Skip to content

Commit b60d730

Browse files
committed
Bind operation to this in #atomic and #transaction
Not doing this was causing `user-acl-two`'s `Package#delete` to error out due to lack of `this`.
1 parent 1abf35b commit b60d730

4 files changed

+10
-10
lines changed

db-session.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const api = module.exports = {
4747
return function atomic$operation () {
4848
return Promise.try(() => {
4949
const args = [].slice.call(arguments)
50-
return api.session.atomic(operation, args)
50+
return api.session.atomic(operation.bind(this), args)
5151
})
5252
}
5353
},
@@ -56,7 +56,7 @@ const api = module.exports = {
5656
return function transaction$operation () {
5757
return Promise.try(() => {
5858
const args = [].slice.call(arguments)
59-
return api.session.transaction(operation, args)
59+
return api.session.transaction(operation.bind(this), args)
6060
})
6161
}
6262
},

test/basic-atomic-concurrency-test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ test('test nested atomic transaction order', assert => {
8989
}).then(() => {
9090
assert.equal(LOGS.join('\n').replace(/_[\d_]+$/gm, '_TS'), `
9191
BEGIN
92-
SAVEPOINT save_0_runSubOperation_TS
92+
SAVEPOINT save_0_bound_runSubOperation_TS
9393
load 0 0
9494
release 0 0
9595
load 0 1
@@ -98,10 +98,10 @@ load 0 2
9898
release 0 2
9999
load 0 3
100100
release 0 3
101-
RELEASE SAVEPOINT save_0_runSubOperation_TS
101+
RELEASE SAVEPOINT save_0_bound_runSubOperation_TS
102102
load 1
103103
release 1
104-
SAVEPOINT save_1_runSubOperation_TS
104+
SAVEPOINT save_1_bound_runSubOperation_TS
105105
load 2 0
106106
release 2 0
107107
load 2 1
@@ -110,7 +110,7 @@ load 2 2
110110
release 2 2
111111
load 2 3
112112
release 2 3
113-
RELEASE SAVEPOINT save_1_runSubOperation_TS
113+
RELEASE SAVEPOINT save_1_bound_runSubOperation_TS
114114
load 3
115115
release 3
116116
COMMIT

test/basic-atomic-from-session-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ test('test immediate atomic', assert => {
2828
}).then(() => {
2929
assert.equal(LOGS.join('\n').replace(/_[\d_]+$/gm, '_TS'), `
3030
BEGIN
31-
SAVEPOINT save_0_runOperation_TS
32-
RELEASE SAVEPOINT save_0_runOperation_TS
31+
SAVEPOINT save_0_bound_runOperation_TS
32+
RELEASE SAVEPOINT save_0_bound_runOperation_TS
3333
COMMIT
3434
release
3535
`.trim())

test/basic-rollback-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ test('rolling back atomic calls ROLLBACK', assert => {
4949
.then(() => {
5050
assert.equal(LOGS.join('\n').replace(/_[\d_]+$/gm, '_TS'), `
5151
BEGIN
52-
SAVEPOINT save_0_anon_TS
53-
ROLLBACK TO SAVEPOINT save_0_anon_TS
52+
SAVEPOINT save_0_bound_TS
53+
ROLLBACK TO SAVEPOINT save_0_bound_TS
5454
ROLLBACK
5555
`.trim())
5656
})

0 commit comments

Comments
 (0)