orange-orm 4.4.2 → 4.5.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +12 -6
- package/src/client/clientMap.js +2 -0
- package/src/client/createProviders.js +12 -0
- package/src/client/index.js +6 -3
- package/src/client/index.mjs +8 -3
- package/src/client/map.js +1 -0
- package/src/createDomain.js +11 -16
- package/src/d1/newDatabase.js +119 -0
- package/src/d1/newPool.js +19 -0
- package/src/d1/newTransaction.js +82 -0
- package/src/d1/pool/end.js +13 -0
- package/src/d1/pool/newGenericPool.js +53 -0
- package/src/d1/wrapQuery.js +22 -0
- package/src/d1test.js +35 -0
- package/src/emitEvent.js +6 -4
- package/src/emptyFilter.js +12 -12
- package/src/getManyDto/newQuery.js +5 -5
- package/src/getManyDto/query/newSingleQuery.js +5 -5
- package/src/getManyDto.js +25 -24
- package/src/hostExpress/cycle.ts +211 -0
- package/src/hostExpress/executePath.js +360 -357
- package/src/hostLocal.js +8 -8
- package/src/index.d.ts +2 -0
- package/src/index.js +19 -15
- package/src/map.d.ts +3 -0
- package/src/mssql/newDatabase.js +19 -31
- package/src/mssql/newPool.js +2 -2
- package/src/mssql/newTransaction.js +5 -4
- package/src/mssql/pool/newGenericPool.js +1 -1
- package/src/mySql/deleteFromSql.js +1 -1
- package/src/mySql/insert.js +5 -5
- package/src/mySql/insertSql.js +2 -3
- package/src/mySql/lastInsertedSql.js +3 -4
- package/src/mySql/newDatabase.js +20 -34
- package/src/mySql/newPool.js +10 -10
- package/src/mySql/newTransaction.js +3 -3
- package/src/mySql/pool/newGenericPool.js +2 -3
- package/src/mySql/quote.js +1 -0
- package/src/newImmutable.js +1 -2
- package/src/oracle/deleteFromSql.js +1 -1
- package/src/oracle/formatDateOut.js +1 -1
- package/src/oracle/insert.js +6 -6
- package/src/oracle/insertSql.js +6 -14
- package/src/oracle/lastInsertedSql.js +3 -3
- package/src/oracle/mergeSql.js +3 -6
- package/src/oracle/newDatabase.js +18 -33
- package/src/oracle/newInsertCommandCore.js +3 -3
- package/src/oracle/newPool.js +10 -10
- package/src/oracle/newTransaction.js +3 -2
- package/src/oracle/pool/newGenericPool.js +2 -2
- package/src/oracle/quote.js +1 -0
- package/src/oracle/wrapQuery.js +0 -3
- package/src/patchRow.js +2 -2
- package/src/patchTable.js +6 -5
- package/src/pg/deleteFromSql.js +1 -1
- package/src/pg/formatDateOut.js +1 -2
- package/src/pg/insert.js +3 -3
- package/src/pg/insertSql.js +2 -7
- package/src/pg/lastInsertedSql.js +1 -2
- package/src/pg/newDatabase.js +20 -37
- package/src/pg/newPool.js +10 -10
- package/src/pg/newTransaction.js +3 -2
- package/src/pg/pool/newPgPool.js +2 -2
- package/src/pg/quote.js +2 -0
- package/src/pg/schema.js +2 -2
- package/src/{mySql/pool/defaults.js → poolDefaults.js} +0 -2
- package/src/query.js +2 -2
- package/src/sap/deleteFromSql.js +1 -1
- package/src/sap/formatDateOut.js +1 -1
- package/src/sap/insert.js +5 -5
- package/src/sap/insertSql.js +4 -5
- package/src/sap/lastInsertedSql.js +3 -3
- package/src/sap/mergeSql.js +1 -2
- package/src/sap/newDatabase.js +23 -34
- package/src/sap/newPool.js +2 -2
- package/src/sap/newTransaction.js +3 -2
- package/src/sap/quote.js +1 -0
- package/src/sqlite/deleteFromSql.js +1 -1
- package/src/sqlite/insert.js +5 -5
- package/src/sqlite/insertSql.js +2 -2
- package/src/sqlite/lastInsertedSql.js +2 -2
- package/src/sqlite/newDatabase.js +16 -32
- package/src/sqlite/newPool.js +10 -10
- package/src/sqlite/newTransaction.js +3 -2
- package/src/sqlite/pool/newGenericPool.js +2 -1
- package/src/sqlite/quote.js +1 -0
- package/src/table/aggregate.js +1 -1
- package/src/table/begin.js +5 -5
- package/src/table/cascadeDelete.js +2 -2
- package/src/table/column/binary/newDecode.js +2 -2
- package/src/table/column/binary/newEncode.js +3 -4
- package/src/table/column/boolean/newDecode.js +1 -1
- package/src/table/column/boolean/newEncode.js +6 -6
- package/src/table/column/date/formatOut.js +3 -5
- package/src/table/column/date/newDecode.js +2 -2
- package/src/table/column/date/newEncode.js +8 -8
- package/src/table/column/date.js +1 -1
- package/src/table/column/dateWithTimeZone/newEncode.js +3 -4
- package/src/table/column/dateWithTimeZone.js +1 -1
- package/src/table/column/encodeFilterArg.js +3 -3
- package/src/table/column/equal.js +3 -3
- package/src/table/column/extractAlias.js +0 -2
- package/src/table/column/greaterThan.js +3 -3
- package/src/table/column/greaterThanOrEqual.js +3 -3
- package/src/table/column/guid/newDecode.js +1 -1
- package/src/table/column/guid/newEncode.js +3 -3
- package/src/table/column/in.js +3 -3
- package/src/table/column/json/formatOut.js +3 -3
- package/src/table/column/json/newDecode.js +3 -3
- package/src/table/column/json/newEncode.js +6 -6
- package/src/table/column/json.js +2 -1
- package/src/table/column/lessThan.js +3 -3
- package/src/table/column/lessThanOrEqual.js +4 -4
- package/src/table/column/negotiateRawSqlFilter.js +9 -9
- package/src/table/column/newBoolean.js +9 -9
- package/src/table/column/newColumn.js +21 -21
- package/src/table/column/newDecodeCore.js +1 -1
- package/src/table/column/notEqual.js +3 -3
- package/src/table/column/numeric/newDecode.js +2 -2
- package/src/table/column/numeric/newEncode.js +3 -3
- package/src/table/column/string/contains.js +2 -1
- package/src/table/column/string/containsCore.js +5 -5
- package/src/table/column/string/endsWith.js +1 -1
- package/src/table/column/string/endsWithCore.js +4 -4
- package/src/table/column/string/iContains.js +2 -1
- package/src/table/column/string/iEndsWith.js +1 -1
- package/src/table/column/string/iEqual.js +3 -3
- package/src/table/column/string/iStartsWith.js +1 -1
- package/src/table/column/string/newEncode.js +3 -3
- package/src/table/column/string/startsWith.js +1 -1
- package/src/table/column/string/startsWithCore.js +4 -4
- package/src/table/column/string.js +14 -14
- package/src/table/commands/beginCommand.js +2 -2
- package/src/table/commands/compressChanges.js +2 -2
- package/src/table/commands/delete/newSingleCommand.js +5 -5
- package/src/table/commands/delete/singleCommand/joinSql.js +12 -12
- package/src/table/commands/delete/singleCommand/newSingleCommandCore.js +2 -2
- package/src/table/commands/delete/singleCommand/selectSql.js +6 -6
- package/src/table/commands/delete/singleCommand/subFilter.js +11 -11
- package/src/table/commands/delete/singleCommand/whereSql.js +2 -2
- package/src/table/commands/getChangeSet.js +2 -2
- package/src/table/commands/insert/getSqlTemplate.js +16 -16
- package/src/table/commands/lastCommandMatches.js +2 -2
- package/src/table/commands/newDeleteCommand.js +5 -5
- package/src/table/commands/newGetLastInsertedCommand.js +4 -4
- package/src/table/commands/newGetLastInsertedCommandCore.js +5 -5
- package/src/table/commands/newInsertCommand.js +0 -1
- package/src/table/commands/newInsertCommandCore.js +3 -3
- package/src/table/commands/newRow.js +4 -4
- package/src/table/commands/newUpdateCommand.js +4 -4
- package/src/table/commands/newUpdateCommandCore.js +4 -4
- package/src/table/commands/pushCommand.js +2 -2
- package/src/table/commit.js +13 -11
- package/src/table/count.js +8 -8
- package/src/table/delete.js +4 -4
- package/src/table/deleteSessionContext.js +4 -13
- package/src/table/executeQueries/executeChanges.js +3 -3
- package/src/table/executeQueries/executeQueriesCore.js +2 -2
- package/src/table/executeQueries/executeQuery.js +2 -2
- package/src/table/executeQueries/resolveExecuteQuery.js +4 -4
- package/src/table/executeQueries.js +4 -4
- package/src/table/getFromDbById.js +1 -1
- package/src/table/getMany.js +7 -7
- package/src/table/getManyDto.js +3 -4
- package/src/table/getSessionContext.js +4 -4
- package/src/table/getSessionSingleton.js +3 -2
- package/src/table/groupBy/newQuery.js +4 -4
- package/src/table/groupBy.js +9 -9
- package/src/table/insert.js +10 -13
- package/src/table/joinRelation/getRelatives.js +6 -6
- package/src/table/newGetRelated.js +3 -3
- package/src/table/newManyRelation.js +9 -9
- package/src/table/newOneRelation.js +9 -9
- package/src/table/newPrimaryKeyFilter.js +6 -6
- package/src/table/newQuery.js +5 -5
- package/src/table/newRelatedTable.js +2 -2
- package/src/table/newRowCache.js +17 -17
- package/src/table/newThrow.js +2 -2
- package/src/table/oneRelation/getRelatives.js +5 -5
- package/src/table/popChanges.js +3 -3
- package/src/table/promise.js +2 -8
- package/src/table/query/extractLimit.js +2 -2
- package/src/table/query/extractOffset.js +2 -2
- package/src/table/query/extractOrderBy.js +2 -2
- package/src/table/query/newSingleQuery.js +7 -7
- package/src/table/query/singleQuery/columnSql/joinLegToColumnSql.js +5 -5
- package/src/table/query/singleQuery/columnSql/newJoinedColumnSql.js +2 -2
- package/src/table/query/singleQuery/columnSql/newShallowColumnSql.js +4 -4
- package/src/table/query/singleQuery/joinSql/joinLegToJoinSql.js +2 -2
- package/src/table/query/singleQuery/joinSql/joinLegToShallowJoinSql.js +2 -2
- package/src/table/query/singleQuery/joinSql/newDiscriminatorSql.js +2 -2
- package/src/table/query/singleQuery/joinSql/newShallowJoinSql.js +5 -5
- package/src/table/query/singleQuery/joinSql/newShallowJoinSqlCore.js +6 -5
- package/src/table/query/singleQuery/joinSql/oneLegToJoinSql.js +2 -2
- package/src/table/query/singleQuery/joinSql/oneLegToShallowJoinSql.js +2 -2
- package/src/table/query/singleQuery/negotiateExclusive.js +2 -2
- package/src/table/query/singleQuery/newColumnSql.js +3 -3
- package/src/table/query/singleQuery/newDiscriminatorSql.js +2 -2
- package/src/table/query/singleQuery/newJoinSql.js +6 -6
- package/src/table/query/singleQuery/newWhereSql.js +3 -3
- package/src/table/quote.js +4 -4
- package/src/table/relatedTable/aggregate.js +2 -2
- package/src/table/relatedTable/all.js +5 -5
- package/src/table/relatedTable/any.js +3 -3
- package/src/table/relatedTable/childColumn.js +12 -12
- package/src/table/relatedTable/columnAggregate.js +3 -3
- package/src/table/relatedTable/columnAggregateGroup.js +11 -11
- package/src/table/relatedTable/joinSql.js +5 -5
- package/src/table/relatedTable/joinSqlArray.js +3 -3
- package/src/table/relatedTable/none.js +3 -3
- package/src/table/relatedTable/relatedColumn.js +13 -13
- package/src/table/relatedTable/selectSql.js +2 -2
- package/src/table/relatedTable/subFilter.js +4 -4
- package/src/table/relatedTable/where.js +3 -3
- package/src/table/relatedTable/whereSql.js +2 -2
- package/src/table/relation/manyCache/synchronizeAdded.js +2 -2
- package/src/table/relation/manyCache/synchronizeChanged.js +3 -3
- package/src/table/relation/manyCache/synchronizeRemoved.js +2 -2
- package/src/table/relation/newForeignKeyFilter.js +2 -2
- package/src/table/relation/newManyCache.js +16 -16
- package/src/table/relation/newOneCache.js +6 -6
- package/src/table/releaseDbClient.js +4 -4
- package/src/table/resultToPromise.js +1 -3
- package/src/table/resultToRows/dbRowToRow.js +8 -8
- package/src/table/resultToRows/dbRowsToRows.js +2 -2
- package/src/table/resultToRows/decodeDbRow.js +2 -2
- package/src/table/resultToRows/delete/removeFromCache.js +6 -6
- package/src/table/resultToRows/delete.js +6 -6
- package/src/table/resultToRows/newDecodeDbRow.js +19 -18
- package/src/table/resultToRows/toDto.js +3 -3
- package/src/table/resultToRows.js +3 -3
- package/src/table/rollback.js +21 -11
- package/src/table/rowArray/negotiateNextTick.js +1 -2
- package/src/table/setSessionSingleton.js +6 -3
- package/src/table/tryGetFirstFromDb.js +4 -4
- package/src/table/tryGetFromCacheById.js +3 -3
- package/src/table/tryGetFromDbById/extractStrategy.js +2 -2
- package/src/table/tryGetFromDbById.js +8 -6
- package/src/table/tryGetSessionContext.js +5 -10
- package/src/table/tryReleaseDbClient.js +2 -2
- package/src/table/updateField.js +4 -4
- package/src/table/where.js +2 -2
- package/src/table.js +58 -51
- package/src/tedious/deleteFromSql.js +1 -1
- package/src/tedious/formatDateOut.js +1 -1
- package/src/tedious/getManyDto/newQueryCore.js +5 -5
- package/src/tedious/getManyDto/query/newSingleQuery.js +5 -5
- package/src/tedious/getManyDto/query/newSubQueries/joinLegToQuery.js +3 -3
- package/src/tedious/getManyDto/query/newSubQueries/manyLegToQuery.js +3 -3
- package/src/tedious/getManyDto/query/newSubQueries/oneLegToQuery.js +4 -4
- package/src/tedious/getManyDto/query/newSubQueries.js +8 -8
- package/src/tedious/getManyDto/query/singleQuery/newShallowColumnSql.js +5 -6
- package/src/tedious/getManyDto.js +6 -6
- package/src/tedious/insert.js +3 -3
- package/src/tedious/insertSql.js +3 -3
- package/src/tedious/newDatabase.js +17 -30
- package/src/tedious/newPool.js +10 -10
- package/src/tedious/newTransaction.js +4 -5
- package/src/tedious/pool/newGenericPool.js +1 -1
- package/src/tedious/quote.js +1 -0
- package/src/mssql/pool/defaults.js +0 -45
- package/src/oracle/pool/defaults.js +0 -45
- package/src/pg/pool/defaults.js +0 -45
- package/src/sqlite/pool/defaults.js +0 -45
- package/src/tedious/pool/defaults.js +0 -45
package/README.md
CHANGED
|
@@ -1867,7 +1867,7 @@ Supported functions include:
|
|
|
1867
1867
|
- avg
|
|
1868
1868
|
|
|
1869
1869
|
__On each row__
|
|
1870
|
-
In this example, we are counting the number of lines
|
|
1870
|
+
In this example, we are counting the number of lines on each order. This is represented as the property <i>numberOfLines</i>. You can name these aggregated properties whatever you want.
|
|
1871
1871
|
You can also elevate associated data to the a parent level for easier access. In the example below, <i>balance</i> of the customer is elevated to the root level.
|
|
1872
1872
|
|
|
1873
1873
|
```javascript
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "orange-orm",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.0-beta.1",
|
|
4
4
|
"main": "./src/index.js",
|
|
5
5
|
"browser": "./src/client/index.mjs",
|
|
6
6
|
"bin": {
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"mssql",
|
|
20
20
|
"Microsoft Sql Server",
|
|
21
21
|
"PostgreSql",
|
|
22
|
+
"Cloudflare D1",
|
|
22
23
|
"Postgres",
|
|
23
24
|
"pg",
|
|
24
25
|
"sap",
|
|
@@ -48,7 +49,7 @@
|
|
|
48
49
|
"lint": "eslint ./",
|
|
49
50
|
"fix": "eslint ./ --fix",
|
|
50
51
|
"owasp": "owasp-dependency-check --project \"MY_PROJECT\" --scan \"package-lock.json\" --exclude \"dependency-check-bin\" --out \"owasp\" --format HTML",
|
|
51
|
-
"beta": "publish --tag beta"
|
|
52
|
+
"beta": "npm publish --tag beta"
|
|
52
53
|
},
|
|
53
54
|
"dependencies": {
|
|
54
55
|
"@lroal/on-change": "^4.0.2",
|
|
@@ -58,15 +59,14 @@
|
|
|
58
59
|
"@types/tedious": "^4.0.14",
|
|
59
60
|
"ajv": "^6.10.2",
|
|
60
61
|
"axios": "^1.6.2",
|
|
61
|
-
"deferred": "^0.7.5",
|
|
62
62
|
"fast-json-patch": "^3.1.1",
|
|
63
63
|
"findup-sync": "^5.0.0",
|
|
64
64
|
"glob": "^10.3.4",
|
|
65
65
|
"module-definition": "^4.0.0",
|
|
66
66
|
"node-cls": "^1.0.5",
|
|
67
|
-
"promise": "^8.0.3",
|
|
68
67
|
"rfdc": "^1.2.0",
|
|
69
|
-
"uuid": "^8.3.2"
|
|
68
|
+
"uuid": "^8.3.2",
|
|
69
|
+
"wrangler": "^3.107.2"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
72
|
"msnodesqlv8": "^4.1.0",
|
|
@@ -99,9 +99,14 @@
|
|
|
99
99
|
},
|
|
100
100
|
"tedious": {
|
|
101
101
|
"optional": true
|
|
102
|
+
},
|
|
103
|
+
"oracledb": {
|
|
104
|
+
"optional": true
|
|
102
105
|
}
|
|
103
106
|
},
|
|
104
107
|
"devDependencies": {
|
|
108
|
+
"@cloudflare/workers-types": "^4.20241106.0",
|
|
109
|
+
"@miniflare/d1": "^2.14.4",
|
|
105
110
|
"@rollup/plugin-commonjs": "^21.0.1",
|
|
106
111
|
"@rollup/plugin-node-resolve": "^13.0.0",
|
|
107
112
|
"@typescript-eslint/eslint-plugin": "^6.x",
|
|
@@ -111,6 +116,7 @@
|
|
|
111
116
|
"eslint": "^8.57.0",
|
|
112
117
|
"eslint-plugin-jest": "^27.1.7",
|
|
113
118
|
"express": "^4.18.2",
|
|
119
|
+
"miniflare": "^3.20250129.0",
|
|
114
120
|
"msnodesqlv8": "^4.1.0",
|
|
115
121
|
"mysql2": "^3.9.4",
|
|
116
122
|
"oracledb": "^6.3.0",
|
|
@@ -121,7 +127,7 @@
|
|
|
121
127
|
"sqlite3": "^5.0.2",
|
|
122
128
|
"tedious": "^18.2.0",
|
|
123
129
|
"typescript": "^5.4.5",
|
|
124
|
-
"vitest": "^0.34.
|
|
130
|
+
"vitest": "^0.34.6"
|
|
125
131
|
},
|
|
126
132
|
"engines": {
|
|
127
133
|
"node": ">= 8.0.0"
|
package/src/client/clientMap.js
CHANGED
|
@@ -39,6 +39,7 @@ function map(index, _fn) {
|
|
|
39
39
|
dbMap.sap = throwDb;
|
|
40
40
|
dbMap.oracle = throwDb;
|
|
41
41
|
dbMap.sqlite = throwDb;
|
|
42
|
+
dbMap.d1 = throwDb;
|
|
42
43
|
|
|
43
44
|
function throwDb() {
|
|
44
45
|
throw new Error('Cannot create pool for database outside node');
|
|
@@ -65,6 +66,7 @@ function map(index, _fn) {
|
|
|
65
66
|
onFinal.sap = () => index({ db: throwDb, providers: dbMap });
|
|
66
67
|
onFinal.oracle = () => index({ db: throwDb, providers: dbMap });
|
|
67
68
|
onFinal.sqlite = () => index({ db: throwDb, providers: dbMap });
|
|
69
|
+
onFinal.d1 = () => index({ db: throwDb, providers: dbMap });
|
|
68
70
|
|
|
69
71
|
return new Proxy(onFinal, handler);
|
|
70
72
|
}
|
|
@@ -48,6 +48,11 @@ function createProviders(index) {
|
|
|
48
48
|
return createPool.bind(null, 'sqlite');
|
|
49
49
|
}
|
|
50
50
|
});
|
|
51
|
+
Object.defineProperty(dbMap, 'd1', {
|
|
52
|
+
get: function() {
|
|
53
|
+
return createPool.bind(null, 'd1');
|
|
54
|
+
}
|
|
55
|
+
});
|
|
51
56
|
Object.defineProperty(dbMap, 'http', {
|
|
52
57
|
get: function() {
|
|
53
58
|
return createPool.bind(null, 'http');
|
|
@@ -97,12 +102,19 @@ function negotiateCachedPool(fn, providers) {
|
|
|
97
102
|
get sqlite() {
|
|
98
103
|
return createPool.bind(null, 'sqlite');
|
|
99
104
|
},
|
|
105
|
+
get d1() {
|
|
106
|
+
return createPool.bind(null, 'd1');
|
|
107
|
+
},
|
|
100
108
|
get http() {
|
|
101
109
|
return createPool.bind(null, 'http');
|
|
102
110
|
}
|
|
103
111
|
};
|
|
104
112
|
|
|
105
113
|
function createPool(providerName, ...args) {
|
|
114
|
+
//todo
|
|
115
|
+
if (providerName === 'd1') {
|
|
116
|
+
return providers[providerName].apply(null, args);
|
|
117
|
+
}
|
|
106
118
|
const key = JSON.stringify(args);
|
|
107
119
|
if (!cache[providerName])
|
|
108
120
|
cache[providerName] = {};
|
package/src/client/index.js
CHANGED
|
@@ -57,6 +57,7 @@ function rdbClient(options = {}) {
|
|
|
57
57
|
client.mssqlNative = onProvider.bind(null, 'mssqlNative');
|
|
58
58
|
client.pg = onProvider.bind(null, 'pg');
|
|
59
59
|
client.postgres = onProvider.bind(null, 'postgres');
|
|
60
|
+
client.d1 = onProvider.bind(null, 'd1');
|
|
60
61
|
client.sqlite = onProvider.bind(null, 'sqlite');
|
|
61
62
|
client.sap = onProvider.bind(null, 'sap');
|
|
62
63
|
client.oracle = onProvider.bind(null, 'oracle');
|
|
@@ -128,7 +129,8 @@ function rdbClient(options = {}) {
|
|
|
128
129
|
}
|
|
129
130
|
|
|
130
131
|
async function query() {
|
|
131
|
-
|
|
132
|
+
const adapter = netAdapter(baseUrl, undefined, { tableOptions: { db: baseUrl, transaction } });
|
|
133
|
+
return adapter.query.apply(null, arguments);
|
|
132
134
|
}
|
|
133
135
|
|
|
134
136
|
function express(arg) {
|
|
@@ -168,13 +170,14 @@ function rdbClient(options = {}) {
|
|
|
168
170
|
if (!db.createTransaction)
|
|
169
171
|
throw new Error('Transaction not supported through http');
|
|
170
172
|
const transaction = db.createTransaction(_options);
|
|
173
|
+
|
|
171
174
|
try {
|
|
172
175
|
const nextClient = client({ transaction });
|
|
173
176
|
await fn(nextClient);
|
|
174
|
-
await transaction(
|
|
177
|
+
await transaction(transaction.commit);
|
|
175
178
|
}
|
|
176
179
|
catch (e) {
|
|
177
|
-
await transaction(
|
|
180
|
+
await transaction(transaction.rollback.bind(null, e));
|
|
178
181
|
}
|
|
179
182
|
}
|
|
180
183
|
|
package/src/client/index.mjs
CHANGED
|
@@ -5594,6 +5594,7 @@ function map$1(index, _fn) {
|
|
|
5594
5594
|
dbMap.sap = throwDb;
|
|
5595
5595
|
dbMap.oracle = throwDb;
|
|
5596
5596
|
dbMap.sqlite = throwDb;
|
|
5597
|
+
dbMap.d1 = throwDb;
|
|
5597
5598
|
|
|
5598
5599
|
function throwDb() {
|
|
5599
5600
|
throw new Error('Cannot create pool for database outside node');
|
|
@@ -5620,6 +5621,7 @@ function map$1(index, _fn) {
|
|
|
5620
5621
|
onFinal.sap = () => index({ db: throwDb, providers: dbMap });
|
|
5621
5622
|
onFinal.oracle = () => index({ db: throwDb, providers: dbMap });
|
|
5622
5623
|
onFinal.sqlite = () => index({ db: throwDb, providers: dbMap });
|
|
5624
|
+
onFinal.d1 = () => index({ db: throwDb, providers: dbMap });
|
|
5623
5625
|
|
|
5624
5626
|
return new Proxy(onFinal, handler);
|
|
5625
5627
|
}
|
|
@@ -5930,6 +5932,7 @@ function rdbClient(options = {}) {
|
|
|
5930
5932
|
client.mssqlNative = onProvider.bind(null, 'mssqlNative');
|
|
5931
5933
|
client.pg = onProvider.bind(null, 'pg');
|
|
5932
5934
|
client.postgres = onProvider.bind(null, 'postgres');
|
|
5935
|
+
client.d1 = onProvider.bind(null, 'd1');
|
|
5933
5936
|
client.sqlite = onProvider.bind(null, 'sqlite');
|
|
5934
5937
|
client.sap = onProvider.bind(null, 'sap');
|
|
5935
5938
|
client.oracle = onProvider.bind(null, 'oracle');
|
|
@@ -6001,7 +6004,8 @@ function rdbClient(options = {}) {
|
|
|
6001
6004
|
}
|
|
6002
6005
|
|
|
6003
6006
|
async function query() {
|
|
6004
|
-
|
|
6007
|
+
const adapter = netAdapter(baseUrl, undefined, { tableOptions: { db: baseUrl, transaction } });
|
|
6008
|
+
return adapter.query.apply(null, arguments);
|
|
6005
6009
|
}
|
|
6006
6010
|
|
|
6007
6011
|
function express(arg) {
|
|
@@ -6041,13 +6045,14 @@ function rdbClient(options = {}) {
|
|
|
6041
6045
|
if (!db.createTransaction)
|
|
6042
6046
|
throw new Error('Transaction not supported through http');
|
|
6043
6047
|
const transaction = db.createTransaction(_options);
|
|
6048
|
+
|
|
6044
6049
|
try {
|
|
6045
6050
|
const nextClient = client({ transaction });
|
|
6046
6051
|
await fn(nextClient);
|
|
6047
|
-
await transaction(
|
|
6052
|
+
await transaction(transaction.commit);
|
|
6048
6053
|
}
|
|
6049
6054
|
catch (e) {
|
|
6050
|
-
await transaction(
|
|
6055
|
+
await transaction(transaction.rollback.bind(null, e));
|
|
6051
6056
|
}
|
|
6052
6057
|
}
|
|
6053
6058
|
|
package/src/client/map.js
CHANGED
|
@@ -48,6 +48,7 @@ function map(index, context, providers, fn) {
|
|
|
48
48
|
context.sap = connect.bind(null, 'sap');
|
|
49
49
|
context.oracle = connect.bind(null, 'oracle');
|
|
50
50
|
context.sqlite = connect.bind(null, 'sqlite');
|
|
51
|
+
context.d1 = connect.bind(null, 'd1');
|
|
51
52
|
context.http = function(url) {
|
|
52
53
|
return index({ db: url, providers});
|
|
53
54
|
};
|
package/src/createDomain.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
let cls;
|
|
3
|
-
var Domain = require('domain');
|
|
1
|
+
var Domain = require('node:domain');
|
|
4
2
|
var negotiateForwardProperty = require('./createDomain/negotiateForwardProperty');
|
|
5
3
|
|
|
6
|
-
function
|
|
4
|
+
function createNodeDomain() {
|
|
7
5
|
var oldDomain = Domain.active || {};
|
|
8
6
|
var domain = Domain.create();
|
|
9
7
|
var ownProperties = Object.getOwnPropertyNames(oldDomain);
|
|
@@ -13,19 +11,16 @@ function createDomain() {
|
|
|
13
11
|
return domain;
|
|
14
12
|
}
|
|
15
13
|
|
|
16
|
-
function createOnContext() {
|
|
17
|
-
if (!cls)
|
|
18
|
-
cls = require('node-cls');
|
|
19
|
-
return cls.create('rdb');
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
function _createDomain() {
|
|
24
|
-
if (useHook())
|
|
25
|
-
return createOnContext();
|
|
26
|
-
else
|
|
27
|
-
return createDomain();
|
|
28
14
|
|
|
15
|
+
function _createDomain(useNodeDomain) {
|
|
16
|
+
if (useNodeDomain)
|
|
17
|
+
return createNodeDomain();
|
|
18
|
+
let c = {};
|
|
19
|
+
function run(fn) {
|
|
20
|
+
return fn(c);
|
|
21
|
+
}
|
|
22
|
+
c.run = run;
|
|
23
|
+
return c;
|
|
29
24
|
}
|
|
30
25
|
|
|
31
26
|
module.exports = _createDomain;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
let createDomain = require('../createDomain');
|
|
2
|
+
let newTransaction = require('./newTransaction');
|
|
3
|
+
let _begin = require('../table/begin');
|
|
4
|
+
let commit = require('../table/commit');
|
|
5
|
+
let rollback = require('../table/rollback');
|
|
6
|
+
let newPool = require('./newPool');
|
|
7
|
+
let express = require('../hostExpress');
|
|
8
|
+
let hostLocal = require('../hostLocal');
|
|
9
|
+
let doQuery = require('../query');
|
|
10
|
+
let releaseDbClient = require('../table/releaseDbClient');
|
|
11
|
+
let setSessionSingleton = require('../table/setSessionSingleton');
|
|
12
|
+
|
|
13
|
+
function newDatabase(d1Database, poolOptions) {
|
|
14
|
+
if (!d1Database)
|
|
15
|
+
throw new Error('Missing d1Database');
|
|
16
|
+
var pool;
|
|
17
|
+
if (!poolOptions)
|
|
18
|
+
pool = newPool.bind(null,d1Database, poolOptions);
|
|
19
|
+
else
|
|
20
|
+
pool = newPool(d1Database, poolOptions);
|
|
21
|
+
|
|
22
|
+
let c = {poolFactory: pool, hostLocal, express};
|
|
23
|
+
|
|
24
|
+
c.transaction = function(options, fn) {
|
|
25
|
+
if ((arguments.length === 1) && (typeof options === 'function')) {
|
|
26
|
+
fn = options;
|
|
27
|
+
options = undefined;
|
|
28
|
+
}
|
|
29
|
+
let domain = createDomain();
|
|
30
|
+
|
|
31
|
+
if (fn)
|
|
32
|
+
return domain.run(runInTransaction);
|
|
33
|
+
else
|
|
34
|
+
return domain.run(run);
|
|
35
|
+
|
|
36
|
+
async function runInTransaction() {
|
|
37
|
+
let result;
|
|
38
|
+
let transaction = newTransaction(domain, pool, options);
|
|
39
|
+
await new Promise(transaction)
|
|
40
|
+
.then(begin)
|
|
41
|
+
.then(() => fn(domain))
|
|
42
|
+
.then((res) => result = res)
|
|
43
|
+
.then(() => c.commit(domain))
|
|
44
|
+
.then(null, (e) => c.rollback(domain,e));
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function begin() {
|
|
49
|
+
const transactionLess = true;
|
|
50
|
+
return _begin(domain, transactionLess);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function run() {
|
|
54
|
+
let p;
|
|
55
|
+
let transaction = newTransaction(domain, pool, options);
|
|
56
|
+
p = new Promise(transaction);
|
|
57
|
+
|
|
58
|
+
return p.then(begin);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
c.createTransaction = function(options) {
|
|
64
|
+
let domain = createDomain();
|
|
65
|
+
let transaction = newTransaction(domain, pool, options);
|
|
66
|
+
let p = domain.run(() => new Promise(transaction).then(begin));
|
|
67
|
+
|
|
68
|
+
function run(fn) {
|
|
69
|
+
return p.then(domain.run.bind(domain, fn));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function begin() {
|
|
73
|
+
return _begin(domain, options);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
run.rollback = rollback.bind(null, domain);
|
|
77
|
+
run.commit = commit.bind(null, domain);
|
|
78
|
+
|
|
79
|
+
return run;
|
|
80
|
+
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
c.query = function(query) {
|
|
84
|
+
let domain = createDomain();
|
|
85
|
+
let transaction = newTransaction(domain, pool);
|
|
86
|
+
let p = domain.run(() => new Promise(transaction)
|
|
87
|
+
.then(() => setSessionSingleton(domain, 'changes', []))
|
|
88
|
+
.then(() => doQuery(domain, query).then(onResult, onError)));
|
|
89
|
+
return p;
|
|
90
|
+
|
|
91
|
+
function onResult(result) {
|
|
92
|
+
releaseDbClient(domain);
|
|
93
|
+
return result;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function onError(e) {
|
|
97
|
+
releaseDbClient(domain);
|
|
98
|
+
throw e;
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
c.rollback = rollback;
|
|
103
|
+
c.commit = commit;
|
|
104
|
+
|
|
105
|
+
c.end = function() {
|
|
106
|
+
if (poolOptions)
|
|
107
|
+
return pool.end();
|
|
108
|
+
else
|
|
109
|
+
return Promise.resolve();
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
c.accept = function(caller) {
|
|
113
|
+
caller.visitSqlite();
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
return c;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
module.exports = newDatabase;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const promisify = require('node:util').promisify;
|
|
2
|
+
const pools = require('../pools');
|
|
3
|
+
const end = require('./pool/end');
|
|
4
|
+
const newGenericPool = require('./pool/newGenericPool');
|
|
5
|
+
const newId = require('../newId');
|
|
6
|
+
|
|
7
|
+
function newPool(d1Database, poolOptions) {
|
|
8
|
+
var pool = newGenericPool(d1Database, poolOptions);
|
|
9
|
+
var id = newId();
|
|
10
|
+
var boundEnd = end.bind(null, pool, id);
|
|
11
|
+
var c = {};
|
|
12
|
+
|
|
13
|
+
c.connect = pool.connect;
|
|
14
|
+
c.end = promisify(boundEnd);
|
|
15
|
+
pools[id] = c;
|
|
16
|
+
return c;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
module.exports = newPool;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
const wrapQuery = require('./wrapQuery');
|
|
2
|
+
const encodeBoolean = require('../sqlite/encodeBoolean');
|
|
3
|
+
const deleteFromSql = require('../sqlite/deleteFromSql');
|
|
4
|
+
const selectForUpdateSql = require('../sqlite/selectForUpdateSql');
|
|
5
|
+
const lastInsertedSql = require('../sqlite/lastInsertedSql');
|
|
6
|
+
const limitAndOffset = require('../sqlite/limitAndOffset');
|
|
7
|
+
const insertSql = require('../sqlite/insertSql');
|
|
8
|
+
const insert = require('../sqlite/insert');
|
|
9
|
+
|
|
10
|
+
function newResolveTransaction(domain, pool, { readonly = false } = {}) {
|
|
11
|
+
var rdb = {poolFactory: pool};
|
|
12
|
+
if (!pool.connect) {
|
|
13
|
+
pool = pool();
|
|
14
|
+
rdb.pool = pool;
|
|
15
|
+
}
|
|
16
|
+
rdb.engine = 'sqlite';
|
|
17
|
+
rdb.encodeBoolean = encodeBoolean;
|
|
18
|
+
rdb.decodeJSON = decodeJSON;
|
|
19
|
+
rdb.encodeJSON = JSON.stringify;
|
|
20
|
+
rdb.deleteFromSql = deleteFromSql;
|
|
21
|
+
rdb.selectForUpdateSql = selectForUpdateSql;
|
|
22
|
+
rdb.lastInsertedSql = lastInsertedSql;
|
|
23
|
+
rdb.insertSql = insertSql;
|
|
24
|
+
rdb.insert = insert;
|
|
25
|
+
rdb.lastInsertedIsSeparate = true;
|
|
26
|
+
rdb.multipleStatements = false;
|
|
27
|
+
rdb.limitAndOffset = limitAndOffset;
|
|
28
|
+
rdb.accept = function(caller) {
|
|
29
|
+
caller.visitSqlite();
|
|
30
|
+
};
|
|
31
|
+
rdb.aggregateCount = 0;
|
|
32
|
+
rdb.quote = (name) => `"${name}"`;
|
|
33
|
+
|
|
34
|
+
if (readonly) {
|
|
35
|
+
rdb.dbClient = {
|
|
36
|
+
executeQuery: function(query, callback) {
|
|
37
|
+
pool.connect((err, client, done) => {
|
|
38
|
+
if (err) {
|
|
39
|
+
return callback(err);
|
|
40
|
+
}
|
|
41
|
+
try {
|
|
42
|
+
wrapQuery(client)(query, (err, res) => {
|
|
43
|
+
done();
|
|
44
|
+
callback(err, res);
|
|
45
|
+
});
|
|
46
|
+
} catch (e) {
|
|
47
|
+
done();
|
|
48
|
+
callback(e);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
domain.rdb = rdb;
|
|
54
|
+
return (onSuccess) => onSuccess();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return function(onSuccess, onError) {
|
|
58
|
+
pool.connect(onConnected);
|
|
59
|
+
|
|
60
|
+
function onConnected(err, client, done) {
|
|
61
|
+
try {
|
|
62
|
+
if (err) {
|
|
63
|
+
onError(err);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
client.executeQuery = wrapQuery(client);
|
|
67
|
+
rdb.dbClient = client;
|
|
68
|
+
rdb.dbClientDone = done;
|
|
69
|
+
domain.rdb = rdb;
|
|
70
|
+
onSuccess();
|
|
71
|
+
} catch (e) {
|
|
72
|
+
onError(e);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function decodeJSON(value) {
|
|
79
|
+
return JSON.parse(value);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
module.exports = newResolveTransaction;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/* eslint-disable no-prototype-builtins */
|
|
2
|
+
var EventEmitter = require('events').EventEmitter;
|
|
3
|
+
|
|
4
|
+
var defaults = require('../../poolDefaults');
|
|
5
|
+
var genericPool = require('../../generic-pool');
|
|
6
|
+
var process = require('node:process');
|
|
7
|
+
|
|
8
|
+
function newGenericPool(d1Database, poolOptions) {
|
|
9
|
+
poolOptions = poolOptions || {};
|
|
10
|
+
// @ts-ignore
|
|
11
|
+
var pool = genericPool.Pool({
|
|
12
|
+
max: 1,
|
|
13
|
+
idleTimeoutMillis: poolOptions.idleTimeout || defaults.poolIdleTimeout,
|
|
14
|
+
reapIntervalMillis: poolOptions.reapIntervalMillis || defaults.reapIntervalMillis,
|
|
15
|
+
log: poolOptions.log || defaults.poolLog,
|
|
16
|
+
create: function(cb) {
|
|
17
|
+
var client = {d1: d1Database, poolCount: 0};
|
|
18
|
+
|
|
19
|
+
return cb(null, client);
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
destroy: function() {
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
//mixin EventEmitter to pool
|
|
26
|
+
EventEmitter.call(pool);
|
|
27
|
+
for(var key in EventEmitter.prototype) {
|
|
28
|
+
if(EventEmitter.prototype.hasOwnProperty(key)) {
|
|
29
|
+
pool[key] = EventEmitter.prototype[key];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//monkey-patch with connect method
|
|
33
|
+
pool.connect = function(cb) {
|
|
34
|
+
var domain = process.domain;
|
|
35
|
+
pool.acquire(function(err, client) {
|
|
36
|
+
if(domain) {
|
|
37
|
+
cb = domain.bind(cb);
|
|
38
|
+
}
|
|
39
|
+
if(err) return cb(err, null, function() {/*NOOP*/});
|
|
40
|
+
client.poolCount++;
|
|
41
|
+
cb(null, client, function(err) {
|
|
42
|
+
if(err) {
|
|
43
|
+
pool.destroy(client);
|
|
44
|
+
} else {
|
|
45
|
+
pool.release(client);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
return pool;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
module.exports = newGenericPool;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
var log = require('../table/log');
|
|
2
|
+
|
|
3
|
+
function wrapQuery(client) {
|
|
4
|
+
|
|
5
|
+
return runQuery;
|
|
6
|
+
|
|
7
|
+
function runQuery(query, onCompleted) {
|
|
8
|
+
|
|
9
|
+
var params = query.parameters;
|
|
10
|
+
var sql = query.sql();
|
|
11
|
+
log.emitQuery({sql, parameters: params});
|
|
12
|
+
client.d1.prepare(sql, params).bind(...params).all().then(onInnerCompleted, onCompleted);
|
|
13
|
+
|
|
14
|
+
function onInnerCompleted(response) {
|
|
15
|
+
onCompleted(null, response.results);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
module.exports = wrapQuery;
|
package/src/d1test.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { connect } from '@cloudflare/d1';
|
|
2
|
+
|
|
3
|
+
const databaseId = process.env.D1_DATABASE_ID;
|
|
4
|
+
const accountId = process.env.D1_ACCOUNT_ID;
|
|
5
|
+
const apiToken = process.env.D1_API_TOKEN;
|
|
6
|
+
|
|
7
|
+
export class Database {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.db = connect({
|
|
10
|
+
databaseId,
|
|
11
|
+
accountId,
|
|
12
|
+
apiToken,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async createUser(name, email) {
|
|
17
|
+
return await this.db
|
|
18
|
+
.prepare('INSERT INTO users (name, email) VALUES (?, ?)')
|
|
19
|
+
.bind(name, email)
|
|
20
|
+
.run();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async getUsers() {
|
|
24
|
+
return await this.db
|
|
25
|
+
.prepare('SELECT * FROM users')
|
|
26
|
+
.all();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async getUserById(id) {
|
|
30
|
+
return await this.db
|
|
31
|
+
.prepare('SELECT * FROM users WHERE id = ?')
|
|
32
|
+
.bind(id)
|
|
33
|
+
.first();
|
|
34
|
+
}
|
|
35
|
+
}
|
package/src/emitEvent.js
CHANGED
|
@@ -6,12 +6,14 @@ function emitEvent() {
|
|
|
6
6
|
var result = [];
|
|
7
7
|
for (var i = 0; i < copy.length; i++) {
|
|
8
8
|
var callback = copy[i];
|
|
9
|
-
result.push(callback.apply(null,arguments));
|
|
9
|
+
result.push(callback.apply(null, arguments));
|
|
10
10
|
}
|
|
11
11
|
return result;
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
emit.add = function(callback) {
|
|
15
|
+
if (!callback)
|
|
16
|
+
throw new Error('missing callback');
|
|
15
17
|
callbacks.push(callback);
|
|
16
18
|
};
|
|
17
19
|
|
|
@@ -22,15 +24,15 @@ function emitEvent() {
|
|
|
22
24
|
|
|
23
25
|
emit.remove = function(callback) {
|
|
24
26
|
for (var i = 0; i < callbacks.length; i++) {
|
|
25
|
-
if(callbacks[i] === callback){
|
|
26
|
-
callbacks.splice(i,1);
|
|
27
|
+
if (callbacks[i] === callback) {
|
|
28
|
+
callbacks.splice(i, 1);
|
|
27
29
|
return;
|
|
28
30
|
}
|
|
29
31
|
}
|
|
30
32
|
};
|
|
31
33
|
|
|
32
34
|
emit.tryRemove = function(callback) {
|
|
33
|
-
if(callback)
|
|
35
|
+
if (callback)
|
|
34
36
|
emit.remove(callback);
|
|
35
37
|
};
|
|
36
38
|
|
package/src/emptyFilter.js
CHANGED
|
@@ -7,26 +7,26 @@ function emptyFilter() {
|
|
|
7
7
|
emptyFilter.sql = parameterized.sql;
|
|
8
8
|
emptyFilter.parameters = parameterized.parameters;
|
|
9
9
|
|
|
10
|
-
emptyFilter.and = function(other) {
|
|
11
|
-
other = negotiateRawSqlFilter(other);
|
|
12
|
-
for (var i =
|
|
13
|
-
other = other.and(arguments[i]);
|
|
10
|
+
emptyFilter.and = function(context, other) {
|
|
11
|
+
other = negotiateRawSqlFilter(context, other);
|
|
12
|
+
for (var i = 2; i < arguments.length; i++) {
|
|
13
|
+
other = other.and(context, arguments[i]);
|
|
14
14
|
}
|
|
15
15
|
return other;
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
emptyFilter.or = function(other) {
|
|
19
|
-
other = negotiateRawSqlFilter(other);
|
|
20
|
-
for (var i =
|
|
21
|
-
other = other.or(arguments[i]);
|
|
18
|
+
emptyFilter.or = function(context, other) {
|
|
19
|
+
other = negotiateRawSqlFilter(context, other);
|
|
20
|
+
for (var i = 2; i < arguments.length; i++) {
|
|
21
|
+
other = other.or(context, arguments[i]);
|
|
22
22
|
}
|
|
23
23
|
return other;
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
emptyFilter.not = function(other) {
|
|
27
|
-
other = negotiateRawSqlFilter(other).not();
|
|
28
|
-
for (var i =
|
|
29
|
-
other = other.and(arguments[i]);
|
|
26
|
+
emptyFilter.not = function(context, other) {
|
|
27
|
+
other = negotiateRawSqlFilter(context, other).not(context);
|
|
28
|
+
for (var i = 2; i < arguments.length; i++) {
|
|
29
|
+
other = other.and(context, arguments[i]);
|
|
30
30
|
}
|
|
31
31
|
return other;
|
|
32
32
|
|