Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optional locks for getMany, getById, tryGetById, getFirst, tryGetFirst
- Loading branch information
Showing
101 changed files
with
588 additions
and
266 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = function(alias) { | ||
return ' FOR UPDATE'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
var when = require('a').when; | ||
var c = {}; | ||
|
||
when(c) | ||
.it('should return sql').assertEqual(' FOR UPDATE', c.returned) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = function(alias) { | ||
return ' FOR UPDATE OF ' + alias; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
var a = require('a'); | ||
|
||
function act(c){ | ||
c.mock = a.mock; | ||
c.requireMock = a.requireMock; | ||
c.expectRequire = a.expectRequire; | ||
c.then = a.then; | ||
|
||
c.returned = require('../selectForUpdateSql')('alias'); | ||
} | ||
|
||
module.exports = act; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
var when = require('a').when; | ||
var c = {}; | ||
|
||
when(c) | ||
.it('should return sql').assertEqual(' FOR UPDATE OF alias', c.returned) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
var expected = {}; | ||
var cached = {}; | ||
|
||
function act(c) { | ||
c.expected = expected; | ||
c.tryGetFromCacheById.expect(c.table,c.arg1,c.arg2,c.strategy).return(cached); | ||
c.resultToPromise.expect(cached).return(expected); | ||
c.getExclusive(); | ||
} | ||
|
||
module.exports = act; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
var expected = {}; | ||
function act(c) { | ||
c.expected = expected; | ||
c.tryGetFromCacheById.expect(c.table,c.arg1,c.arg2,c.strategy).return(null); | ||
c.getFromDbById.exclusive.expect(c.table,c.arg1,c.arg2,c.strategy).return(expected); | ||
c.getExclusive(); | ||
} | ||
|
||
module.exports = act; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
table/getByIdSpec/new/isCached/whenGet.js → ...ByIdSpec/notExclusive/isCached/whenGet.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
var when = require('a').when; | ||
var c = {}; | ||
|
||
when('./get',c). | ||
when(c). | ||
it('should return expected').assertEqual(c.expected,c.returned); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,5 +6,4 @@ function act(c) { | |
c.get(); | ||
} | ||
|
||
act.base = '../../new'; | ||
module.exports = act; |
2 changes: 1 addition & 1 deletion
2
table/getByIdSpec/new/notCached/whenGet.js → ...yIdSpec/notExclusive/notCached/whenGet.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
var when = require('a').when; | ||
var c = {}; | ||
|
||
when('./get',c). | ||
when(c). | ||
it('should return expected').assertEqual(c.expected,c.returned); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,23 @@ | ||
var tryGetFromDbById = require('./tryGetFromDbById'); | ||
|
||
function get() { | ||
return tryGetFromDbById.apply(null,arguments).then(onResult); | ||
|
||
function onResult(row) { | ||
if (row === null) | ||
throw new Error("Row not found."); | ||
return row; | ||
} | ||
function get() { | ||
return tryGetFromDbById.apply(null, arguments).then(onResult); | ||
|
||
function onResult(row) { | ||
if (row === null) | ||
throw new Error("Row not found."); | ||
return row; | ||
} | ||
} | ||
|
||
get.exclusive = function() { | ||
return tryGetFromDbById.exclusive.apply(null, arguments).then(onResult); | ||
|
||
function onResult(row) { | ||
if (row === null) | ||
throw new Error("Row not found."); | ||
return row; | ||
} | ||
} | ||
|
||
module.exports = get; | ||
module.exports = get; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
var expected = {}; | ||
|
||
function act(c) { | ||
c.row = {}; | ||
|
||
c.tryGetFromDbById.exclusive.expect(c.table,c.id,c.strategy).resolve(c.row); | ||
|
||
return c.getExclusive(); | ||
} | ||
|
||
module.exports = act; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
var when = require('a').when; | ||
var c = {}; | ||
|
||
when(c).then(function(it) { | ||
it('returns row').assertEqual(c.row, c.returned); | ||
}) |
Oops, something went wrong.