orange-orm 4.5.1-beta.3 → 4.5.2
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 +11 -11
- package/docs/changelog.md +6 -0
- package/package.json +4 -15
- package/{dist/index.browser.mjs → src/client/index.mjs} +259 -145
- package/src/client/merge.js +9 -0
- package/src/{rollup.config.browser.js → client/rollup.config.js} +1 -1
- package/src/d1/newTransaction.js +1 -0
- package/src/index.js +3 -16
- package/src/map.d.ts +2 -12
- package/src/mssql/newTransaction.js +1 -0
- package/src/mssql/pool/newGenericPool.js +2 -9
- package/src/mySql/newTransaction.js +1 -0
- package/src/mySql/pool/newGenericPool.js +2 -11
- package/src/oracle/newTransaction.js +1 -0
- package/src/oracle/pool/newGenericPool.js +5 -13
- package/src/patchTable.js +4 -1
- package/src/pg/newDatabase.js +5 -0
- package/src/pg/newTransaction.js +1 -0
- package/src/pg/pool/newPgPool.js +3 -15
- package/src/sap/newTransaction.js +1 -0
- package/src/sqlite/newTransaction.js +1 -0
- package/src/{sqlite3 → sqlite}/pool/newGenericPool.js +2 -10
- package/src/table/clearCache.js +7 -0
- package/src/table/column/binary/newDecode.js +2 -13
- package/src/table/column/binary/newEncode.js +6 -16
- package/src/table/column/columnAggregate.js +15 -0
- package/src/table/column/columnAggregateGroup.js +35 -0
- package/src/table/column/newColumn.js +13 -0
- package/src/table/getSessionCache.js +8 -0
- package/src/table/newRowCache.js +4 -4
- package/src/table/relatedTable/columnAggregate.js +1 -1
- package/src/table/relation/newManyCache.js +4 -4
- package/src/table/resultToRows/newDecodeDbRow.js +1 -1
- package/src/table/setSessionCache.js +8 -0
- package/src/table/setSessionSingleton.js +1 -1
- package/src/tedious/newTransaction.js +1 -0
- package/src/tedious/pool/newGenericPool.js +2 -8
- package/src/tedious/wrapQuery.js +17 -40
- package/dist/index.mjs +0 -20002
- package/src/bunPg/newDatabase.js +0 -137
- package/src/bunPg/newPool.js +0 -19
- package/src/bunPg/pool/end.js +0 -13
- package/src/bunPg/pool/newPgPool.js +0 -98
- package/src/bunPg/wrapQuery.js +0 -33
- package/src/bunSqlite/newPool.js +0 -19
- package/src/bunSqlite/newTransaction.js +0 -87
- package/src/bunSqlite/pool/newGenericPool.js +0 -55
- package/src/bunSqlite/wrapQuery.js +0 -23
- package/src/merge-browser.js +0 -9
- package/src/merge-server.js +0 -9
- package/src/nodeSqlite/decodeBinary.js +0 -9
- package/src/nodeSqlite/encodeBinary.js +0 -17
- package/src/nodeSqlite/newDatabase.js +0 -116
- package/src/nodeSqlite/newPool.js +0 -19
- package/src/nodeSqlite/newTransaction.js +0 -87
- package/src/nodeSqlite/pool/newGenericPool.js +0 -50
- package/src/nodeSqlite/wrapQuery.js +0 -23
- package/src/rollup.config.server.js +0 -32
- package/src/runtimes.js +0 -24
- package/src/sqlite3/deleteFromSql.js +0 -10
- package/src/sqlite3/encodeBoolean.js +0 -7
- package/src/sqlite3/encodeBuffer.js +0 -7
- package/src/sqlite3/insert.js +0 -21
- package/src/sqlite3/insertSql.js +0 -67
- package/src/sqlite3/lastInsertedSql.js +0 -12
- package/src/sqlite3/limitAndOffset.js +0 -18
- package/src/sqlite3/newDatabase.js +0 -116
- package/src/sqlite3/newTransaction.js +0 -83
- package/src/sqlite3/pool/end.js +0 -13
- package/src/sqlite3/quote.js +0 -1
- package/src/sqlite3/selectForUpdateSql.js +0 -5
- /package/src/{bunSqlite → sqlite}/newDatabase.js +0 -0
- /package/src/{sqlite3 → sqlite}/newPool.js +0 -0
- /package/src/{sqlite3 → sqlite}/wrapQuery.js +0 -0
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<img src="./docs/orange.svg" alt="Orange ORM Logo" width="250"/>
|
|
3
3
|
</div>
|
|
4
4
|
|
|
5
|
-
The ultimate Object Relational Mapper for Node.js and Typescript, offering seamless integration with a variety of popular databases.
|
|
5
|
+
The ultimate Object Relational Mapper for Node.js and Typescript, offering seamless integration with a variety of popular databases. Orange ORM supports both TypeScript and JavaScript, including both CommonJS and ECMAScript.
|
|
6
6
|
|
|
7
7
|
[](https://www.npmjs.org/package/orange-orm)
|
|
8
8
|
[](https://github.com/alfateam/orange-orm/actions)
|
|
@@ -22,16 +22,16 @@ The ultimate Object Relational Mapper for Node.js and Typescript, offering seaml
|
|
|
22
22
|
- **TypeScript and JavaScript Support**: Orange fully supports both TypeScript and JavaScript, allowing you to leverage the benefits of static typing and modern ECMAScript features.
|
|
23
23
|
- **Works in the Browser**: You can securely use Orange in the browser by utilizing the Express.js plugin, which serves to safeguard sensitive database credentials from exposure at the client level and protect against SQL injection. This method mirrors a traditional REST API, augmented with advanced TypeScript tooling for enhanced functionality.
|
|
24
24
|
|
|
25
|
-
## Supported Databases
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
25
|
+
## Supported Databases
|
|
26
|
+
|
|
27
|
+
✅ Postgres
|
|
28
|
+
✅ MS SQL
|
|
29
|
+
✅ MySQL
|
|
30
|
+
✅ Oracle
|
|
31
|
+
✅ SAP ASE
|
|
32
|
+
✅ SQLite
|
|
33
|
+
✅ Cloudflare D1
|
|
34
|
+
|
|
35
35
|
|
|
36
36
|
This is the _Modern Typescript Documentation_. Are you looking for the [_Classic Documentation_](https://github.com/alfateam/orange-orm/blob/master/docs/docs.md) ?
|
|
37
37
|
|
package/docs/changelog.md
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
## Changelog
|
|
2
|
+
__4.5.2__
|
|
3
|
+
Bugfix: Aggregate functions are not allowed on root tables . See [#120](https://github.com/alfateam/orange-orm/issues/121)
|
|
4
|
+
__4.5.1__
|
|
5
|
+
Bugfix: "Changed by Other User" Error Triggered by Precision Mismatch in Numeric Column. See [#120](https://github.com/alfateam/orange-orm/issues/120)
|
|
2
6
|
__4.5.0__
|
|
3
7
|
Support for Cloudflare D1.
|
|
4
8
|
__4.4.2__
|
|
@@ -26,6 +30,8 @@ __4.0.1__
|
|
|
26
30
|
Inhouse definitions of ajv to avoid trouble with nestjs.
|
|
27
31
|
__4.0.0__
|
|
28
32
|
Changed the behaviour of `update` to accept a `where` filter and only update passed in columns and relations. The previous behaviour of `update` has moved to `replace` method.
|
|
33
|
+
__3.10.4__
|
|
34
|
+
Bugfix: "Changed by Other User" Error Triggered by Precision Mismatch in Numeric Column. See [#120](https://github.com/alfateam/orange-orm/issues/120)
|
|
29
35
|
__3.10.3__
|
|
30
36
|
Fix duplicate method signatures for those still using code generation
|
|
31
37
|
__3.10.2__
|
package/package.json
CHANGED
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "orange-orm",
|
|
3
|
-
"version": "4.5.
|
|
3
|
+
"version": "4.5.2",
|
|
4
4
|
"main": "./src/index.js",
|
|
5
|
-
"
|
|
6
|
-
"browser": "./dist/index.browser.mjs",
|
|
7
|
-
"exports": {
|
|
8
|
-
".": {
|
|
9
|
-
"require": "./src/index.js",
|
|
10
|
-
"import": "./dist/index.mjs",
|
|
11
|
-
"browser": "./dist/index.browser.mjs"
|
|
12
|
-
}
|
|
13
|
-
},
|
|
5
|
+
"browser": "./src/client/index.mjs",
|
|
14
6
|
"bin": {
|
|
15
7
|
"orange-orm": "bin/rdb.js"
|
|
16
8
|
},
|
|
@@ -51,11 +43,8 @@
|
|
|
51
43
|
"coverage": "vitest run --coverage.enabled --coverage.reporter='text-summary' --threads=false",
|
|
52
44
|
"testw": "vitest --threads=false update",
|
|
53
45
|
"tscheck": "tsc ./src/index.d.ts --module commonjs --target es2022 --noEmit true --strict true --esModuleInterop true",
|
|
54
|
-
"concat
|
|
55
|
-
"
|
|
56
|
-
"build": "npm run build-server && npm run build-browser",
|
|
57
|
-
"build-server": "rollup -c ./src/rollup.config.server.js && npm run concat-server",
|
|
58
|
-
"build-browser": "rollup -c ./src/rollup.config.browser.js && npm run concat-browser",
|
|
46
|
+
"concat": "node ./src/client/merge.js",
|
|
47
|
+
"build": "rollup -c ./src/client/rollup.config.js && npm run concat",
|
|
59
48
|
"lint": "eslint ./",
|
|
60
49
|
"fix": "eslint ./ --fix",
|
|
61
50
|
"owasp": "owasp-dependency-check --project \"MY_PROJECT\" --scan \"package-lock.json\" --exclude \"dependency-check-bin\" --out \"owasp\" --format HTML",
|
|
@@ -1758,7 +1758,7 @@ var hasRequiredSetSessionSingleton;
|
|
|
1758
1758
|
function requireSetSessionSingleton () {
|
|
1759
1759
|
if (hasRequiredSetSessionSingleton) return setSessionSingleton_1;
|
|
1760
1760
|
hasRequiredSetSessionSingleton = 1;
|
|
1761
|
-
|
|
1761
|
+
const getSessionContext = requireGetSessionContext();
|
|
1762
1762
|
|
|
1763
1763
|
function setSessionSingleton(context, name, value) {
|
|
1764
1764
|
const rdb = getSessionContext(context);
|
|
@@ -3951,6 +3951,178 @@ function requireExtractAlias () {
|
|
|
3951
3951
|
return extractAlias;
|
|
3952
3952
|
}
|
|
3953
3953
|
|
|
3954
|
+
var columnAggregate_1$1;
|
|
3955
|
+
var hasRequiredColumnAggregate$1;
|
|
3956
|
+
|
|
3957
|
+
function requireColumnAggregate$1 () {
|
|
3958
|
+
if (hasRequiredColumnAggregate$1) return columnAggregate_1$1;
|
|
3959
|
+
hasRequiredColumnAggregate$1 = 1;
|
|
3960
|
+
const getSessionSingleton = requireGetSessionSingleton();
|
|
3961
|
+
|
|
3962
|
+
function columnAggregate(context, operator, column, table, coalesce = true) {
|
|
3963
|
+
const quote = getSessionSingleton(context, 'quote');
|
|
3964
|
+
|
|
3965
|
+
const tableAlias = quote(table._rootAlias || table._dbName);
|
|
3966
|
+
const columnName = quote(column._dbName);
|
|
3967
|
+
|
|
3968
|
+
return {
|
|
3969
|
+
expression: (alias) => coalesce ? `COALESCE(${operator}(${tableAlias}.${columnName}), 0) as ${quote(alias)}` : `${operator}(${tableAlias}.${columnName}) as ${quote(alias)}`,
|
|
3970
|
+
joins: ['']
|
|
3971
|
+
};
|
|
3972
|
+
}
|
|
3973
|
+
|
|
3974
|
+
columnAggregate_1$1 = columnAggregate;
|
|
3975
|
+
return columnAggregate_1$1;
|
|
3976
|
+
}
|
|
3977
|
+
|
|
3978
|
+
var newDiscriminatorSql_1$1;
|
|
3979
|
+
var hasRequiredNewDiscriminatorSql$1;
|
|
3980
|
+
|
|
3981
|
+
function requireNewDiscriminatorSql$1 () {
|
|
3982
|
+
if (hasRequiredNewDiscriminatorSql$1) return newDiscriminatorSql_1$1;
|
|
3983
|
+
hasRequiredNewDiscriminatorSql$1 = 1;
|
|
3984
|
+
const getSessionSingleton = requireGetSessionSingleton();
|
|
3985
|
+
|
|
3986
|
+
function newDiscriminatorSql(context, table, alias) {
|
|
3987
|
+
const quote = getSessionSingleton(context, 'quote');
|
|
3988
|
+
alias = quote(alias);
|
|
3989
|
+
var result = '';
|
|
3990
|
+
var formulaDiscriminators = table._formulaDiscriminators;
|
|
3991
|
+
var columnDiscriminators = table._columnDiscriminators;
|
|
3992
|
+
addFormula();
|
|
3993
|
+
addColumn();
|
|
3994
|
+
return result;
|
|
3995
|
+
|
|
3996
|
+
function addFormula() {
|
|
3997
|
+
for (var i = 0; i<formulaDiscriminators.length; i++) {
|
|
3998
|
+
var current = formulaDiscriminators[i].replace('@this',alias);
|
|
3999
|
+
and();
|
|
4000
|
+
result += '(' + current + ')';
|
|
4001
|
+
}
|
|
4002
|
+
}
|
|
4003
|
+
|
|
4004
|
+
function addColumn() {
|
|
4005
|
+
for (var i = 0; i< columnDiscriminators.length; i++) {
|
|
4006
|
+
var current = columnDiscriminators[i].split('=');
|
|
4007
|
+
and();
|
|
4008
|
+
result += alias + '.' + quote(current[0]) + '=' + current[1];
|
|
4009
|
+
}
|
|
4010
|
+
}
|
|
4011
|
+
|
|
4012
|
+
function and() {
|
|
4013
|
+
if(result)
|
|
4014
|
+
result += ' AND ';
|
|
4015
|
+
else
|
|
4016
|
+
result = ' ';
|
|
4017
|
+
}
|
|
4018
|
+
}
|
|
4019
|
+
|
|
4020
|
+
newDiscriminatorSql_1$1 = newDiscriminatorSql;
|
|
4021
|
+
return newDiscriminatorSql_1$1;
|
|
4022
|
+
}
|
|
4023
|
+
|
|
4024
|
+
var newDiscriminatorSql_1;
|
|
4025
|
+
var hasRequiredNewDiscriminatorSql;
|
|
4026
|
+
|
|
4027
|
+
function requireNewDiscriminatorSql () {
|
|
4028
|
+
if (hasRequiredNewDiscriminatorSql) return newDiscriminatorSql_1;
|
|
4029
|
+
hasRequiredNewDiscriminatorSql = 1;
|
|
4030
|
+
var newDiscriminatorSqlCore = requireNewDiscriminatorSql$1();
|
|
4031
|
+
|
|
4032
|
+
function newDiscriminatorSql(context, table, alias) {
|
|
4033
|
+
var result = newDiscriminatorSqlCore(context,table,alias);
|
|
4034
|
+
if (result)
|
|
4035
|
+
return ' AND' + result;
|
|
4036
|
+
return result;
|
|
4037
|
+
|
|
4038
|
+
}
|
|
4039
|
+
|
|
4040
|
+
newDiscriminatorSql_1 = newDiscriminatorSql;
|
|
4041
|
+
return newDiscriminatorSql_1;
|
|
4042
|
+
}
|
|
4043
|
+
|
|
4044
|
+
var newShallowJoinSqlCore;
|
|
4045
|
+
var hasRequiredNewShallowJoinSqlCore;
|
|
4046
|
+
|
|
4047
|
+
function requireNewShallowJoinSqlCore () {
|
|
4048
|
+
if (hasRequiredNewShallowJoinSqlCore) return newShallowJoinSqlCore;
|
|
4049
|
+
hasRequiredNewShallowJoinSqlCore = 1;
|
|
4050
|
+
const newDiscriminatorSql = requireNewDiscriminatorSql();
|
|
4051
|
+
const newParameterized = requireNewParameterized();
|
|
4052
|
+
const getSessionSingleton = requireGetSessionSingleton();
|
|
4053
|
+
|
|
4054
|
+
function _new(context, rightTable, leftColumns, rightColumns, leftAlias, rightAlias, filter) {
|
|
4055
|
+
const quote = getSessionSingleton(context, 'quote');
|
|
4056
|
+
leftAlias = quote(leftAlias);
|
|
4057
|
+
rightAlias = quote(rightAlias);
|
|
4058
|
+
var sql = '';
|
|
4059
|
+
var delimiter = '';
|
|
4060
|
+
for (var i = 0; i < leftColumns.length; i++) {
|
|
4061
|
+
addColumn(i);
|
|
4062
|
+
delimiter = ' AND ';
|
|
4063
|
+
}
|
|
4064
|
+
|
|
4065
|
+
function addColumn(index) {
|
|
4066
|
+
var leftColumn = leftColumns[index];
|
|
4067
|
+
var rightColumn = rightColumns[index];
|
|
4068
|
+
sql += delimiter + leftAlias + '.' + quote(leftColumn._dbName) + '=' + rightAlias + '.' + quote(rightColumn._dbName);
|
|
4069
|
+
}
|
|
4070
|
+
|
|
4071
|
+
sql += newDiscriminatorSql(context, rightTable, rightAlias);
|
|
4072
|
+
var result = newParameterized(sql);
|
|
4073
|
+
if (filter)
|
|
4074
|
+
result = result.append(delimiter).append(filter);
|
|
4075
|
+
return result;
|
|
4076
|
+
}
|
|
4077
|
+
|
|
4078
|
+
newShallowJoinSqlCore = _new;
|
|
4079
|
+
return newShallowJoinSqlCore;
|
|
4080
|
+
}
|
|
4081
|
+
|
|
4082
|
+
var columnAggregateGroup$1;
|
|
4083
|
+
var hasRequiredColumnAggregateGroup$1;
|
|
4084
|
+
|
|
4085
|
+
function requireColumnAggregateGroup$1 () {
|
|
4086
|
+
if (hasRequiredColumnAggregateGroup$1) return columnAggregateGroup$1;
|
|
4087
|
+
hasRequiredColumnAggregateGroup$1 = 1;
|
|
4088
|
+
var getSessionContext = requireGetSessionContext();
|
|
4089
|
+
var newJoinCore = requireNewShallowJoinSqlCore();
|
|
4090
|
+
const getSessionSingleton = requireGetSessionSingleton();
|
|
4091
|
+
|
|
4092
|
+
function columnAggregate(context, operator, column, table, coalesce = true) {
|
|
4093
|
+
const quote = getSessionSingleton(context, 'quote');
|
|
4094
|
+
const rdb = getSessionContext(context);
|
|
4095
|
+
const outerAlias = 'y' + rdb.aggregateCount++;
|
|
4096
|
+
const outerAliasQuoted = quote(outerAlias);
|
|
4097
|
+
const alias = quote('x');
|
|
4098
|
+
const foreignKeys = getForeignKeys(table);
|
|
4099
|
+
const select = ` LEFT JOIN (SELECT ${foreignKeys},${operator}(${alias}.${quote(column._dbName)}) as amount`;
|
|
4100
|
+
const onClause = createOnClause(context, table, outerAlias);
|
|
4101
|
+
const from = ` FROM ${quote(table._dbName)} ${alias} GROUP BY ${foreignKeys}) ${outerAliasQuoted} ON (${onClause})`;
|
|
4102
|
+
const join = select + from;
|
|
4103
|
+
|
|
4104
|
+
return {
|
|
4105
|
+
expression: (alias) => coalesce ? `COALESCE(${outerAliasQuoted}.amount, 0) as ${quote(alias)}` : `${outerAliasQuoted}.amount as ${alias}`,
|
|
4106
|
+
joins: [join]
|
|
4107
|
+
};
|
|
4108
|
+
|
|
4109
|
+
function getForeignKeys(table) {
|
|
4110
|
+
return table._primaryColumns.map(x => `${alias}.${quote(x._dbName)}`).join(',');
|
|
4111
|
+
}
|
|
4112
|
+
}
|
|
4113
|
+
|
|
4114
|
+
function createOnClause(context, table, rightAlias) {
|
|
4115
|
+
let leftAlias = table._rootAlias || table._dbName;
|
|
4116
|
+
const columns = table._primaryColumns;
|
|
4117
|
+
return newJoinCore(context, table, columns, columns, leftAlias, rightAlias).sql();
|
|
4118
|
+
}
|
|
4119
|
+
|
|
4120
|
+
|
|
4121
|
+
|
|
4122
|
+
columnAggregateGroup$1 = columnAggregate;
|
|
4123
|
+
return columnAggregateGroup$1;
|
|
4124
|
+
}
|
|
4125
|
+
|
|
3954
4126
|
var newColumn;
|
|
3955
4127
|
var hasRequiredNewColumn;
|
|
3956
4128
|
|
|
@@ -3966,6 +4138,8 @@ function requireNewColumn () {
|
|
|
3966
4138
|
const _in = require_in();
|
|
3967
4139
|
const _extractAlias = requireExtractAlias();
|
|
3968
4140
|
const quote = requireQuote$1();
|
|
4141
|
+
const aggregate = requireColumnAggregate$1();
|
|
4142
|
+
const aggregateGroup = requireColumnAggregateGroup$1();
|
|
3969
4143
|
|
|
3970
4144
|
newColumn = function(table, name) {
|
|
3971
4145
|
var c = {};
|
|
@@ -4035,6 +4209,17 @@ function requireNewColumn () {
|
|
|
4035
4209
|
c.IN = c.in;
|
|
4036
4210
|
c.self = self;
|
|
4037
4211
|
|
|
4212
|
+
c.groupSum = (context, ...rest) => aggregateGroup.apply(null, [context, 'sum', c, table, ...rest]);
|
|
4213
|
+
c.groupAvg = (context, ...rest) => aggregateGroup.apply(null, [context, 'avg', c, table, ...rest]);
|
|
4214
|
+
c.groupMin = (context, ...rest) => aggregateGroup.apply(null, [context, 'min', c, table, ...rest]);
|
|
4215
|
+
c.groupMax = (context, ...rest) => aggregateGroup.apply(null, [context, 'max', c, table, ...rest]);
|
|
4216
|
+
c.groupCount = (context, ...rest) => aggregateGroup.apply(null, [context, 'count', c, table, false, ...rest]);
|
|
4217
|
+
c.sum = (context, ...rest) => aggregate.apply(null, [context, 'sum', c, table, ...rest]);
|
|
4218
|
+
c.avg = (context, ...rest) => aggregate.apply(null, [context, 'avg', c, table, ...rest]);
|
|
4219
|
+
c.min = (context, ...rest) => aggregate.apply(null, [context, 'min', c, table, ...rest]);
|
|
4220
|
+
c.max = (context, ...rest) => aggregate.apply(null, [context, 'max', c, table, ...rest]);
|
|
4221
|
+
c.count = (context, ...rest) => aggregate.apply(null, [context, 'count', c, table, false, ...rest]);
|
|
4222
|
+
|
|
4038
4223
|
function self(context) {
|
|
4039
4224
|
const tableAlias = quote(context,table._rootAlias || table._dbName);
|
|
4040
4225
|
const columnName = quote(context, c._dbName);
|
|
@@ -5137,39 +5322,29 @@ function requireNewEncode () {
|
|
|
5137
5322
|
hasRequiredNewEncode = 1;
|
|
5138
5323
|
var purify = requirePurify();
|
|
5139
5324
|
var newParam = requireNewParameterized();
|
|
5140
|
-
var getSessionSingleton = requireGetSessionSingleton();
|
|
5141
5325
|
|
|
5142
5326
|
function _new(_column) {
|
|
5143
5327
|
|
|
5144
|
-
function encode(
|
|
5328
|
+
function encode(_context, value) {
|
|
5145
5329
|
value = purify(value);
|
|
5146
5330
|
if (value === null)
|
|
5147
5331
|
return newParam('null');
|
|
5148
|
-
|
|
5149
|
-
var encodeCore = getSessionSingleton(context, 'encodeBinary') || encodeDefault;
|
|
5150
|
-
const enc = encodeCore(value);
|
|
5151
|
-
return newParam('?', [enc]);
|
|
5332
|
+
return newParam('?', [Buffer.from(value, 'base64')]);
|
|
5152
5333
|
}
|
|
5153
|
-
encode.unsafe = function(
|
|
5334
|
+
encode.unsafe = function(_context, value) {
|
|
5154
5335
|
value = purify(value);
|
|
5155
5336
|
if (value === null)
|
|
5156
5337
|
return 'null';
|
|
5157
|
-
|
|
5158
|
-
return encodeCore(value);
|
|
5338
|
+
return Buffer.from(value, 'base64');
|
|
5159
5339
|
};
|
|
5160
5340
|
|
|
5161
|
-
encode.direct = function(
|
|
5162
|
-
|
|
5163
|
-
return encodeCore(value);
|
|
5341
|
+
encode.direct = function(_context, value) {
|
|
5342
|
+
return Buffer.from(value, 'base64');
|
|
5164
5343
|
};
|
|
5165
5344
|
|
|
5166
5345
|
return encode;
|
|
5167
5346
|
}
|
|
5168
5347
|
|
|
5169
|
-
function encodeDefault(base64) {
|
|
5170
|
-
return Buffer.from(base64, 'base64');
|
|
5171
|
-
}
|
|
5172
|
-
|
|
5173
5348
|
newEncode = _new;
|
|
5174
5349
|
return newEncode;
|
|
5175
5350
|
}
|
|
@@ -5181,30 +5356,19 @@ function requireNewDecode () {
|
|
|
5181
5356
|
if (hasRequiredNewDecode) return newDecode;
|
|
5182
5357
|
hasRequiredNewDecode = 1;
|
|
5183
5358
|
var newDecodeCore = requireNewDecodeCore();
|
|
5184
|
-
var getSessionSingleton = requireGetSessionSingleton();
|
|
5185
5359
|
|
|
5186
5360
|
function _new(column) {
|
|
5187
5361
|
var decodeCore = newDecodeCore(column);
|
|
5188
5362
|
|
|
5189
5363
|
return function(context, value) {
|
|
5190
|
-
|
|
5191
|
-
var toBase64 = getSessionSingleton(context, 'decodeBinary') || toBase64Default;
|
|
5192
|
-
|
|
5193
5364
|
value = decodeCore(context, value);
|
|
5194
5365
|
if (value === null)
|
|
5195
5366
|
return value;
|
|
5196
|
-
else
|
|
5197
|
-
|
|
5198
|
-
return ret;
|
|
5199
|
-
}
|
|
5367
|
+
else
|
|
5368
|
+
return value.toString('base64');
|
|
5200
5369
|
};
|
|
5201
5370
|
}
|
|
5202
5371
|
|
|
5203
|
-
function toBase64Default(buffer) {
|
|
5204
|
-
return buffer.toString('base64');
|
|
5205
|
-
|
|
5206
|
-
}
|
|
5207
|
-
|
|
5208
5372
|
newDecode = _new;
|
|
5209
5373
|
return newDecode;
|
|
5210
5374
|
}
|
|
@@ -5691,110 +5855,6 @@ function requireNewColumnSql () {
|
|
|
5691
5855
|
return newColumnSql;
|
|
5692
5856
|
}
|
|
5693
5857
|
|
|
5694
|
-
var newDiscriminatorSql_1$1;
|
|
5695
|
-
var hasRequiredNewDiscriminatorSql$1;
|
|
5696
|
-
|
|
5697
|
-
function requireNewDiscriminatorSql$1 () {
|
|
5698
|
-
if (hasRequiredNewDiscriminatorSql$1) return newDiscriminatorSql_1$1;
|
|
5699
|
-
hasRequiredNewDiscriminatorSql$1 = 1;
|
|
5700
|
-
const getSessionSingleton = requireGetSessionSingleton();
|
|
5701
|
-
|
|
5702
|
-
function newDiscriminatorSql(context, table, alias) {
|
|
5703
|
-
const quote = getSessionSingleton(context, 'quote');
|
|
5704
|
-
alias = quote(alias);
|
|
5705
|
-
var result = '';
|
|
5706
|
-
var formulaDiscriminators = table._formulaDiscriminators;
|
|
5707
|
-
var columnDiscriminators = table._columnDiscriminators;
|
|
5708
|
-
addFormula();
|
|
5709
|
-
addColumn();
|
|
5710
|
-
return result;
|
|
5711
|
-
|
|
5712
|
-
function addFormula() {
|
|
5713
|
-
for (var i = 0; i<formulaDiscriminators.length; i++) {
|
|
5714
|
-
var current = formulaDiscriminators[i].replace('@this',alias);
|
|
5715
|
-
and();
|
|
5716
|
-
result += '(' + current + ')';
|
|
5717
|
-
}
|
|
5718
|
-
}
|
|
5719
|
-
|
|
5720
|
-
function addColumn() {
|
|
5721
|
-
for (var i = 0; i< columnDiscriminators.length; i++) {
|
|
5722
|
-
var current = columnDiscriminators[i].split('=');
|
|
5723
|
-
and();
|
|
5724
|
-
result += alias + '.' + quote(current[0]) + '=' + current[1];
|
|
5725
|
-
}
|
|
5726
|
-
}
|
|
5727
|
-
|
|
5728
|
-
function and() {
|
|
5729
|
-
if(result)
|
|
5730
|
-
result += ' AND ';
|
|
5731
|
-
else
|
|
5732
|
-
result = ' ';
|
|
5733
|
-
}
|
|
5734
|
-
}
|
|
5735
|
-
|
|
5736
|
-
newDiscriminatorSql_1$1 = newDiscriminatorSql;
|
|
5737
|
-
return newDiscriminatorSql_1$1;
|
|
5738
|
-
}
|
|
5739
|
-
|
|
5740
|
-
var newDiscriminatorSql_1;
|
|
5741
|
-
var hasRequiredNewDiscriminatorSql;
|
|
5742
|
-
|
|
5743
|
-
function requireNewDiscriminatorSql () {
|
|
5744
|
-
if (hasRequiredNewDiscriminatorSql) return newDiscriminatorSql_1;
|
|
5745
|
-
hasRequiredNewDiscriminatorSql = 1;
|
|
5746
|
-
var newDiscriminatorSqlCore = requireNewDiscriminatorSql$1();
|
|
5747
|
-
|
|
5748
|
-
function newDiscriminatorSql(context, table, alias) {
|
|
5749
|
-
var result = newDiscriminatorSqlCore(context,table,alias);
|
|
5750
|
-
if (result)
|
|
5751
|
-
return ' AND' + result;
|
|
5752
|
-
return result;
|
|
5753
|
-
|
|
5754
|
-
}
|
|
5755
|
-
|
|
5756
|
-
newDiscriminatorSql_1 = newDiscriminatorSql;
|
|
5757
|
-
return newDiscriminatorSql_1;
|
|
5758
|
-
}
|
|
5759
|
-
|
|
5760
|
-
var newShallowJoinSqlCore;
|
|
5761
|
-
var hasRequiredNewShallowJoinSqlCore;
|
|
5762
|
-
|
|
5763
|
-
function requireNewShallowJoinSqlCore () {
|
|
5764
|
-
if (hasRequiredNewShallowJoinSqlCore) return newShallowJoinSqlCore;
|
|
5765
|
-
hasRequiredNewShallowJoinSqlCore = 1;
|
|
5766
|
-
const newDiscriminatorSql = requireNewDiscriminatorSql();
|
|
5767
|
-
const newParameterized = requireNewParameterized();
|
|
5768
|
-
const getSessionSingleton = requireGetSessionSingleton();
|
|
5769
|
-
|
|
5770
|
-
function _new(context, rightTable, leftColumns, rightColumns, leftAlias, rightAlias, filter) {
|
|
5771
|
-
const quote = getSessionSingleton(context, 'quote');
|
|
5772
|
-
leftAlias = quote(leftAlias);
|
|
5773
|
-
rightAlias = quote(rightAlias);
|
|
5774
|
-
var sql = '';
|
|
5775
|
-
var delimiter = '';
|
|
5776
|
-
for (var i = 0; i < leftColumns.length; i++) {
|
|
5777
|
-
addColumn(i);
|
|
5778
|
-
delimiter = ' AND ';
|
|
5779
|
-
}
|
|
5780
|
-
|
|
5781
|
-
function addColumn(index) {
|
|
5782
|
-
var leftColumn = leftColumns[index];
|
|
5783
|
-
var rightColumn = rightColumns[index];
|
|
5784
|
-
sql += delimiter + leftAlias + '.' + quote(leftColumn._dbName) + '=' + rightAlias + '.' + quote(rightColumn._dbName);
|
|
5785
|
-
}
|
|
5786
|
-
|
|
5787
|
-
sql += newDiscriminatorSql(context, rightTable, rightAlias);
|
|
5788
|
-
var result = newParameterized(sql);
|
|
5789
|
-
if (filter)
|
|
5790
|
-
result = result.append(delimiter).append(filter);
|
|
5791
|
-
return result;
|
|
5792
|
-
}
|
|
5793
|
-
|
|
5794
|
-
newShallowJoinSqlCore = _new;
|
|
5795
|
-
return newShallowJoinSqlCore;
|
|
5796
|
-
}
|
|
5797
|
-
|
|
5798
5858
|
var newShallowJoinSql;
|
|
5799
5859
|
var hasRequiredNewShallowJoinSql;
|
|
5800
5860
|
|
|
@@ -7393,6 +7453,22 @@ function requireValidateDeleteAllowed () {
|
|
|
7393
7453
|
return validateDeleteAllowed_1;
|
|
7394
7454
|
}
|
|
7395
7455
|
|
|
7456
|
+
var clearCache_1;
|
|
7457
|
+
var hasRequiredClearCache;
|
|
7458
|
+
|
|
7459
|
+
function requireClearCache () {
|
|
7460
|
+
if (hasRequiredClearCache) return clearCache_1;
|
|
7461
|
+
hasRequiredClearCache = 1;
|
|
7462
|
+
var setSessionSingleton = requireSetSessionSingleton();
|
|
7463
|
+
|
|
7464
|
+
function clearCache(context) {
|
|
7465
|
+
setSessionSingleton(context, 'cache', {});
|
|
7466
|
+
}
|
|
7467
|
+
|
|
7468
|
+
clearCache_1 = clearCache;
|
|
7469
|
+
return clearCache_1;
|
|
7470
|
+
}
|
|
7471
|
+
|
|
7396
7472
|
/* eslint-disable require-atomic-updates */
|
|
7397
7473
|
|
|
7398
7474
|
var patchTable_1;
|
|
@@ -7405,13 +7481,16 @@ function requirePatchTable () {
|
|
|
7405
7481
|
let fromCompareObject = requireFromCompareObject();
|
|
7406
7482
|
let validateDeleteConflict = requireValidateDeleteConflict();
|
|
7407
7483
|
let validateDeleteAllowed = requireValidateDeleteAllowed();
|
|
7484
|
+
let clearCache = requireClearCache();
|
|
7408
7485
|
|
|
7409
7486
|
async function patchTable() {
|
|
7410
7487
|
// const dryrun = true;
|
|
7411
7488
|
//traverse all rows you want to update before updatinng or inserting anything.
|
|
7412
7489
|
//this is to avoid page locks in ms sql
|
|
7413
7490
|
// await patchTableCore.apply(null, [...arguments, dryrun]);
|
|
7414
|
-
|
|
7491
|
+
const result = await patchTableCore.apply(null, arguments);
|
|
7492
|
+
clearCache(arguments[0]);
|
|
7493
|
+
return result;
|
|
7415
7494
|
}
|
|
7416
7495
|
|
|
7417
7496
|
async function patchTableCore(context, table, patches, { strategy = undefined, deduceStrategy = false, ...options } = {}, dryrun) {
|
|
@@ -8014,7 +8093,7 @@ function requireNewDecodeDbRow () {
|
|
|
8014
8093
|
for (let i = 0; i < numberOfColumns; i++) {
|
|
8015
8094
|
let index = offset + i;
|
|
8016
8095
|
let key = keys[index];
|
|
8017
|
-
if (row[key] !== undefined
|
|
8096
|
+
if (row[key] !== undefined)
|
|
8018
8097
|
row[key] = columns[i].decode(context, row[key]);
|
|
8019
8098
|
if (shouldValidate && columns[i].validate)
|
|
8020
8099
|
columns[i].validate(row[key], row, isInsert);
|
|
@@ -9195,7 +9274,7 @@ function requireColumnAggregate () {
|
|
|
9195
9274
|
const columnName = quote(column._dbName);
|
|
9196
9275
|
|
|
9197
9276
|
return {
|
|
9198
|
-
expression: (alias) => coalesce ? `COALESCE(${operator}(${tableAlias}.${columnName}), 0) as ${quote(alias)}` : `${operator}(${tableAlias}.${columnName}) as ${alias}`,
|
|
9277
|
+
expression: (alias) => coalesce ? `COALESCE(${operator}(${tableAlias}.${columnName}), 0) as ${quote(alias)}` : `${operator}(${tableAlias}.${columnName}) as ${quote(alias)}`,
|
|
9199
9278
|
|
|
9200
9279
|
joins: newJoinArray(context, relations)
|
|
9201
9280
|
};
|
|
@@ -10074,6 +10153,40 @@ function requireNewId () {
|
|
|
10074
10153
|
return newId;
|
|
10075
10154
|
}
|
|
10076
10155
|
|
|
10156
|
+
var getSessionCache_1;
|
|
10157
|
+
var hasRequiredGetSessionCache;
|
|
10158
|
+
|
|
10159
|
+
function requireGetSessionCache () {
|
|
10160
|
+
if (hasRequiredGetSessionCache) return getSessionCache_1;
|
|
10161
|
+
hasRequiredGetSessionCache = 1;
|
|
10162
|
+
const getSessionSingleton = requireGetSessionSingleton();
|
|
10163
|
+
|
|
10164
|
+
function getSessionCache(context, id) {
|
|
10165
|
+
const cache = getSessionSingleton(context, 'cache');
|
|
10166
|
+
return cache[id];
|
|
10167
|
+
}
|
|
10168
|
+
|
|
10169
|
+
getSessionCache_1 = getSessionCache;
|
|
10170
|
+
return getSessionCache_1;
|
|
10171
|
+
}
|
|
10172
|
+
|
|
10173
|
+
var setSessionCache_1;
|
|
10174
|
+
var hasRequiredSetSessionCache;
|
|
10175
|
+
|
|
10176
|
+
function requireSetSessionCache () {
|
|
10177
|
+
if (hasRequiredSetSessionCache) return setSessionCache_1;
|
|
10178
|
+
hasRequiredSetSessionCache = 1;
|
|
10179
|
+
const getSessionSingleton = requireGetSessionSingleton();
|
|
10180
|
+
|
|
10181
|
+
function setSessionCache(context, id, value) {
|
|
10182
|
+
const cache = getSessionSingleton(context, 'cache');
|
|
10183
|
+
cache[id] = value;
|
|
10184
|
+
}
|
|
10185
|
+
|
|
10186
|
+
setSessionCache_1 = setSessionCache;
|
|
10187
|
+
return setSessionCache_1;
|
|
10188
|
+
}
|
|
10189
|
+
|
|
10077
10190
|
var newManyCache_1;
|
|
10078
10191
|
var hasRequiredNewManyCache;
|
|
10079
10192
|
|
|
@@ -10086,8 +10199,8 @@ function requireNewManyCache () {
|
|
|
10086
10199
|
var extractParentKey = requireExtractParentKey();
|
|
10087
10200
|
var newCacheCore = requireNewManyCacheCore();
|
|
10088
10201
|
var newId = requireNewId();
|
|
10089
|
-
var
|
|
10090
|
-
var
|
|
10202
|
+
var getSessionCache = requireGetSessionCache();
|
|
10203
|
+
var setSessionCache = requireSetSessionCache();
|
|
10091
10204
|
|
|
10092
10205
|
function newManyCache(joinRelation) {
|
|
10093
10206
|
var c = {};
|
|
@@ -10108,10 +10221,10 @@ function requireNewManyCache () {
|
|
|
10108
10221
|
|
|
10109
10222
|
c.getInnerCache = function(context) {
|
|
10110
10223
|
const theKey = negotiateKey();
|
|
10111
|
-
var cache =
|
|
10224
|
+
var cache = getSessionCache(context, theKey);
|
|
10112
10225
|
if (!cache) {
|
|
10113
10226
|
cache = newCacheCore(joinRelation);
|
|
10114
|
-
|
|
10227
|
+
setSessionCache(context, theKey, cache);
|
|
10115
10228
|
fillCache(context);
|
|
10116
10229
|
synchronizeAdded(context, c.tryAdd.bind(null, context), joinRelation);
|
|
10117
10230
|
synchronizeRemoved(context, c.tryRemove.bind(null, context), joinRelation);
|
|
@@ -11061,8 +11174,8 @@ function requireNewRowCache () {
|
|
|
11061
11174
|
if (hasRequiredNewRowCache) return newRowCache_1;
|
|
11062
11175
|
hasRequiredNewRowCache = 1;
|
|
11063
11176
|
let newCache = requireNewCache();
|
|
11064
|
-
let
|
|
11065
|
-
let
|
|
11177
|
+
let getSessionCache = requireGetSessionCache();
|
|
11178
|
+
let setSessionCache = requireSetSessionCache();
|
|
11066
11179
|
|
|
11067
11180
|
function newRowCache(table) {
|
|
11068
11181
|
let id = Symbol();
|
|
@@ -11100,11 +11213,11 @@ function requireNewRowCache () {
|
|
|
11100
11213
|
|
|
11101
11214
|
|
|
11102
11215
|
function getCache(context, table, id) {
|
|
11103
|
-
let cache =
|
|
11216
|
+
let cache = getSessionCache(context, id);
|
|
11104
11217
|
if (cache)
|
|
11105
11218
|
return cache;
|
|
11106
11219
|
cache = _newRowCache(table);
|
|
11107
|
-
|
|
11220
|
+
setSessionCache(context, id, cache);
|
|
11108
11221
|
return cache;
|
|
11109
11222
|
}
|
|
11110
11223
|
|
|
@@ -12965,6 +13078,7 @@ function requireNewTransaction () {
|
|
|
12965
13078
|
};
|
|
12966
13079
|
rdb.aggregateCount = 0;
|
|
12967
13080
|
rdb.quote = (name) => `"${name}"`;
|
|
13081
|
+
rdb.cache = {};
|
|
12968
13082
|
|
|
12969
13083
|
if (readonly) {
|
|
12970
13084
|
rdb.dbClient = {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const fs = require('fs').promises;
|
|
2
|
+
|
|
3
|
+
async function merge() {
|
|
4
|
+
let data1 = await fs.readFile('./src/client/self.js', 'utf8');
|
|
5
|
+
let data2 = await fs.readFile('./src/client/index.mjs', 'utf8');
|
|
6
|
+
await fs.writeFile('./src/client/index.mjs', data1 + data2);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
merge();
|