orange-orm 5.2.3 → 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 +4 -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 +7 -6
- package/src/index.js +11 -1
- package/src/map.d.ts +21 -18
- 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/dist/index.mjs
CHANGED
|
@@ -3050,6 +3050,7 @@ function requireClientMap () {
|
|
|
3050
3050
|
dbMap.mssql = throwDb;
|
|
3051
3051
|
dbMap.mssqlNative = throwDb;
|
|
3052
3052
|
dbMap.mysql = throwDb;
|
|
3053
|
+
dbMap.mariadb = throwDb;
|
|
3053
3054
|
dbMap.sap = throwDb;
|
|
3054
3055
|
dbMap.oracle = throwDb;
|
|
3055
3056
|
dbMap.sqlite = throwDb;
|
|
@@ -3078,6 +3079,7 @@ function requireClientMap () {
|
|
|
3078
3079
|
onFinal.mssql = () => index({ db: throwDb, providers: dbMap });
|
|
3079
3080
|
onFinal.mssqlNative = () => index({ db: throwDb, providers: dbMap });
|
|
3080
3081
|
onFinal.mysql = () => index({ db: throwDb, providers: dbMap });
|
|
3082
|
+
onFinal.mariadb = () => index({ db: throwDb, providers: dbMap });
|
|
3081
3083
|
onFinal.sap = () => index({ db: throwDb, providers: dbMap });
|
|
3082
3084
|
onFinal.oracle = () => index({ db: throwDb, providers: dbMap });
|
|
3083
3085
|
onFinal.sqlite = () => index({ db: throwDb, providers: dbMap });
|
|
@@ -3235,6 +3237,7 @@ function requireClient () {
|
|
|
3235
3237
|
client.oracle = onProvider.bind(null, 'oracle');
|
|
3236
3238
|
client.http = onProvider.bind(null, 'http');//todo
|
|
3237
3239
|
client.mysql = onProvider.bind(null, 'mysql');
|
|
3240
|
+
client.mariadb = onProvider.bind(null, 'mariadb');
|
|
3238
3241
|
client.express = express;
|
|
3239
3242
|
client.hono = hono;
|
|
3240
3243
|
client.close = close;
|
|
@@ -4973,7 +4976,7 @@ function requireNewLikeColumnArg () {
|
|
|
4973
4976
|
var encodedSuffix = suffix ? column.encode(context, suffix) : null;
|
|
4974
4977
|
var engine = getSessionSingleton(context, 'engine');
|
|
4975
4978
|
|
|
4976
|
-
if (engine === 'mysql')
|
|
4979
|
+
if (engine === 'mysql' || engine === 'mariadb')
|
|
4977
4980
|
return concatWithFunction(encodedPrefix, encodedArg, encodedSuffix);
|
|
4978
4981
|
if (engine === 'mssql' || engine === 'mssqlNative')
|
|
4979
4982
|
return concatWithOperator('+', encodedPrefix, encodedArg, encodedSuffix);
|
|
@@ -5709,39 +5712,44 @@ function requireNewEncode$4 () {
|
|
|
5709
5712
|
hasRequiredNewEncode$4 = 1;
|
|
5710
5713
|
var newPara = requireNewParameterized();
|
|
5711
5714
|
var purify = requirePurify$3();
|
|
5715
|
+
var getSessionContext = requireGetSessionContext();
|
|
5716
|
+
var getSessionSingleton = requireGetSessionSingleton();
|
|
5712
5717
|
|
|
5713
5718
|
function _new(column) {
|
|
5714
|
-
var encode = function(
|
|
5719
|
+
var encode = function(context, value) {
|
|
5715
5720
|
value = purify(value);
|
|
5716
5721
|
if (value == null) {
|
|
5717
5722
|
if (column.dbNull === null)
|
|
5718
5723
|
return newPara('null');
|
|
5719
5724
|
return newPara('\'' + column.dbNull + '\'');
|
|
5720
5725
|
}
|
|
5721
|
-
|
|
5726
|
+
var ctx = getSessionContext(context);
|
|
5727
|
+
var encodeCore = ctx.encodeDateTz || ctx.encodeDate || encodeDate;
|
|
5728
|
+
return newPara('?', [encodeCore(value)]);
|
|
5722
5729
|
};
|
|
5723
5730
|
|
|
5724
|
-
encode.unsafe = function(
|
|
5731
|
+
encode.unsafe = function(context, value) {
|
|
5725
5732
|
value = purify(value);
|
|
5726
5733
|
if (value == null) {
|
|
5727
5734
|
if (column.dbNull === null)
|
|
5728
5735
|
return 'null';
|
|
5729
5736
|
return '\'' + column.dbNull + '\'';
|
|
5730
5737
|
}
|
|
5731
|
-
|
|
5738
|
+
var encodeCore = getSessionSingleton(context, 'encodeDateTz') || getSessionSingleton(context, 'encodeDateTz') || getSessionSingleton(context, 'encodeDate') || encodeDate;
|
|
5739
|
+
return encodeCore(value);
|
|
5732
5740
|
};
|
|
5733
5741
|
|
|
5734
|
-
encode.direct = function(
|
|
5735
|
-
|
|
5742
|
+
encode.direct = function(context, value) {
|
|
5743
|
+
var encodeCore = getSessionSingleton(context, 'encodeDateTz') || getSessionSingleton(context, 'encodeDateTz') || getSessionSingleton(context, 'encodeDate') || encodeDate;
|
|
5744
|
+
return encodeCore(value);
|
|
5736
5745
|
};
|
|
5737
5746
|
|
|
5738
5747
|
return encode;
|
|
5739
|
-
|
|
5740
|
-
|
|
5741
5748
|
}
|
|
5749
|
+
|
|
5742
5750
|
function encodeDate(date) {
|
|
5743
5751
|
if (date.toISOString)
|
|
5744
|
-
return truncate(date.toISOString(
|
|
5752
|
+
return truncate(date.toISOString());
|
|
5745
5753
|
return truncate(date);
|
|
5746
5754
|
}
|
|
5747
5755
|
|
|
@@ -5749,7 +5757,6 @@ function requireNewEncode$4 () {
|
|
|
5749
5757
|
return date;
|
|
5750
5758
|
}
|
|
5751
5759
|
|
|
5752
|
-
|
|
5753
5760
|
newEncode$4 = _new;
|
|
5754
5761
|
return newEncode$4;
|
|
5755
5762
|
}
|
|
@@ -7171,7 +7178,7 @@ function requireIsJsonUpdateSupported () {
|
|
|
7171
7178
|
if (hasRequiredIsJsonUpdateSupported) return isJsonUpdateSupported_1;
|
|
7172
7179
|
hasRequiredIsJsonUpdateSupported = 1;
|
|
7173
7180
|
function isJsonUpdateSupported(engine) {
|
|
7174
|
-
return engine === 'pg' || engine === 'mysql' || engine === 'sqlite' || engine === 'mssql' || engine === 'mssqlNative' || engine === 'oracle';
|
|
7181
|
+
return engine === 'pg' || engine === 'mysql' || engine === 'mariadb' || engine === 'sqlite' || engine === 'mssql' || engine === 'mssqlNative' || engine === 'oracle';
|
|
7175
7182
|
}
|
|
7176
7183
|
|
|
7177
7184
|
isJsonUpdateSupported_1 = isJsonUpdateSupported;
|
|
@@ -7270,7 +7277,7 @@ function requireNewUpdateCommandCore () {
|
|
|
7270
7277
|
if (engine === 'pg') {
|
|
7271
7278
|
command = command.append(separator + columnSql + ' IS NOT DISTINCT FROM ').append(encoded);
|
|
7272
7279
|
}
|
|
7273
|
-
else if (engine === 'mysql') {
|
|
7280
|
+
else if (engine === 'mysql' || engine === 'mariadb') {
|
|
7274
7281
|
command = command.append(separator + columnSql + ' <=> ').append(encoded);
|
|
7275
7282
|
}
|
|
7276
7283
|
else if (engine === 'sqlite') {
|
|
@@ -7309,7 +7316,7 @@ function requireNewUpdateCommandCore () {
|
|
|
7309
7316
|
if (engine === 'pg') {
|
|
7310
7317
|
command = command.append(separator).append(columnExpr).append(' IS NOT DISTINCT FROM ').append(encoded);
|
|
7311
7318
|
}
|
|
7312
|
-
else if (engine === 'mysql') {
|
|
7319
|
+
else if (engine === 'mysql' || engine === 'mariadb') {
|
|
7313
7320
|
command = command.append(separator).append(columnExpr).append(' <=> ').append(encoded);
|
|
7314
7321
|
}
|
|
7315
7322
|
else if (engine === 'sqlite') {
|
|
@@ -7370,6 +7377,11 @@ function requireNewUpdateCommandCore () {
|
|
|
7370
7377
|
const sql = 'JSON_SET(' + expr.sql() + ', ' + jsonPath.sql + ', CAST(? AS JSON))';
|
|
7371
7378
|
return newParameterized(sql, expr.parameters.concat(jsonPath.parameters, [jsonValue]));
|
|
7372
7379
|
}
|
|
7380
|
+
if (engine === 'mariadb') {
|
|
7381
|
+
const jsonValue = JSON.stringify(value === undefined ? null : value);
|
|
7382
|
+
const sql = 'JSON_SET(' + expr.sql() + ', ' + jsonPath.sql + ', JSON_EXTRACT(?, \'$\'))';
|
|
7383
|
+
return newParameterized(sql, expr.parameters.concat(jsonPath.parameters, [jsonValue]));
|
|
7384
|
+
}
|
|
7373
7385
|
if (engine === 'sqlite') {
|
|
7374
7386
|
const jsonValue = JSON.stringify(value === undefined ? null : value);
|
|
7375
7387
|
const sql = 'json_set(' + expr.sql() + ', ' + jsonPath.sql + ', json(?))';
|
|
@@ -7394,7 +7406,7 @@ function requireNewUpdateCommandCore () {
|
|
|
7394
7406
|
const sql = expr.sql() + ' #- ' + pathLiteral;
|
|
7395
7407
|
return newParameterized(sql, expr.parameters);
|
|
7396
7408
|
}
|
|
7397
|
-
if (engine === 'mysql') {
|
|
7409
|
+
if (engine === 'mysql' || engine === 'mariadb') {
|
|
7398
7410
|
const sql = 'JSON_REMOVE(' + expr.sql() + ', ' + jsonPath.sql + ')';
|
|
7399
7411
|
return newParameterized(sql, expr.parameters.concat(jsonPath.parameters));
|
|
7400
7412
|
}
|
|
@@ -7422,6 +7434,12 @@ function requireNewUpdateCommandCore () {
|
|
|
7422
7434
|
const sql = 'JSON_EXTRACT(' + columnSql + ', ' + jsonPath.sql + ')';
|
|
7423
7435
|
return newParameterized(sql, jsonPath.parameters);
|
|
7424
7436
|
}
|
|
7437
|
+
if (engine === 'mariadb') {
|
|
7438
|
+
const sql = isJsonObject(oldValue)
|
|
7439
|
+
? 'JSON_EXTRACT(' + columnSql + ', ' + jsonPath.sql + ')'
|
|
7440
|
+
: 'JSON_UNQUOTE(JSON_EXTRACT(' + columnSql + ', ' + jsonPath.sql + '))';
|
|
7441
|
+
return newParameterized(sql, jsonPath.parameters);
|
|
7442
|
+
}
|
|
7425
7443
|
if (engine === 'sqlite') {
|
|
7426
7444
|
const sql = 'json_extract(' + columnSql + ', ' + jsonPath.sql + ')';
|
|
7427
7445
|
return newParameterized(sql, jsonPath.parameters);
|
|
@@ -7497,6 +7515,15 @@ function requireNewUpdateCommandCore () {
|
|
|
7497
7515
|
const jsonValue = JSON.stringify(value === undefined ? null : value);
|
|
7498
7516
|
return newParameterized('CAST(? AS JSON)', [jsonValue]);
|
|
7499
7517
|
}
|
|
7518
|
+
if (engine === 'mariadb') {
|
|
7519
|
+
if (isJsonObject(value)) {
|
|
7520
|
+
const jsonValue = JSON.stringify(value);
|
|
7521
|
+
return newParameterized('JSON_EXTRACT(?, \'$\')', [jsonValue]);
|
|
7522
|
+
}
|
|
7523
|
+
if (value === null || value === undefined)
|
|
7524
|
+
return newParameterized('null');
|
|
7525
|
+
return newParameterized('?', [String(value)]);
|
|
7526
|
+
}
|
|
7500
7527
|
if (engine === 'sqlite') {
|
|
7501
7528
|
if (isJsonObject(value)) {
|
|
7502
7529
|
const jsonValue = JSON.stringify(value);
|
|
@@ -8196,7 +8223,7 @@ function requireNewSingleCommandCore () {
|
|
|
8196
8223
|
if (engine === 'pg') {
|
|
8197
8224
|
return newParameterized(columnSql + ' IS NOT DISTINCT FROM ' + encoded.sql(), encoded.parameters);
|
|
8198
8225
|
}
|
|
8199
|
-
if (engine === 'mysql') {
|
|
8226
|
+
if (engine === 'mysql' || engine === 'mariadb') {
|
|
8200
8227
|
return newParameterized(columnSql + ' <=> ' + encoded.sql(), encoded.parameters);
|
|
8201
8228
|
}
|
|
8202
8229
|
if (engine === 'sqlite') {
|
|
@@ -8237,6 +8264,10 @@ function requireNewSingleCommandCore () {
|
|
|
8237
8264
|
const jsonValue = JSON.stringify(value === undefined ? null : value);
|
|
8238
8265
|
return newParameterized('CAST(? AS JSON)', [jsonValue]);
|
|
8239
8266
|
}
|
|
8267
|
+
if (engine === 'mariadb') {
|
|
8268
|
+
const jsonValue = JSON.stringify(value === undefined ? null : value);
|
|
8269
|
+
return newParameterized('JSON_EXTRACT(?, \'$\')', [jsonValue]);
|
|
8270
|
+
}
|
|
8240
8271
|
if (engine === 'sqlite') {
|
|
8241
8272
|
if (isJsonObject(value)) {
|
|
8242
8273
|
const jsonValue = JSON.stringify(value);
|
|
@@ -13510,6 +13541,11 @@ function requireCreateProviders () {
|
|
|
13510
13541
|
return createPool.bind(null, 'mysql');
|
|
13511
13542
|
}
|
|
13512
13543
|
});
|
|
13544
|
+
Object.defineProperty(dbMap, 'mariadb', {
|
|
13545
|
+
get: function() {
|
|
13546
|
+
return createPool.bind(null, 'mariadb');
|
|
13547
|
+
}
|
|
13548
|
+
});
|
|
13513
13549
|
Object.defineProperty(dbMap, 'sap', {
|
|
13514
13550
|
get: function() {
|
|
13515
13551
|
return createPool.bind(null, 'sap');
|
|
@@ -13574,6 +13610,9 @@ function requireCreateProviders () {
|
|
|
13574
13610
|
get mysql() {
|
|
13575
13611
|
return createPool.bind(null, 'mysql');
|
|
13576
13612
|
},
|
|
13613
|
+
get mariadb() {
|
|
13614
|
+
return createPool.bind(null, 'mariadb');
|
|
13615
|
+
},
|
|
13577
13616
|
get sap() {
|
|
13578
13617
|
return createPool.bind(null, 'sap');
|
|
13579
13618
|
},
|
|
@@ -13669,6 +13708,7 @@ function requireMap () {
|
|
|
13669
13708
|
context.mssql = connect.bind(null, 'mssql');
|
|
13670
13709
|
context.mssqlNative = connect.bind(null, 'mssqlNative');
|
|
13671
13710
|
context.mysql = connect.bind(null, 'mysql');
|
|
13711
|
+
context.mariadb = connect.bind(null, 'mariadb');
|
|
13672
13712
|
context.sap = connect.bind(null, 'sap');
|
|
13673
13713
|
context.oracle = connect.bind(null, 'oracle');
|
|
13674
13714
|
context.sqlite = connect.bind(null, 'sqlite');
|
|
@@ -14818,12 +14858,12 @@ function requireInsert$5 () {
|
|
|
14818
14858
|
return insert$4;
|
|
14819
14859
|
}
|
|
14820
14860
|
|
|
14821
|
-
var newTransaction$
|
|
14822
|
-
var hasRequiredNewTransaction$
|
|
14861
|
+
var newTransaction$c;
|
|
14862
|
+
var hasRequiredNewTransaction$c;
|
|
14823
14863
|
|
|
14824
|
-
function requireNewTransaction$
|
|
14825
|
-
if (hasRequiredNewTransaction$
|
|
14826
|
-
hasRequiredNewTransaction$
|
|
14864
|
+
function requireNewTransaction$c () {
|
|
14865
|
+
if (hasRequiredNewTransaction$c) return newTransaction$c;
|
|
14866
|
+
hasRequiredNewTransaction$c = 1;
|
|
14827
14867
|
const wrapQuery = requireWrapQuery$a();
|
|
14828
14868
|
const wrapCommand = requireWrapCommand$a();
|
|
14829
14869
|
const encodeBoolean = requireEncodeBoolean$5();
|
|
@@ -14844,6 +14884,9 @@ function requireNewTransaction$b () {
|
|
|
14844
14884
|
}
|
|
14845
14885
|
rdb.engine = 'mysql';
|
|
14846
14886
|
rdb.encodeBoolean = encodeBoolean;
|
|
14887
|
+
rdb.decodeJSON = decodeJSON;
|
|
14888
|
+
rdb.encodeDate = encodeDate;
|
|
14889
|
+
rdb.encodeDateTz = encodeDateTz;
|
|
14847
14890
|
rdb.encodeJSON = JSON.stringify;
|
|
14848
14891
|
rdb.deleteFromSql = deleteFromSql;
|
|
14849
14892
|
rdb.selectForUpdateSql = selectForUpdateSql;
|
|
@@ -14923,8 +14966,31 @@ function requireNewTransaction$b () {
|
|
|
14923
14966
|
};
|
|
14924
14967
|
}
|
|
14925
14968
|
|
|
14926
|
-
|
|
14927
|
-
|
|
14969
|
+
function decodeJSON(value) {
|
|
14970
|
+
return JSON.parse(value);
|
|
14971
|
+
}
|
|
14972
|
+
|
|
14973
|
+
function encodeDate(date) {
|
|
14974
|
+
date = date.toISOString ? removeTimezone(date.toISOString()) : removeTimezone(date);
|
|
14975
|
+
return date;
|
|
14976
|
+
}
|
|
14977
|
+
|
|
14978
|
+
function removeTimezone(isoString) {
|
|
14979
|
+
let dateTimePattern = /[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(.[0-9]{3})?/;
|
|
14980
|
+
let match = isoString.match(dateTimePattern);
|
|
14981
|
+
return match ? match[0] : isoString;
|
|
14982
|
+
}
|
|
14983
|
+
|
|
14984
|
+
function encodeDateTz(date) {
|
|
14985
|
+
if (date && date.toISOString)
|
|
14986
|
+
return removeTimezone(date.toISOString());
|
|
14987
|
+
if (typeof date === 'string' && /(Z|[+-][0-9]{2}:[0-9]{2})$/.test(date))
|
|
14988
|
+
return removeTimezone(new Date(date).toISOString());
|
|
14989
|
+
return date;
|
|
14990
|
+
}
|
|
14991
|
+
|
|
14992
|
+
newTransaction$c = newResolveTransaction;
|
|
14993
|
+
return newTransaction$c;
|
|
14928
14994
|
}
|
|
14929
14995
|
|
|
14930
14996
|
var beginCommand;
|
|
@@ -15734,12 +15800,12 @@ function requireNewGenericPool$7 () {
|
|
|
15734
15800
|
return newGenericPool_1$7;
|
|
15735
15801
|
}
|
|
15736
15802
|
|
|
15737
|
-
var newPool_1$
|
|
15738
|
-
var hasRequiredNewPool$
|
|
15803
|
+
var newPool_1$c;
|
|
15804
|
+
var hasRequiredNewPool$c;
|
|
15739
15805
|
|
|
15740
|
-
function requireNewPool$
|
|
15741
|
-
if (hasRequiredNewPool$
|
|
15742
|
-
hasRequiredNewPool$
|
|
15806
|
+
function requireNewPool$c () {
|
|
15807
|
+
if (hasRequiredNewPool$c) return newPool_1$c;
|
|
15808
|
+
hasRequiredNewPool$c = 1;
|
|
15743
15809
|
const promisify = requirePromisify();
|
|
15744
15810
|
const pools = requirePools();
|
|
15745
15811
|
const end = requireEnd$a();
|
|
@@ -15758,6 +15824,277 @@ function requireNewPool$b () {
|
|
|
15758
15824
|
return c;
|
|
15759
15825
|
}
|
|
15760
15826
|
|
|
15827
|
+
newPool_1$c = newPool;
|
|
15828
|
+
return newPool_1$c;
|
|
15829
|
+
}
|
|
15830
|
+
|
|
15831
|
+
var newDatabase_1$c;
|
|
15832
|
+
var hasRequiredNewDatabase$c;
|
|
15833
|
+
|
|
15834
|
+
function requireNewDatabase$c () {
|
|
15835
|
+
if (hasRequiredNewDatabase$c) return newDatabase_1$c;
|
|
15836
|
+
hasRequiredNewDatabase$c = 1;
|
|
15837
|
+
let createDomain = requireCreateDomain();
|
|
15838
|
+
let newTransaction = requireNewTransaction$c();
|
|
15839
|
+
let _begin = requireBegin();
|
|
15840
|
+
let commit = requireCommit();
|
|
15841
|
+
let rollback = requireRollback();
|
|
15842
|
+
let newPool = requireNewPool$c();
|
|
15843
|
+
let express = requireHostExpress();
|
|
15844
|
+
let hono = requireHostHono();
|
|
15845
|
+
let hostLocal = requireHostLocal();
|
|
15846
|
+
let doQuery = requireQuery();
|
|
15847
|
+
let releaseDbClient = requireReleaseDbClient();
|
|
15848
|
+
|
|
15849
|
+
function newDatabase(connectionString, poolOptions) {
|
|
15850
|
+
if (!connectionString)
|
|
15851
|
+
throw new Error('Connection string cannot be empty');
|
|
15852
|
+
poolOptions = poolOptions || { min: 1 };
|
|
15853
|
+
var pool = newPool(connectionString, poolOptions);
|
|
15854
|
+
|
|
15855
|
+
let c = { poolFactory: pool, hostLocal, express, hono };
|
|
15856
|
+
|
|
15857
|
+
c.transaction = function(options, fn) {
|
|
15858
|
+
if ((arguments.length === 1) && (typeof options === 'function')) {
|
|
15859
|
+
fn = options;
|
|
15860
|
+
options = undefined;
|
|
15861
|
+
}
|
|
15862
|
+
let domain = createDomain();
|
|
15863
|
+
|
|
15864
|
+
if (!fn)
|
|
15865
|
+
throw new Error('transaction requires a function');
|
|
15866
|
+
return domain.run(runInTransaction);
|
|
15867
|
+
|
|
15868
|
+
async function runInTransaction() {
|
|
15869
|
+
let result;
|
|
15870
|
+
let transaction = newTransaction(domain, pool, options);
|
|
15871
|
+
await new Promise(transaction)
|
|
15872
|
+
.then(begin)
|
|
15873
|
+
.then(() => fn(domain))
|
|
15874
|
+
.then((res) => result = res)
|
|
15875
|
+
.then(() => commit(domain))
|
|
15876
|
+
.then(null, (e) => rollback(domain, e));
|
|
15877
|
+
return result;
|
|
15878
|
+
}
|
|
15879
|
+
|
|
15880
|
+
function begin() {
|
|
15881
|
+
return _begin(domain, options);
|
|
15882
|
+
}
|
|
15883
|
+
|
|
15884
|
+
|
|
15885
|
+
};
|
|
15886
|
+
|
|
15887
|
+
c.createTransaction = function(options) {
|
|
15888
|
+
let domain = createDomain();
|
|
15889
|
+
let transaction = newTransaction(domain, pool);
|
|
15890
|
+
let p = domain.run(() => new Promise(transaction).then(begin));
|
|
15891
|
+
|
|
15892
|
+
function run(fn) {
|
|
15893
|
+
return p.then(() => fn(domain));
|
|
15894
|
+
}
|
|
15895
|
+
run.rollback = rollback.bind(null, domain);
|
|
15896
|
+
run.commit = commit.bind(null, domain);
|
|
15897
|
+
return run;
|
|
15898
|
+
|
|
15899
|
+
function begin() {
|
|
15900
|
+
return _begin(domain, options);
|
|
15901
|
+
}
|
|
15902
|
+
};
|
|
15903
|
+
|
|
15904
|
+
|
|
15905
|
+
c.query = function(query) {
|
|
15906
|
+
let domain = createDomain();
|
|
15907
|
+
let transaction = newTransaction(domain, pool);
|
|
15908
|
+
let p = domain.run(() => new Promise(transaction)
|
|
15909
|
+
.then(() => doQuery(domain, query).then(onResult, onError)));
|
|
15910
|
+
return p;
|
|
15911
|
+
|
|
15912
|
+
function onResult(result) {
|
|
15913
|
+
releaseDbClient(domain);
|
|
15914
|
+
return result;
|
|
15915
|
+
}
|
|
15916
|
+
|
|
15917
|
+
function onError(e) {
|
|
15918
|
+
releaseDbClient(domain);
|
|
15919
|
+
throw e;
|
|
15920
|
+
}
|
|
15921
|
+
};
|
|
15922
|
+
|
|
15923
|
+
|
|
15924
|
+
c.rollback = rollback;
|
|
15925
|
+
c.commit = commit;
|
|
15926
|
+
|
|
15927
|
+
c.end = function() {
|
|
15928
|
+
if (poolOptions)
|
|
15929
|
+
return pool.end();
|
|
15930
|
+
else
|
|
15931
|
+
return Promise.resolve();
|
|
15932
|
+
};
|
|
15933
|
+
|
|
15934
|
+
c.accept = function(caller) {
|
|
15935
|
+
caller.visitMySql();
|
|
15936
|
+
};
|
|
15937
|
+
|
|
15938
|
+
return c;
|
|
15939
|
+
}
|
|
15940
|
+
|
|
15941
|
+
newDatabase_1$c = newDatabase;
|
|
15942
|
+
return newDatabase_1$c;
|
|
15943
|
+
}
|
|
15944
|
+
|
|
15945
|
+
var newTransaction$b;
|
|
15946
|
+
var hasRequiredNewTransaction$b;
|
|
15947
|
+
|
|
15948
|
+
function requireNewTransaction$b () {
|
|
15949
|
+
if (hasRequiredNewTransaction$b) return newTransaction$b;
|
|
15950
|
+
hasRequiredNewTransaction$b = 1;
|
|
15951
|
+
const wrapQuery = requireWrapQuery$a();
|
|
15952
|
+
const wrapCommand = requireWrapCommand$a();
|
|
15953
|
+
const encodeBoolean = requireEncodeBoolean$5();
|
|
15954
|
+
const deleteFromSql = requireDeleteFromSql$5();
|
|
15955
|
+
const selectForUpdateSql = requireSelectForUpdateSql$5();
|
|
15956
|
+
const lastInsertedSql = requireLastInsertedSql$4();
|
|
15957
|
+
const limitAndOffset = requireLimitAndOffset$5();
|
|
15958
|
+
const formatBigintOut = requireFormatBigintOut$4();
|
|
15959
|
+
const insertSql = requireInsertSql$5();
|
|
15960
|
+
const insert = requireInsert$5();
|
|
15961
|
+
const quote = requireQuote$5();
|
|
15962
|
+
|
|
15963
|
+
function newResolveTransaction(domain, pool, { readonly = false } = {}) {
|
|
15964
|
+
var rdb = { poolFactory: pool };
|
|
15965
|
+
if (!pool.connect) {
|
|
15966
|
+
pool = pool();
|
|
15967
|
+
rdb.pool = pool;
|
|
15968
|
+
}
|
|
15969
|
+
rdb.engine = 'mariadb';
|
|
15970
|
+
rdb.encodeBoolean = encodeBoolean;
|
|
15971
|
+
rdb.decodeJSON = decodeJSON;
|
|
15972
|
+
rdb.encodeDate = encodeDate;
|
|
15973
|
+
rdb.encodeDateTz = encodeDateTz;
|
|
15974
|
+
rdb.encodeJSON = JSON.stringify;
|
|
15975
|
+
rdb.deleteFromSql = deleteFromSql;
|
|
15976
|
+
rdb.selectForUpdateSql = selectForUpdateSql;
|
|
15977
|
+
rdb.lastInsertedIsSeparate = true;
|
|
15978
|
+
rdb.lastInsertedSql = lastInsertedSql;
|
|
15979
|
+
rdb.formatBigintOut = formatBigintOut;
|
|
15980
|
+
rdb.insertSql = insertSql;
|
|
15981
|
+
rdb.insert = insert;
|
|
15982
|
+
rdb.multipleStatements = false;
|
|
15983
|
+
rdb.limitAndOffset = limitAndOffset;
|
|
15984
|
+
rdb.accept = function(caller) {
|
|
15985
|
+
caller.visitMySql();
|
|
15986
|
+
};
|
|
15987
|
+
rdb.aggregateCount = 0;
|
|
15988
|
+
rdb.quote = quote;
|
|
15989
|
+
rdb.cache = {};
|
|
15990
|
+
rdb.changes = [];
|
|
15991
|
+
|
|
15992
|
+
if (readonly) {
|
|
15993
|
+
rdb.dbClient = {
|
|
15994
|
+
executeQuery: function(query, callback) {
|
|
15995
|
+
pool.connect((err, client, done) => {
|
|
15996
|
+
if (err) {
|
|
15997
|
+
return callback(err);
|
|
15998
|
+
}
|
|
15999
|
+
try {
|
|
16000
|
+
wrapQuery(domain, client)(query, (err, res) => {
|
|
16001
|
+
done();
|
|
16002
|
+
callback(err, res);
|
|
16003
|
+
});
|
|
16004
|
+
} catch (e) {
|
|
16005
|
+
done();
|
|
16006
|
+
callback(e);
|
|
16007
|
+
}
|
|
16008
|
+
});
|
|
16009
|
+
},
|
|
16010
|
+
executeCommand: function(query, callback) {
|
|
16011
|
+
pool.connect((err, client, done) => {
|
|
16012
|
+
if (err) {
|
|
16013
|
+
return callback(err);
|
|
16014
|
+
}
|
|
16015
|
+
try {
|
|
16016
|
+
wrapCommand(domain, client)(query, (err, res) => {
|
|
16017
|
+
done();
|
|
16018
|
+
callback(err, res);
|
|
16019
|
+
});
|
|
16020
|
+
} catch (e) {
|
|
16021
|
+
done();
|
|
16022
|
+
callback(e);
|
|
16023
|
+
}
|
|
16024
|
+
});
|
|
16025
|
+
}
|
|
16026
|
+
};
|
|
16027
|
+
domain.rdb = rdb;
|
|
16028
|
+
return (onSuccess) => onSuccess();
|
|
16029
|
+
}
|
|
16030
|
+
|
|
16031
|
+
return function(onSuccess, onError) {
|
|
16032
|
+
pool.connect(onConnected);
|
|
16033
|
+
|
|
16034
|
+
function onConnected(err, client, done) {
|
|
16035
|
+
try {
|
|
16036
|
+
if (err) {
|
|
16037
|
+
onError(err);
|
|
16038
|
+
return;
|
|
16039
|
+
}
|
|
16040
|
+
client.executeQuery = wrapQuery(domain, client);
|
|
16041
|
+
client.executeCommand = wrapCommand(domain, client);
|
|
16042
|
+
rdb.dbClient = client;
|
|
16043
|
+
rdb.dbClientDone = done;
|
|
16044
|
+
domain.rdb = rdb;
|
|
16045
|
+
onSuccess();
|
|
16046
|
+
} catch (e) {
|
|
16047
|
+
onError(e);
|
|
16048
|
+
}
|
|
16049
|
+
}
|
|
16050
|
+
};
|
|
16051
|
+
}
|
|
16052
|
+
|
|
16053
|
+
function decodeJSON(value) {
|
|
16054
|
+
return JSON.parse(value);
|
|
16055
|
+
}
|
|
16056
|
+
|
|
16057
|
+
function encodeDate(date) {
|
|
16058
|
+
date = date.toISOString ? removeTimezone(date.toISOString()) : removeTimezone(date);
|
|
16059
|
+
return date;
|
|
16060
|
+
}
|
|
16061
|
+
|
|
16062
|
+
function removeTimezone(isoString) {
|
|
16063
|
+
let dateTimePattern = /[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(.[0-9]{3})?/;
|
|
16064
|
+
let match = isoString.match(dateTimePattern);
|
|
16065
|
+
return match ? match[0] : isoString;
|
|
16066
|
+
}
|
|
16067
|
+
|
|
16068
|
+
function encodeDateTz(date) {
|
|
16069
|
+
if (date && date.toISOString)
|
|
16070
|
+
return removeTimezone(date.toISOString());
|
|
16071
|
+
if (typeof date === 'string' && /(Z|[+-][0-9]{2}:[0-9]{2})$/.test(date))
|
|
16072
|
+
return removeTimezone(new Date(date).toISOString());
|
|
16073
|
+
return date;
|
|
16074
|
+
}
|
|
16075
|
+
|
|
16076
|
+
newTransaction$b = newResolveTransaction;
|
|
16077
|
+
return newTransaction$b;
|
|
16078
|
+
}
|
|
16079
|
+
|
|
16080
|
+
var newPool_1$b;
|
|
16081
|
+
var hasRequiredNewPool$b;
|
|
16082
|
+
|
|
16083
|
+
function requireNewPool$b () {
|
|
16084
|
+
if (hasRequiredNewPool$b) return newPool_1$b;
|
|
16085
|
+
hasRequiredNewPool$b = 1;
|
|
16086
|
+
const mySqlNewPool = requireNewPool$c();
|
|
16087
|
+
|
|
16088
|
+
function normalizeConnectionString(connectionString) {
|
|
16089
|
+
if (typeof connectionString === 'string' && connectionString.indexOf('mariadb://') === 0)
|
|
16090
|
+
return 'mysql://' + connectionString.slice('mariadb://'.length);
|
|
16091
|
+
return connectionString;
|
|
16092
|
+
}
|
|
16093
|
+
|
|
16094
|
+
function newPool(connectionString, poolOptions) {
|
|
16095
|
+
return mySqlNewPool(normalizeConnectionString(connectionString), poolOptions);
|
|
16096
|
+
}
|
|
16097
|
+
|
|
15761
16098
|
newPool_1$b = newPool;
|
|
15762
16099
|
return newPool_1$b;
|
|
15763
16100
|
}
|
|
@@ -15814,8 +16151,6 @@ function requireNewDatabase$b () {
|
|
|
15814
16151
|
function begin() {
|
|
15815
16152
|
return _begin(domain, options);
|
|
15816
16153
|
}
|
|
15817
|
-
|
|
15818
|
-
|
|
15819
16154
|
};
|
|
15820
16155
|
|
|
15821
16156
|
c.createTransaction = function(options) {
|
|
@@ -15835,7 +16170,6 @@ function requireNewDatabase$b () {
|
|
|
15835
16170
|
}
|
|
15836
16171
|
};
|
|
15837
16172
|
|
|
15838
|
-
|
|
15839
16173
|
c.query = function(query) {
|
|
15840
16174
|
let domain = createDomain();
|
|
15841
16175
|
let transaction = newTransaction(domain, pool);
|
|
@@ -15854,7 +16188,6 @@ function requireNewDatabase$b () {
|
|
|
15854
16188
|
}
|
|
15855
16189
|
};
|
|
15856
16190
|
|
|
15857
|
-
|
|
15858
16191
|
c.rollback = rollback;
|
|
15859
16192
|
c.commit = commit;
|
|
15860
16193
|
|
|
@@ -23214,6 +23547,7 @@ function requireSrc () {
|
|
|
23214
23547
|
const runtimes = requireRuntimes();
|
|
23215
23548
|
|
|
23216
23549
|
let _mySql;
|
|
23550
|
+
let _mariadb;
|
|
23217
23551
|
let _pg;
|
|
23218
23552
|
let _pglite;
|
|
23219
23553
|
let _sqlite;
|
|
@@ -23224,7 +23558,9 @@ function requireSrc () {
|
|
|
23224
23558
|
let _d1;
|
|
23225
23559
|
|
|
23226
23560
|
var connectViaPool = function(connectionString) {
|
|
23227
|
-
if (connectionString.indexOf && connectionString.indexOf('
|
|
23561
|
+
if (connectionString.indexOf && connectionString.indexOf('mariadb') === 0)
|
|
23562
|
+
return connectViaPool.mariadb.apply(null, arguments);
|
|
23563
|
+
else if (connectionString.indexOf && connectionString.indexOf('mysql') === 0)
|
|
23228
23564
|
return connectViaPool.mySql.apply(null, arguments);
|
|
23229
23565
|
else if (connectionString.indexOf && connectionString.indexOf('postgres') === 0)
|
|
23230
23566
|
connectViaPool.pg.apply(null, arguments);
|
|
@@ -23253,7 +23589,7 @@ function requireSrc () {
|
|
|
23253
23589
|
Object.defineProperty(connectViaPool, 'mysql', {
|
|
23254
23590
|
get: function() {
|
|
23255
23591
|
if (!_mySql)
|
|
23256
|
-
_mySql = requireNewDatabase$
|
|
23592
|
+
_mySql = requireNewDatabase$c();
|
|
23257
23593
|
return _mySql;
|
|
23258
23594
|
}
|
|
23259
23595
|
});
|
|
@@ -23261,10 +23597,17 @@ function requireSrc () {
|
|
|
23261
23597
|
Object.defineProperty(connectViaPool, 'mySql', {
|
|
23262
23598
|
get: function() {
|
|
23263
23599
|
if (!_mySql)
|
|
23264
|
-
_mySql = requireNewDatabase$
|
|
23600
|
+
_mySql = requireNewDatabase$c();
|
|
23265
23601
|
return _mySql;
|
|
23266
23602
|
}
|
|
23267
23603
|
});
|
|
23604
|
+
Object.defineProperty(connectViaPool, 'mariadb', {
|
|
23605
|
+
get: function() {
|
|
23606
|
+
if (!_mariadb)
|
|
23607
|
+
_mariadb = requireNewDatabase$b();
|
|
23608
|
+
return _mariadb;
|
|
23609
|
+
}
|
|
23610
|
+
});
|
|
23268
23611
|
Object.defineProperty(connectViaPool, 'pglite', {
|
|
23269
23612
|
get: function() {
|
|
23270
23613
|
if (!_pglite)
|
package/docs/changelog.md
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
## Changelog
|
|
2
|
+
__5.3.0__
|
|
3
|
+
Support for MariaDB [#169](https://github.com/alfateam/orange-orm/issues/169)
|
|
4
|
+
__5.2.4__
|
|
5
|
+
Meta parameter in validator is optional
|
|
2
6
|
__5.2.3__
|
|
3
7
|
Pass table and column and other metadata to custom validate function [#165](https://github.com/alfateam/orange-orm/issues/165)
|
|
4
8
|
__5.2.2__
|
package/other.db
ADDED
|
Binary file
|
package/package.json
CHANGED
package/src/client/clientMap.js
CHANGED
|
@@ -37,6 +37,7 @@ function map(index, _fn) {
|
|
|
37
37
|
dbMap.mssql = throwDb;
|
|
38
38
|
dbMap.mssqlNative = throwDb;
|
|
39
39
|
dbMap.mysql = throwDb;
|
|
40
|
+
dbMap.mariadb = throwDb;
|
|
40
41
|
dbMap.sap = throwDb;
|
|
41
42
|
dbMap.oracle = throwDb;
|
|
42
43
|
dbMap.sqlite = throwDb;
|
|
@@ -65,6 +66,7 @@ function map(index, _fn) {
|
|
|
65
66
|
onFinal.mssql = () => index({ db: throwDb, providers: dbMap });
|
|
66
67
|
onFinal.mssqlNative = () => index({ db: throwDb, providers: dbMap });
|
|
67
68
|
onFinal.mysql = () => index({ db: throwDb, providers: dbMap });
|
|
69
|
+
onFinal.mariadb = () => index({ db: throwDb, providers: dbMap });
|
|
68
70
|
onFinal.sap = () => index({ db: throwDb, providers: dbMap });
|
|
69
71
|
onFinal.oracle = () => index({ db: throwDb, providers: dbMap });
|
|
70
72
|
onFinal.sqlite = () => index({ db: throwDb, providers: dbMap });
|
|
@@ -38,6 +38,11 @@ function createProviders(index) {
|
|
|
38
38
|
return createPool.bind(null, 'mysql');
|
|
39
39
|
}
|
|
40
40
|
});
|
|
41
|
+
Object.defineProperty(dbMap, 'mariadb', {
|
|
42
|
+
get: function() {
|
|
43
|
+
return createPool.bind(null, 'mariadb');
|
|
44
|
+
}
|
|
45
|
+
});
|
|
41
46
|
Object.defineProperty(dbMap, 'sap', {
|
|
42
47
|
get: function() {
|
|
43
48
|
return createPool.bind(null, 'sap');
|
|
@@ -102,6 +107,9 @@ function negotiateCachedPool(fn, providers) {
|
|
|
102
107
|
get mysql() {
|
|
103
108
|
return createPool.bind(null, 'mysql');
|
|
104
109
|
},
|
|
110
|
+
get mariadb() {
|
|
111
|
+
return createPool.bind(null, 'mariadb');
|
|
112
|
+
},
|
|
105
113
|
get sap() {
|
|
106
114
|
return createPool.bind(null, 'sap');
|
|
107
115
|
},
|