orange-orm 5.2.4 → 5.3.0
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 +10 -0
- package/deno.lock +75 -0
- package/dist/index.browser.mjs +56 -16
- package/dist/index.mjs +378 -35
- package/docs/changelog.md +2 -0
- package/other.db +0 -0
- package/package.json +1 -1
- package/src/client/clientMap.js +2 -0
- package/src/client/createProviders.js +8 -0
- package/src/client/index.js +1 -0
- package/src/client/map.js +1 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +11 -1
- package/src/map.d.ts +3 -0
- package/src/map2.d.ts +3 -0
- package/src/mariaDb/newDatabase.js +101 -0
- package/src/mariaDb/newPool.js +13 -0
- package/src/mariaDb/newTransaction.js +126 -0
- package/src/mySql/newTransaction.js +27 -1
- package/src/table/column/dateWithTimeZone/newEncode.js +14 -10
- package/src/table/column/string/newLikeColumnArg.js +1 -1
- package/src/table/commands/delete/singleCommand/newSingleCommandCore.js +5 -1
- package/src/table/commands/newUpdateCommandCore.js +23 -3
- package/src/table/isJsonUpdateSupported.js +1 -1
package/README.md
CHANGED
|
@@ -27,6 +27,7 @@ The ultimate Object Relational Mapper for Node.js, Bun and Deno, offering seamle
|
|
|
27
27
|
| PGlite | ✅ | ✅ | ✅ | ✅ | ✅
|
|
28
28
|
| MS SQL | ✅ | | ✅ | |
|
|
29
29
|
| MySQL | ✅ | ✅ | ✅ ||
|
|
30
|
+
| MariaDB | ✅ | ✅ | ✅ ||
|
|
30
31
|
| Oracle | ✅ | ✅ | ✅ | |
|
|
31
32
|
| SAP ASE | ✅ | | | |
|
|
32
33
|
| SQLite | ✅ | ✅ | ✅ | |
|
|
@@ -350,6 +351,15 @@ import map from './map';
|
|
|
350
351
|
const db = map.mysql('mysql://test:test@mysql/test');
|
|
351
352
|
```
|
|
352
353
|
|
|
354
|
+
__MariaDB__
|
|
355
|
+
```bash
|
|
356
|
+
$ npm install mysql2
|
|
357
|
+
```
|
|
358
|
+
```javascript
|
|
359
|
+
import map from './map';
|
|
360
|
+
const db = map.mariadb('mariadb://test:test@mariadb/test');
|
|
361
|
+
```
|
|
362
|
+
|
|
353
363
|
|
|
354
364
|
__MS SQL__
|
|
355
365
|
```bash
|
package/deno.lock
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "5",
|
|
3
|
+
"specifiers": {
|
|
4
|
+
"jsr:@std/assert@*": "1.0.19",
|
|
5
|
+
"jsr:@std/assert@^1.0.17": "1.0.19",
|
|
6
|
+
"jsr:@std/internal@^1.0.12": "1.0.12",
|
|
7
|
+
"jsr:@std/path@*": "1.1.4",
|
|
8
|
+
"jsr:@std/testing@*": "1.0.17"
|
|
9
|
+
},
|
|
10
|
+
"jsr": {
|
|
11
|
+
"@std/assert@1.0.19": {
|
|
12
|
+
"integrity": "eaada96ee120cb980bc47e040f82814d786fe8162ecc53c91d8df60b8755991e",
|
|
13
|
+
"dependencies": [
|
|
14
|
+
"jsr:@std/internal"
|
|
15
|
+
]
|
|
16
|
+
},
|
|
17
|
+
"@std/internal@1.0.12": {
|
|
18
|
+
"integrity": "972a634fd5bc34b242024402972cd5143eac68d8dffaca5eaa4dba30ce17b027"
|
|
19
|
+
},
|
|
20
|
+
"@std/path@1.1.4": {
|
|
21
|
+
"integrity": "1d2d43f39efb1b42f0b1882a25486647cb851481862dc7313390b2bb044314b5",
|
|
22
|
+
"dependencies": [
|
|
23
|
+
"jsr:@std/internal"
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
"@std/testing@1.0.17": {
|
|
27
|
+
"integrity": "87bdc2700fa98249d48a17cd72413352d3d3680dcfbdb64947fd0982d6bbf681",
|
|
28
|
+
"dependencies": [
|
|
29
|
+
"jsr:@std/assert@^1.0.17",
|
|
30
|
+
"jsr:@std/internal"
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"workspace": {
|
|
35
|
+
"packageJson": {
|
|
36
|
+
"dependencies": [
|
|
37
|
+
"npm:@cloudflare/workers-types@^4.20241106.0",
|
|
38
|
+
"npm:@electric-sql/pglite@0.3",
|
|
39
|
+
"npm:@hono/node-server@^1.14.4",
|
|
40
|
+
"npm:@lroal/on-change@^4.0.2",
|
|
41
|
+
"npm:@rollup/plugin-commonjs@^28.0.2",
|
|
42
|
+
"npm:@rollup/plugin-json@^6.1.0",
|
|
43
|
+
"npm:@rollup/plugin-node-resolve@13",
|
|
44
|
+
"npm:@tediousjs/connection-string@~0.4.1",
|
|
45
|
+
"npm:@types/express@^4.17.13",
|
|
46
|
+
"npm:@types/oracledb@^6.0.4",
|
|
47
|
+
"npm:@types/tedious@^4.0.14",
|
|
48
|
+
"npm:@typescript-eslint/eslint-plugin@^8.56.1",
|
|
49
|
+
"npm:@typescript-eslint/parser@^8.56.1",
|
|
50
|
+
"npm:@vitest/coverage-v8@^3.2.4",
|
|
51
|
+
"npm:ajv@^8.17.1",
|
|
52
|
+
"npm:axios@^1.6.2",
|
|
53
|
+
"npm:better-sqlite3@^12.6.2",
|
|
54
|
+
"npm:cors@^2.8.5",
|
|
55
|
+
"npm:eslint-plugin-jest@^29.15.0",
|
|
56
|
+
"npm:eslint@^8.57.0",
|
|
57
|
+
"npm:express@^4.18.2",
|
|
58
|
+
"npm:fast-json-patch@^3.1.1",
|
|
59
|
+
"npm:hono@^4.8.2",
|
|
60
|
+
"npm:msnodesqlv8@^4.1.0",
|
|
61
|
+
"npm:mysql2@^3.9.4",
|
|
62
|
+
"npm:oracledb@^6.3.0",
|
|
63
|
+
"npm:owasp-dependency-check@^0.0.21",
|
|
64
|
+
"npm:pg-query-stream@^3.3.2",
|
|
65
|
+
"npm:pg@^8.5.1",
|
|
66
|
+
"npm:rfdc@^1.2.0",
|
|
67
|
+
"npm:rollup@^2.52.7",
|
|
68
|
+
"npm:tedious@19",
|
|
69
|
+
"npm:typescript@^5.4.5",
|
|
70
|
+
"npm:uuid@^8.3.2 || 9 || 10 || ^11.1.0",
|
|
71
|
+
"npm:vitest@^3.2.4"
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
package/dist/index.browser.mjs
CHANGED
|
@@ -3049,6 +3049,7 @@ function requireClientMap () {
|
|
|
3049
3049
|
dbMap.mssql = throwDb;
|
|
3050
3050
|
dbMap.mssqlNative = throwDb;
|
|
3051
3051
|
dbMap.mysql = throwDb;
|
|
3052
|
+
dbMap.mariadb = throwDb;
|
|
3052
3053
|
dbMap.sap = throwDb;
|
|
3053
3054
|
dbMap.oracle = throwDb;
|
|
3054
3055
|
dbMap.sqlite = throwDb;
|
|
@@ -3077,6 +3078,7 @@ function requireClientMap () {
|
|
|
3077
3078
|
onFinal.mssql = () => index({ db: throwDb, providers: dbMap });
|
|
3078
3079
|
onFinal.mssqlNative = () => index({ db: throwDb, providers: dbMap });
|
|
3079
3080
|
onFinal.mysql = () => index({ db: throwDb, providers: dbMap });
|
|
3081
|
+
onFinal.mariadb = () => index({ db: throwDb, providers: dbMap });
|
|
3080
3082
|
onFinal.sap = () => index({ db: throwDb, providers: dbMap });
|
|
3081
3083
|
onFinal.oracle = () => index({ db: throwDb, providers: dbMap });
|
|
3082
3084
|
onFinal.sqlite = () => index({ db: throwDb, providers: dbMap });
|
|
@@ -3234,6 +3236,7 @@ function requireClient () {
|
|
|
3234
3236
|
client.oracle = onProvider.bind(null, 'oracle');
|
|
3235
3237
|
client.http = onProvider.bind(null, 'http');//todo
|
|
3236
3238
|
client.mysql = onProvider.bind(null, 'mysql');
|
|
3239
|
+
client.mariadb = onProvider.bind(null, 'mariadb');
|
|
3237
3240
|
client.express = express;
|
|
3238
3241
|
client.hono = hono;
|
|
3239
3242
|
client.close = close;
|
|
@@ -4972,7 +4975,7 @@ function requireNewLikeColumnArg () {
|
|
|
4972
4975
|
var encodedSuffix = suffix ? column.encode(context, suffix) : null;
|
|
4973
4976
|
var engine = getSessionSingleton(context, 'engine');
|
|
4974
4977
|
|
|
4975
|
-
if (engine === 'mysql')
|
|
4978
|
+
if (engine === 'mysql' || engine === 'mariadb')
|
|
4976
4979
|
return concatWithFunction(encodedPrefix, encodedArg, encodedSuffix);
|
|
4977
4980
|
if (engine === 'mssql' || engine === 'mssqlNative')
|
|
4978
4981
|
return concatWithOperator('+', encodedPrefix, encodedArg, encodedSuffix);
|
|
@@ -5708,39 +5711,44 @@ function requireNewEncode$4 () {
|
|
|
5708
5711
|
hasRequiredNewEncode$4 = 1;
|
|
5709
5712
|
var newPara = requireNewParameterized();
|
|
5710
5713
|
var purify = requirePurify$3();
|
|
5714
|
+
var getSessionContext = requireGetSessionContext();
|
|
5715
|
+
var getSessionSingleton = requireGetSessionSingleton();
|
|
5711
5716
|
|
|
5712
5717
|
function _new(column) {
|
|
5713
|
-
var encode = function(
|
|
5718
|
+
var encode = function(context, value) {
|
|
5714
5719
|
value = purify(value);
|
|
5715
5720
|
if (value == null) {
|
|
5716
5721
|
if (column.dbNull === null)
|
|
5717
5722
|
return newPara('null');
|
|
5718
5723
|
return newPara('\'' + column.dbNull + '\'');
|
|
5719
5724
|
}
|
|
5720
|
-
|
|
5725
|
+
var ctx = getSessionContext(context);
|
|
5726
|
+
var encodeCore = ctx.encodeDateTz || ctx.encodeDate || encodeDate;
|
|
5727
|
+
return newPara('?', [encodeCore(value)]);
|
|
5721
5728
|
};
|
|
5722
5729
|
|
|
5723
|
-
encode.unsafe = function(
|
|
5730
|
+
encode.unsafe = function(context, value) {
|
|
5724
5731
|
value = purify(value);
|
|
5725
5732
|
if (value == null) {
|
|
5726
5733
|
if (column.dbNull === null)
|
|
5727
5734
|
return 'null';
|
|
5728
5735
|
return '\'' + column.dbNull + '\'';
|
|
5729
5736
|
}
|
|
5730
|
-
|
|
5737
|
+
var encodeCore = getSessionSingleton(context, 'encodeDateTz') || getSessionSingleton(context, 'encodeDateTz') || getSessionSingleton(context, 'encodeDate') || encodeDate;
|
|
5738
|
+
return encodeCore(value);
|
|
5731
5739
|
};
|
|
5732
5740
|
|
|
5733
|
-
encode.direct = function(
|
|
5734
|
-
|
|
5741
|
+
encode.direct = function(context, value) {
|
|
5742
|
+
var encodeCore = getSessionSingleton(context, 'encodeDateTz') || getSessionSingleton(context, 'encodeDateTz') || getSessionSingleton(context, 'encodeDate') || encodeDate;
|
|
5743
|
+
return encodeCore(value);
|
|
5735
5744
|
};
|
|
5736
5745
|
|
|
5737
5746
|
return encode;
|
|
5738
|
-
|
|
5739
|
-
|
|
5740
5747
|
}
|
|
5748
|
+
|
|
5741
5749
|
function encodeDate(date) {
|
|
5742
5750
|
if (date.toISOString)
|
|
5743
|
-
return truncate(date.toISOString(
|
|
5751
|
+
return truncate(date.toISOString());
|
|
5744
5752
|
return truncate(date);
|
|
5745
5753
|
}
|
|
5746
5754
|
|
|
@@ -5748,7 +5756,6 @@ function requireNewEncode$4 () {
|
|
|
5748
5756
|
return date;
|
|
5749
5757
|
}
|
|
5750
5758
|
|
|
5751
|
-
|
|
5752
5759
|
newEncode$4 = _new;
|
|
5753
5760
|
return newEncode$4;
|
|
5754
5761
|
}
|
|
@@ -7170,7 +7177,7 @@ function requireIsJsonUpdateSupported () {
|
|
|
7170
7177
|
if (hasRequiredIsJsonUpdateSupported) return isJsonUpdateSupported_1;
|
|
7171
7178
|
hasRequiredIsJsonUpdateSupported = 1;
|
|
7172
7179
|
function isJsonUpdateSupported(engine) {
|
|
7173
|
-
return engine === 'pg' || engine === 'mysql' || engine === 'sqlite' || engine === 'mssql' || engine === 'mssqlNative' || engine === 'oracle';
|
|
7180
|
+
return engine === 'pg' || engine === 'mysql' || engine === 'mariadb' || engine === 'sqlite' || engine === 'mssql' || engine === 'mssqlNative' || engine === 'oracle';
|
|
7174
7181
|
}
|
|
7175
7182
|
|
|
7176
7183
|
isJsonUpdateSupported_1 = isJsonUpdateSupported;
|
|
@@ -7269,7 +7276,7 @@ function requireNewUpdateCommandCore () {
|
|
|
7269
7276
|
if (engine === 'pg') {
|
|
7270
7277
|
command = command.append(separator + columnSql + ' IS NOT DISTINCT FROM ').append(encoded);
|
|
7271
7278
|
}
|
|
7272
|
-
else if (engine === 'mysql') {
|
|
7279
|
+
else if (engine === 'mysql' || engine === 'mariadb') {
|
|
7273
7280
|
command = command.append(separator + columnSql + ' <=> ').append(encoded);
|
|
7274
7281
|
}
|
|
7275
7282
|
else if (engine === 'sqlite') {
|
|
@@ -7308,7 +7315,7 @@ function requireNewUpdateCommandCore () {
|
|
|
7308
7315
|
if (engine === 'pg') {
|
|
7309
7316
|
command = command.append(separator).append(columnExpr).append(' IS NOT DISTINCT FROM ').append(encoded);
|
|
7310
7317
|
}
|
|
7311
|
-
else if (engine === 'mysql') {
|
|
7318
|
+
else if (engine === 'mysql' || engine === 'mariadb') {
|
|
7312
7319
|
command = command.append(separator).append(columnExpr).append(' <=> ').append(encoded);
|
|
7313
7320
|
}
|
|
7314
7321
|
else if (engine === 'sqlite') {
|
|
@@ -7369,6 +7376,11 @@ function requireNewUpdateCommandCore () {
|
|
|
7369
7376
|
const sql = 'JSON_SET(' + expr.sql() + ', ' + jsonPath.sql + ', CAST(? AS JSON))';
|
|
7370
7377
|
return newParameterized(sql, expr.parameters.concat(jsonPath.parameters, [jsonValue]));
|
|
7371
7378
|
}
|
|
7379
|
+
if (engine === 'mariadb') {
|
|
7380
|
+
const jsonValue = JSON.stringify(value === undefined ? null : value);
|
|
7381
|
+
const sql = 'JSON_SET(' + expr.sql() + ', ' + jsonPath.sql + ', JSON_EXTRACT(?, \'$\'))';
|
|
7382
|
+
return newParameterized(sql, expr.parameters.concat(jsonPath.parameters, [jsonValue]));
|
|
7383
|
+
}
|
|
7372
7384
|
if (engine === 'sqlite') {
|
|
7373
7385
|
const jsonValue = JSON.stringify(value === undefined ? null : value);
|
|
7374
7386
|
const sql = 'json_set(' + expr.sql() + ', ' + jsonPath.sql + ', json(?))';
|
|
@@ -7393,7 +7405,7 @@ function requireNewUpdateCommandCore () {
|
|
|
7393
7405
|
const sql = expr.sql() + ' #- ' + pathLiteral;
|
|
7394
7406
|
return newParameterized(sql, expr.parameters);
|
|
7395
7407
|
}
|
|
7396
|
-
if (engine === 'mysql') {
|
|
7408
|
+
if (engine === 'mysql' || engine === 'mariadb') {
|
|
7397
7409
|
const sql = 'JSON_REMOVE(' + expr.sql() + ', ' + jsonPath.sql + ')';
|
|
7398
7410
|
return newParameterized(sql, expr.parameters.concat(jsonPath.parameters));
|
|
7399
7411
|
}
|
|
@@ -7421,6 +7433,12 @@ function requireNewUpdateCommandCore () {
|
|
|
7421
7433
|
const sql = 'JSON_EXTRACT(' + columnSql + ', ' + jsonPath.sql + ')';
|
|
7422
7434
|
return newParameterized(sql, jsonPath.parameters);
|
|
7423
7435
|
}
|
|
7436
|
+
if (engine === 'mariadb') {
|
|
7437
|
+
const sql = isJsonObject(oldValue)
|
|
7438
|
+
? 'JSON_EXTRACT(' + columnSql + ', ' + jsonPath.sql + ')'
|
|
7439
|
+
: 'JSON_UNQUOTE(JSON_EXTRACT(' + columnSql + ', ' + jsonPath.sql + '))';
|
|
7440
|
+
return newParameterized(sql, jsonPath.parameters);
|
|
7441
|
+
}
|
|
7424
7442
|
if (engine === 'sqlite') {
|
|
7425
7443
|
const sql = 'json_extract(' + columnSql + ', ' + jsonPath.sql + ')';
|
|
7426
7444
|
return newParameterized(sql, jsonPath.parameters);
|
|
@@ -7496,6 +7514,15 @@ function requireNewUpdateCommandCore () {
|
|
|
7496
7514
|
const jsonValue = JSON.stringify(value === undefined ? null : value);
|
|
7497
7515
|
return newParameterized('CAST(? AS JSON)', [jsonValue]);
|
|
7498
7516
|
}
|
|
7517
|
+
if (engine === 'mariadb') {
|
|
7518
|
+
if (isJsonObject(value)) {
|
|
7519
|
+
const jsonValue = JSON.stringify(value);
|
|
7520
|
+
return newParameterized('JSON_EXTRACT(?, \'$\')', [jsonValue]);
|
|
7521
|
+
}
|
|
7522
|
+
if (value === null || value === undefined)
|
|
7523
|
+
return newParameterized('null');
|
|
7524
|
+
return newParameterized('?', [String(value)]);
|
|
7525
|
+
}
|
|
7499
7526
|
if (engine === 'sqlite') {
|
|
7500
7527
|
if (isJsonObject(value)) {
|
|
7501
7528
|
const jsonValue = JSON.stringify(value);
|
|
@@ -8195,7 +8222,7 @@ function requireNewSingleCommandCore () {
|
|
|
8195
8222
|
if (engine === 'pg') {
|
|
8196
8223
|
return newParameterized(columnSql + ' IS NOT DISTINCT FROM ' + encoded.sql(), encoded.parameters);
|
|
8197
8224
|
}
|
|
8198
|
-
if (engine === 'mysql') {
|
|
8225
|
+
if (engine === 'mysql' || engine === 'mariadb') {
|
|
8199
8226
|
return newParameterized(columnSql + ' <=> ' + encoded.sql(), encoded.parameters);
|
|
8200
8227
|
}
|
|
8201
8228
|
if (engine === 'sqlite') {
|
|
@@ -8236,6 +8263,10 @@ function requireNewSingleCommandCore () {
|
|
|
8236
8263
|
const jsonValue = JSON.stringify(value === undefined ? null : value);
|
|
8237
8264
|
return newParameterized('CAST(? AS JSON)', [jsonValue]);
|
|
8238
8265
|
}
|
|
8266
|
+
if (engine === 'mariadb') {
|
|
8267
|
+
const jsonValue = JSON.stringify(value === undefined ? null : value);
|
|
8268
|
+
return newParameterized('JSON_EXTRACT(?, \'$\')', [jsonValue]);
|
|
8269
|
+
}
|
|
8239
8270
|
if (engine === 'sqlite') {
|
|
8240
8271
|
if (isJsonObject(value)) {
|
|
8241
8272
|
const jsonValue = JSON.stringify(value);
|
|
@@ -13509,6 +13540,11 @@ function requireCreateProviders () {
|
|
|
13509
13540
|
return createPool.bind(null, 'mysql');
|
|
13510
13541
|
}
|
|
13511
13542
|
});
|
|
13543
|
+
Object.defineProperty(dbMap, 'mariadb', {
|
|
13544
|
+
get: function() {
|
|
13545
|
+
return createPool.bind(null, 'mariadb');
|
|
13546
|
+
}
|
|
13547
|
+
});
|
|
13512
13548
|
Object.defineProperty(dbMap, 'sap', {
|
|
13513
13549
|
get: function() {
|
|
13514
13550
|
return createPool.bind(null, 'sap');
|
|
@@ -13573,6 +13609,9 @@ function requireCreateProviders () {
|
|
|
13573
13609
|
get mysql() {
|
|
13574
13610
|
return createPool.bind(null, 'mysql');
|
|
13575
13611
|
},
|
|
13612
|
+
get mariadb() {
|
|
13613
|
+
return createPool.bind(null, 'mariadb');
|
|
13614
|
+
},
|
|
13576
13615
|
get sap() {
|
|
13577
13616
|
return createPool.bind(null, 'sap');
|
|
13578
13617
|
},
|
|
@@ -13668,6 +13707,7 @@ function requireMap () {
|
|
|
13668
13707
|
context.mssql = connect.bind(null, 'mssql');
|
|
13669
13708
|
context.mssqlNative = connect.bind(null, 'mssqlNative');
|
|
13670
13709
|
context.mysql = connect.bind(null, 'mysql');
|
|
13710
|
+
context.mariadb = connect.bind(null, 'mariadb');
|
|
13671
13711
|
context.sap = connect.bind(null, 'sap');
|
|
13672
13712
|
context.oracle = connect.bind(null, 'oracle');
|
|
13673
13713
|
context.sqlite = connect.bind(null, 'sqlite');
|