Skip to content

Commit 890e1eb

Browse files
committed
Remove isOpen method from managed transactions
1 parent e9ed0c2 commit 890e1eb

File tree

7 files changed

+4
-52
lines changed

7 files changed

+4
-52
lines changed

packages/core/src/session.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,6 @@ class Session {
449449
() => this._beginTransaction(accessMode, transactionConfig),
450450
transactionWork,
451451
tx => new ManagedTransaction({
452-
isOpen: tx.isOpen.bind(tx),
453452
run: tx.run.bind(tx),
454453
})
455454
)

packages/core/src/transaction-managed.ts

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,28 +24,19 @@ interface Run {
2424
(query: Query, parameters?: any): Result
2525
}
2626

27-
interface IsOpen {
28-
(): boolean
29-
}
30-
3127
/**
3228
* Represents a transaction that is managed by the transaction executor.
3329
*
3430
* @public
3531
*/
3632
class ManagedTransaction {
3733
private _run: Run
38-
private _isOpen: IsOpen
3934

40-
constructor({ run, isOpen }: { run: Run, isOpen: IsOpen }) {
35+
constructor({ run }: { run: Run }) {
4136
/**
4237
* @private
4338
*/
4439
this._run = run
45-
/**
46-
* @private
47-
*/
48-
this._isOpen = isOpen
4940
}
5041

5142
/**
@@ -59,14 +50,6 @@ class ManagedTransaction {
5950
run(query: Query, parameters?: any): Result {
6051
return this._run(query, parameters)
6152
}
62-
63-
/**
64-
* Check if this transaction is active, which means commit and rollback did not happen.
65-
* @return {boolean} `true` when not committed and not rolled back, `false` otherwise.
66-
*/
67-
isOpen(): boolean {
68-
return this._isOpen()
69-
}
7053
}
7154

7255
export default ManagedTransaction

packages/core/test/session.test.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -317,22 +317,6 @@ describe('session', () => {
317317
expect(status.functionCalled).toEqual(true)
318318
expect(run).toHaveBeenCalledWith(query, params)
319319
})
320-
321-
it('should proxy isOpen to the begun transaction', async () => {
322-
const connection = mockBeginWithSuccess(newFakeConnection())
323-
const session = newSessionWithConnection(connection, false, FETCH_ALL)
324-
const isOpen = jest.spyOn(Transaction.prototype, 'isOpen').mockImplementationOnce(() => true)
325-
const status = { functionCalled: false }
326-
327-
await execute(session)(async (tx: ManagedTransaction) => {
328-
status.functionCalled = true
329-
expect(tx.isOpen()).toBe(true)
330-
})
331-
332-
expect(status.functionCalled).toEqual(true)
333-
expect(isOpen).toHaveBeenCalled()
334-
})
335-
})
336320
})
337321

338322
function mockBeginWithSuccess(connection: FakeConnection) {

packages/neo4j-driver/src/session-rx.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,7 @@ export default class RxSession {
140140
*/
141141
_executeInTransaction (accessMode, work, transactionConfig) {
142142
const wrapper = txc => new RxManagedTransaction({
143-
run: txc.run.bind(txc),
144-
isOpen: txc.isOpen.bind(txc)
143+
run: txc.run.bind(txc)
145144
})
146145
return this._runTransaction(accessMode, work, transactionConfig, wrapper)
147146
}

packages/neo4j-driver/src/transaction-managed-rx.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@
2323
* @public
2424
*/
2525
class RxManagedTransaction {
26-
constructor({ run, isOpen }) {
26+
constructor({ run }) {
2727
this._run = run
28-
this._isOpen = isOpen
2928
}
3029

3130
/**
@@ -39,14 +38,6 @@ class RxManagedTransaction {
3938
run (query, parameters) {
4039
return this._run(query, parameters)
4140
}
42-
43-
/**
44-
* Check if this transaction is active, which means commit and rollback did not happen.
45-
* @return {boolean} `true` when not committed and not rolled back, `false` otherwise.
46-
*/
47-
isOpen() {
48-
return this._isOpen()
49-
}
5041
}
5142

5243
export default RxManagedTransaction

packages/neo4j-driver/test/types/transaction-managed-rx.test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020
import RxManagedTransaction from '../../types/transaction-managed-rx'
2121
import { Record, ResultSummary } from 'neo4j-driver-core'
2222
import RxResult from '../../types/result-rx'
23-
import { Observable, of, Observer, throwError } from 'rxjs'
24-
import { concat, finalize, catchError } from 'rxjs/operators'
23+
import { Observer } from 'rxjs'
2524

2625
const dummy: any = null
2726

@@ -60,5 +59,3 @@ const result2: RxResult = tx.run('RETURN $value', { value: '42' })
6059
result2.keys().subscribe(keysObserver)
6160
result2.records().subscribe(recordsObserver)
6261
result2.consume().subscribe(summaryObserver)
63-
64-
const isOpen: boolean = tx.isOpen()

packages/neo4j-driver/types/transaction-managed-rx.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
declare interface RxManagedTransaction {
2323
run(query: string, parameters?: Parameters): RxResult
24-
isOpen(): boolean
2524
}
2625

2726
export default RxManagedTransaction

0 commit comments

Comments
 (0)