Skip to content

Bind operation to this in #atomic and #transaction #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions db-session.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const api = module.exports = {
return function atomic$operation () {
return Promise.try(() => {
const args = [].slice.call(arguments)
return api.session.atomic(operation, args)
return api.session.atomic(operation.bind(this), args)
})
}
},
Expand All @@ -56,7 +56,7 @@ const api = module.exports = {
return function transaction$operation () {
return Promise.try(() => {
const args = [].slice.call(arguments)
return api.session.transaction(operation, args)
return api.session.transaction(operation.bind(this), args)
})
}
},
Expand Down
8 changes: 4 additions & 4 deletions test/basic-atomic-concurrency-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ test('test nested atomic transaction order', assert => {
}).then(() => {
assert.equal(LOGS.join('\n').replace(/_[\d_]+$/gm, '_TS'), `
BEGIN
SAVEPOINT save_0_runSubOperation_TS
SAVEPOINT save_0_bound_runSubOperation_TS
load 0 0
release 0 0
load 0 1
Expand All @@ -98,10 +98,10 @@ load 0 2
release 0 2
load 0 3
release 0 3
RELEASE SAVEPOINT save_0_runSubOperation_TS
RELEASE SAVEPOINT save_0_bound_runSubOperation_TS
load 1
release 1
SAVEPOINT save_1_runSubOperation_TS
SAVEPOINT save_1_bound_runSubOperation_TS
load 2 0
release 2 0
load 2 1
Expand All @@ -110,7 +110,7 @@ load 2 2
release 2 2
load 2 3
release 2 3
RELEASE SAVEPOINT save_1_runSubOperation_TS
RELEASE SAVEPOINT save_1_bound_runSubOperation_TS
load 3
release 3
COMMIT
Expand Down
4 changes: 2 additions & 2 deletions test/basic-atomic-from-session-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ test('test immediate atomic', assert => {
}).then(() => {
assert.equal(LOGS.join('\n').replace(/_[\d_]+$/gm, '_TS'), `
BEGIN
SAVEPOINT save_0_runOperation_TS
RELEASE SAVEPOINT save_0_runOperation_TS
SAVEPOINT save_0_bound_runOperation_TS
RELEASE SAVEPOINT save_0_bound_runOperation_TS
COMMIT
release
`.trim())
Expand Down
4 changes: 2 additions & 2 deletions test/basic-rollback-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ test('rolling back atomic calls ROLLBACK', assert => {
.then(() => {
assert.equal(LOGS.join('\n').replace(/_[\d_]+$/gm, '_TS'), `
BEGIN
SAVEPOINT save_0_anon_TS
ROLLBACK TO SAVEPOINT save_0_anon_TS
SAVEPOINT save_0_bound_TS
ROLLBACK TO SAVEPOINT save_0_bound_TS
ROLLBACK
`.trim())
})
Expand Down