orange-orm 4.7.0-beta.1 → 4.7.0-beta.3
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 -0
- package/dist/index.browser.mjs +896 -170
- package/dist/index.mjs +41 -63
- package/package.json +1 -1
- package/src/bunPg/newDatabase.js +2 -5
- package/src/bunPg/pool/newPgPool.js +1 -0
- package/src/bunSqlite/newDatabase.js +2 -5
- package/src/bunSqlite/pool/newGenericPool.js +1 -0
- package/src/client/index.js +5 -0
- package/src/d1/newDatabase.js +2 -5
- package/src/d1/pool/newGenericPool.js +1 -0
- package/src/index.d.ts +1 -1
- package/src/indexBrowser.js +9 -0
- package/src/map.d.ts +1 -0
- package/src/mssql/newDatabase.js +2 -5
- package/src/mssql/pool/newGenericPool.js +1 -0
- package/src/mySql/newDatabase.js +2 -5
- package/src/mySql/pool/newGenericPool.js +1 -0
- package/src/nodeSqlite/newDatabase.js +2 -5
- package/src/nodeSqlite/pool/newGenericPool.js +1 -0
- package/src/oracle/newDatabase.js +2 -5
- package/src/oracle/pool/newGenericPool.js +1 -0
- package/src/pg/newDatabase.js +2 -5
- package/src/pg/pool/newPgPool.js +1 -0
- package/src/pglite/newDatabase.js +2 -5
- package/src/pglite/newTransaction.js +1 -3
- package/src/pglite/pool/newPgPool.js +1 -0
- package/src/sap/newDatabase.js +2 -5
- package/src/sqlite3/newDatabase.js +2 -5
- package/src/sqlite3/pool/newGenericPool.js +1 -0
- package/src/tedious/newDatabase.js +2 -5
- package/src/tedious/pool/newGenericPool.js +1 -0
package/dist/index.browser.mjs
CHANGED
|
@@ -2085,12 +2085,12 @@ function requireNegotiateParameters () {
|
|
|
2085
2085
|
return negotiateParameters_1;
|
|
2086
2086
|
}
|
|
2087
2087
|
|
|
2088
|
-
var wrapQuery_1$
|
|
2089
|
-
var hasRequiredWrapQuery$
|
|
2088
|
+
var wrapQuery_1$2;
|
|
2089
|
+
var hasRequiredWrapQuery$2;
|
|
2090
2090
|
|
|
2091
|
-
function requireWrapQuery$
|
|
2092
|
-
if (hasRequiredWrapQuery$
|
|
2093
|
-
hasRequiredWrapQuery$
|
|
2091
|
+
function requireWrapQuery$2 () {
|
|
2092
|
+
if (hasRequiredWrapQuery$2) return wrapQuery_1$2;
|
|
2093
|
+
hasRequiredWrapQuery$2 = 1;
|
|
2094
2094
|
var negotiateSql = requireNegotiateSql();
|
|
2095
2095
|
var negotiateParameters = requireNegotiateParameters();
|
|
2096
2096
|
|
|
@@ -2107,8 +2107,8 @@ function requireWrapQuery$1 () {
|
|
|
2107
2107
|
}
|
|
2108
2108
|
|
|
2109
2109
|
|
|
2110
|
-
wrapQuery_1$
|
|
2111
|
-
return wrapQuery_1$
|
|
2110
|
+
wrapQuery_1$2 = wrapQuery;
|
|
2111
|
+
return wrapQuery_1$2;
|
|
2112
2112
|
}
|
|
2113
2113
|
|
|
2114
2114
|
var query;
|
|
@@ -2118,7 +2118,7 @@ function requireQuery () {
|
|
|
2118
2118
|
if (hasRequiredQuery) return query;
|
|
2119
2119
|
hasRequiredQuery = 1;
|
|
2120
2120
|
var executeQueries = requireExecuteQueries();
|
|
2121
|
-
var wrapQuery = requireWrapQuery$
|
|
2121
|
+
var wrapQuery = requireWrapQuery$2();
|
|
2122
2122
|
|
|
2123
2123
|
function doQuery(context, query) {
|
|
2124
2124
|
var wrappedQuery = wrapQuery(query);
|
|
@@ -2727,6 +2727,11 @@ function requireClient () {
|
|
|
2727
2727
|
client.http = onProvider.bind(null, 'http');//todo
|
|
2728
2728
|
client.mysql = onProvider.bind(null, 'mysql');
|
|
2729
2729
|
client.express = express;
|
|
2730
|
+
client.close = close;
|
|
2731
|
+
|
|
2732
|
+
function close() {
|
|
2733
|
+
return client.db.end ? client.db.end() : Promise.resolve();
|
|
2734
|
+
}
|
|
2730
2735
|
|
|
2731
2736
|
function onProvider(name, ...args) {
|
|
2732
2737
|
let db = providers[name].apply(null, args);
|
|
@@ -3749,11 +3754,11 @@ function requireEncodeFilterArg () {
|
|
|
3749
3754
|
}
|
|
3750
3755
|
|
|
3751
3756
|
var quote_1;
|
|
3752
|
-
var hasRequiredQuote$
|
|
3757
|
+
var hasRequiredQuote$2;
|
|
3753
3758
|
|
|
3754
|
-
function requireQuote$
|
|
3755
|
-
if (hasRequiredQuote$
|
|
3756
|
-
hasRequiredQuote$
|
|
3759
|
+
function requireQuote$2 () {
|
|
3760
|
+
if (hasRequiredQuote$2) return quote_1;
|
|
3761
|
+
hasRequiredQuote$2 = 1;
|
|
3757
3762
|
let tryGetSessionContext = requireTryGetSessionContext();
|
|
3758
3763
|
|
|
3759
3764
|
function quote(context, name) {
|
|
@@ -3777,7 +3782,7 @@ function requireEqual () {
|
|
|
3777
3782
|
var newBoolean = requireNewBoolean();
|
|
3778
3783
|
var nullOperator = ' is ';
|
|
3779
3784
|
var encodeFilterArg = requireEncodeFilterArg();
|
|
3780
|
-
var quote = requireQuote$
|
|
3785
|
+
var quote = requireQuote$2();
|
|
3781
3786
|
|
|
3782
3787
|
function equal(context, column,arg,alias) {
|
|
3783
3788
|
var operator = '=';
|
|
@@ -3802,7 +3807,7 @@ function requireNotEqual () {
|
|
|
3802
3807
|
var newBoolean = requireNewBoolean();
|
|
3803
3808
|
var encodeFilterArg = requireEncodeFilterArg();
|
|
3804
3809
|
var nullOperator = ' is not ';
|
|
3805
|
-
var quote = requireQuote$
|
|
3810
|
+
var quote = requireQuote$2();
|
|
3806
3811
|
|
|
3807
3812
|
function notEqual(context, column,arg,alias) {
|
|
3808
3813
|
var operator = '<>';
|
|
@@ -3826,7 +3831,7 @@ function requireLessThan () {
|
|
|
3826
3831
|
hasRequiredLessThan = 1;
|
|
3827
3832
|
var newBoolean = requireNewBoolean();
|
|
3828
3833
|
var encodeFilterArg = requireEncodeFilterArg();
|
|
3829
|
-
var quote = requireQuote$
|
|
3834
|
+
var quote = requireQuote$2();
|
|
3830
3835
|
|
|
3831
3836
|
function lessThanOrEqual(context, column,arg,alias) {
|
|
3832
3837
|
var operator = '<';
|
|
@@ -3871,7 +3876,7 @@ function requireGreaterThan () {
|
|
|
3871
3876
|
hasRequiredGreaterThan = 1;
|
|
3872
3877
|
var newBoolean = requireNewBoolean();
|
|
3873
3878
|
var encodeFilterArg = requireEncodeFilterArg();
|
|
3874
|
-
var quote = requireQuote$
|
|
3879
|
+
var quote = requireQuote$2();
|
|
3875
3880
|
|
|
3876
3881
|
function greaterThan(context, column,arg,alias) {
|
|
3877
3882
|
var operator = '>';
|
|
@@ -3893,7 +3898,7 @@ function requireGreaterThanOrEqual () {
|
|
|
3893
3898
|
hasRequiredGreaterThanOrEqual = 1;
|
|
3894
3899
|
var newBoolean = requireNewBoolean();
|
|
3895
3900
|
var encodeFilterArg = requireEncodeFilterArg();
|
|
3896
|
-
var quote = requireQuote$
|
|
3901
|
+
var quote = requireQuote$2();
|
|
3897
3902
|
|
|
3898
3903
|
function greaterThanOrEqual(context, column,arg,alias) {
|
|
3899
3904
|
var operator = '>=';
|
|
@@ -3915,7 +3920,7 @@ function require_in () {
|
|
|
3915
3920
|
hasRequired_in = 1;
|
|
3916
3921
|
const newParameterized = requireNewParameterized();
|
|
3917
3922
|
const newBoolean = requireNewBoolean();
|
|
3918
|
-
const quote = requireQuote$
|
|
3923
|
+
const quote = requireQuote$2();
|
|
3919
3924
|
|
|
3920
3925
|
function _in(context, column,values,alias) {
|
|
3921
3926
|
let filter;
|
|
@@ -4140,7 +4145,7 @@ function requireNewColumn () {
|
|
|
4140
4145
|
const greaterThanOrEqual = requireGreaterThanOrEqual();
|
|
4141
4146
|
const _in = require_in();
|
|
4142
4147
|
const _extractAlias = requireExtractAlias();
|
|
4143
|
-
const quote = requireQuote$
|
|
4148
|
+
const quote = requireQuote$2();
|
|
4144
4149
|
const aggregate = requireColumnAggregate$1();
|
|
4145
4150
|
const aggregateGroup = requireColumnAggregateGroup$1();
|
|
4146
4151
|
|
|
@@ -4328,7 +4333,7 @@ function requireStartsWithCore () {
|
|
|
4328
4333
|
hasRequiredStartsWithCore = 1;
|
|
4329
4334
|
var newBoolean = requireNewBoolean();
|
|
4330
4335
|
var nullOperator = ' is ';
|
|
4331
|
-
var quote = requireQuote$
|
|
4336
|
+
var quote = requireQuote$2();
|
|
4332
4337
|
|
|
4333
4338
|
function startsWithCore(context, operator, column,arg,alias) {
|
|
4334
4339
|
operator = ' ' + operator + ' ';
|
|
@@ -4364,7 +4369,7 @@ var hasRequiredEndsWithCore;
|
|
|
4364
4369
|
function requireEndsWithCore () {
|
|
4365
4370
|
if (hasRequiredEndsWithCore) return endsWithCore_1;
|
|
4366
4371
|
hasRequiredEndsWithCore = 1;
|
|
4367
|
-
const quote = requireQuote$
|
|
4372
|
+
const quote = requireQuote$2();
|
|
4368
4373
|
var newBoolean = requireNewBoolean();
|
|
4369
4374
|
var nullOperator = ' is ';
|
|
4370
4375
|
|
|
@@ -4403,7 +4408,7 @@ var hasRequiredContainsCore;
|
|
|
4403
4408
|
function requireContainsCore () {
|
|
4404
4409
|
if (hasRequiredContainsCore) return containsCore;
|
|
4405
4410
|
hasRequiredContainsCore = 1;
|
|
4406
|
-
const quote = requireQuote$
|
|
4411
|
+
const quote = requireQuote$2();
|
|
4407
4412
|
var newBoolean = requireNewBoolean();
|
|
4408
4413
|
var nullOperator = ' is ';
|
|
4409
4414
|
|
|
@@ -4481,7 +4486,7 @@ function requireIEqual () {
|
|
|
4481
4486
|
var newBoolean = requireNewBoolean();
|
|
4482
4487
|
var nullOperator = ' is ';
|
|
4483
4488
|
var encodeFilterArg = requireEncodeFilterArg();
|
|
4484
|
-
const quote = requireQuote$
|
|
4489
|
+
const quote = requireQuote$2();
|
|
4485
4490
|
|
|
4486
4491
|
function iEqual(context, column,arg,alias) {
|
|
4487
4492
|
var operator = ' ILIKE ';
|
|
@@ -4673,7 +4678,7 @@ function requireFormatOut$1 () {
|
|
|
4673
4678
|
if (hasRequiredFormatOut$1) return formatOut_1$1;
|
|
4674
4679
|
hasRequiredFormatOut$1 = 1;
|
|
4675
4680
|
var getSessionSingleton = requireGetSessionSingleton();
|
|
4676
|
-
const quote = requireQuote$
|
|
4681
|
+
const quote = requireQuote$2();
|
|
4677
4682
|
|
|
4678
4683
|
function formatOut(context, column, alias) {
|
|
4679
4684
|
var formatColumn = getSessionSingleton(context, 'formatJSONOut');
|
|
@@ -4964,7 +4969,7 @@ function requireFormatOut () {
|
|
|
4964
4969
|
if (hasRequiredFormatOut) return formatOut_1;
|
|
4965
4970
|
hasRequiredFormatOut = 1;
|
|
4966
4971
|
var getSessionSingleton = requireGetSessionSingleton();
|
|
4967
|
-
const quote = requireQuote$
|
|
4972
|
+
const quote = requireQuote$2();
|
|
4968
4973
|
|
|
4969
4974
|
function formatOut(context, column, alias) {
|
|
4970
4975
|
var formatColumn = getSessionSingleton(context, 'formatDateOut');
|
|
@@ -6102,7 +6107,7 @@ function requireNewSingleQuery$1 () {
|
|
|
6102
6107
|
var negotiateLimit = requireNegotiateLimit();
|
|
6103
6108
|
var negotiateExclusive = requireNegotiateExclusive();
|
|
6104
6109
|
var newParameterized = requireNewParameterized();
|
|
6105
|
-
var quote = requireQuote$
|
|
6110
|
+
var quote = requireQuote$2();
|
|
6106
6111
|
|
|
6107
6112
|
function _new(context, table, filter, span, alias, innerJoin, orderBy, limit, offset, exclusive) {
|
|
6108
6113
|
|
|
@@ -6764,7 +6769,7 @@ function requireSelectSql$1 () {
|
|
|
6764
6769
|
hasRequiredSelectSql$1 = 1;
|
|
6765
6770
|
const newParameterized = requireNewParameterized();
|
|
6766
6771
|
const newBoolean = requireNewBoolean();
|
|
6767
|
-
const quote = requireQuote$
|
|
6772
|
+
const quote = requireQuote$2();
|
|
6768
6773
|
|
|
6769
6774
|
function newSelectSql(context, table, alias) {
|
|
6770
6775
|
const colName = quote(context, table._primaryColumns[0]._dbName);
|
|
@@ -9322,7 +9327,7 @@ function requireChildColumn () {
|
|
|
9322
9327
|
var getSessionContext = requireGetSessionContext();
|
|
9323
9328
|
var newJoinCore = requireNewShallowJoinSqlCore();
|
|
9324
9329
|
const getSessionSingleton = requireGetSessionSingleton();
|
|
9325
|
-
const _quote = requireQuote$
|
|
9330
|
+
const _quote = requireQuote$2();
|
|
9326
9331
|
|
|
9327
9332
|
|
|
9328
9333
|
function childColumn(context, column, relations) {
|
|
@@ -10644,7 +10649,7 @@ function requireCount () {
|
|
|
10644
10649
|
const negotiateRawSqlFilter = requireNegotiateRawSqlFilter();
|
|
10645
10650
|
const extractFilter = requireExtractFilter();
|
|
10646
10651
|
const newWhereSql = requireNewWhereSql();
|
|
10647
|
-
const quote = requireQuote$
|
|
10652
|
+
const quote = requireQuote$2();
|
|
10648
10653
|
|
|
10649
10654
|
async function count(context, table, filter) {
|
|
10650
10655
|
let alias = table._dbName;
|
|
@@ -11371,11 +11376,11 @@ function requireNewRow () {
|
|
|
11371
11376
|
}
|
|
11372
11377
|
|
|
11373
11378
|
var insert_1;
|
|
11374
|
-
var hasRequiredInsert$
|
|
11379
|
+
var hasRequiredInsert$2;
|
|
11375
11380
|
|
|
11376
|
-
function requireInsert$
|
|
11377
|
-
if (hasRequiredInsert$
|
|
11378
|
-
hasRequiredInsert$
|
|
11381
|
+
function requireInsert$2 () {
|
|
11382
|
+
if (hasRequiredInsert$2) return insert_1;
|
|
11383
|
+
hasRequiredInsert$2 = 1;
|
|
11379
11384
|
let getSessionContext = requireGetSessionContext();
|
|
11380
11385
|
let newRow = requireNewRow();
|
|
11381
11386
|
|
|
@@ -11682,7 +11687,7 @@ function requireTable () {
|
|
|
11682
11687
|
const tryGetFirst = requireTryGetFirstFromDb();
|
|
11683
11688
|
const newCache = requireNewRowCache();
|
|
11684
11689
|
const newContext = requireNewObject();
|
|
11685
|
-
const insert = requireInsert$
|
|
11690
|
+
const insert = requireInsert$2();
|
|
11686
11691
|
const _delete = require_delete();
|
|
11687
11692
|
const cascadeDelete = requireCascadeDelete();
|
|
11688
11693
|
const patchTable = requirePatchTable();
|
|
@@ -12524,12 +12529,12 @@ function requireCreateDomain () {
|
|
|
12524
12529
|
return createDomain_1;
|
|
12525
12530
|
}
|
|
12526
12531
|
|
|
12527
|
-
var wrapQuery_1;
|
|
12528
|
-
var hasRequiredWrapQuery;
|
|
12532
|
+
var wrapQuery_1$1;
|
|
12533
|
+
var hasRequiredWrapQuery$1;
|
|
12529
12534
|
|
|
12530
|
-
function requireWrapQuery () {
|
|
12531
|
-
if (hasRequiredWrapQuery) return wrapQuery_1;
|
|
12532
|
-
hasRequiredWrapQuery = 1;
|
|
12535
|
+
function requireWrapQuery$1 () {
|
|
12536
|
+
if (hasRequiredWrapQuery$1) return wrapQuery_1$1;
|
|
12537
|
+
hasRequiredWrapQuery$1 = 1;
|
|
12533
12538
|
var log = requireLog();
|
|
12534
12539
|
|
|
12535
12540
|
function wrapQuery(_context, client) {
|
|
@@ -12551,8 +12556,8 @@ function requireWrapQuery () {
|
|
|
12551
12556
|
|
|
12552
12557
|
}
|
|
12553
12558
|
|
|
12554
|
-
wrapQuery_1 = wrapQuery;
|
|
12555
|
-
return wrapQuery_1;
|
|
12559
|
+
wrapQuery_1$1 = wrapQuery;
|
|
12560
|
+
return wrapQuery_1$1;
|
|
12556
12561
|
}
|
|
12557
12562
|
|
|
12558
12563
|
var encodeBoolean_1;
|
|
@@ -12589,55 +12594,55 @@ function requireFormat () {
|
|
|
12589
12594
|
return format_1;
|
|
12590
12595
|
}
|
|
12591
12596
|
|
|
12592
|
-
var quote;
|
|
12593
|
-
var hasRequiredQuote;
|
|
12597
|
+
var quote$1;
|
|
12598
|
+
var hasRequiredQuote$1;
|
|
12594
12599
|
|
|
12595
|
-
function requireQuote () {
|
|
12596
|
-
if (hasRequiredQuote) return quote;
|
|
12597
|
-
hasRequiredQuote = 1;
|
|
12598
|
-
quote = (name) => `"${name}"`;
|
|
12599
|
-
return quote;
|
|
12600
|
+
function requireQuote$1 () {
|
|
12601
|
+
if (hasRequiredQuote$1) return quote$1;
|
|
12602
|
+
hasRequiredQuote$1 = 1;
|
|
12603
|
+
quote$1 = (name) => `"${name}"`;
|
|
12604
|
+
return quote$1;
|
|
12600
12605
|
}
|
|
12601
12606
|
|
|
12602
|
-
var deleteFromSql_1;
|
|
12603
|
-
var hasRequiredDeleteFromSql;
|
|
12607
|
+
var deleteFromSql_1$1;
|
|
12608
|
+
var hasRequiredDeleteFromSql$1;
|
|
12604
12609
|
|
|
12605
|
-
function requireDeleteFromSql () {
|
|
12606
|
-
if (hasRequiredDeleteFromSql) return deleteFromSql_1;
|
|
12607
|
-
hasRequiredDeleteFromSql = 1;
|
|
12610
|
+
function requireDeleteFromSql$1 () {
|
|
12611
|
+
if (hasRequiredDeleteFromSql$1) return deleteFromSql_1$1;
|
|
12612
|
+
hasRequiredDeleteFromSql$1 = 1;
|
|
12608
12613
|
const format = 'delete from %s where %s.rowId in (SELECT %s.rowId FROM %s %s%s)';
|
|
12609
12614
|
const formatString = requireFormat();
|
|
12610
|
-
const quote = requireQuote();
|
|
12615
|
+
const quote = requireQuote$1();
|
|
12611
12616
|
|
|
12612
12617
|
function deleteFromSql(table, alias, whereSql) {
|
|
12613
12618
|
const name = quote(table._dbName);
|
|
12614
12619
|
alias = quote(alias);
|
|
12615
12620
|
return formatString(format, name, name, alias, name, alias, whereSql);
|
|
12616
12621
|
}
|
|
12617
|
-
deleteFromSql_1 = deleteFromSql;
|
|
12618
|
-
return deleteFromSql_1;
|
|
12622
|
+
deleteFromSql_1$1 = deleteFromSql;
|
|
12623
|
+
return deleteFromSql_1$1;
|
|
12619
12624
|
}
|
|
12620
12625
|
|
|
12621
|
-
var selectForUpdateSql;
|
|
12622
|
-
var hasRequiredSelectForUpdateSql;
|
|
12626
|
+
var selectForUpdateSql$1;
|
|
12627
|
+
var hasRequiredSelectForUpdateSql$1;
|
|
12623
12628
|
|
|
12624
|
-
function requireSelectForUpdateSql () {
|
|
12625
|
-
if (hasRequiredSelectForUpdateSql) return selectForUpdateSql;
|
|
12626
|
-
hasRequiredSelectForUpdateSql = 1;
|
|
12627
|
-
const quote = requireQuote$
|
|
12629
|
+
function requireSelectForUpdateSql$1 () {
|
|
12630
|
+
if (hasRequiredSelectForUpdateSql$1) return selectForUpdateSql$1;
|
|
12631
|
+
hasRequiredSelectForUpdateSql$1 = 1;
|
|
12632
|
+
const quote = requireQuote$2();
|
|
12628
12633
|
|
|
12629
|
-
selectForUpdateSql = function(alias) {
|
|
12634
|
+
selectForUpdateSql$1 = function(alias) {
|
|
12630
12635
|
return ' FOR UPDATE OF ' + quote(alias);
|
|
12631
12636
|
};
|
|
12632
|
-
return selectForUpdateSql;
|
|
12637
|
+
return selectForUpdateSql$1;
|
|
12633
12638
|
}
|
|
12634
12639
|
|
|
12635
|
-
var lastInsertedSql_1;
|
|
12636
|
-
var hasRequiredLastInsertedSql;
|
|
12640
|
+
var lastInsertedSql_1$1;
|
|
12641
|
+
var hasRequiredLastInsertedSql$1;
|
|
12637
12642
|
|
|
12638
|
-
function requireLastInsertedSql () {
|
|
12639
|
-
if (hasRequiredLastInsertedSql) return lastInsertedSql_1;
|
|
12640
|
-
hasRequiredLastInsertedSql = 1;
|
|
12643
|
+
function requireLastInsertedSql$1 () {
|
|
12644
|
+
if (hasRequiredLastInsertedSql$1) return lastInsertedSql_1$1;
|
|
12645
|
+
hasRequiredLastInsertedSql$1 = 1;
|
|
12641
12646
|
function lastInsertedSql(context, table, keyValues) {
|
|
12642
12647
|
return keyValues.map((value,i) => {
|
|
12643
12648
|
let column = table._primaryColumns[i];
|
|
@@ -12649,16 +12654,16 @@ function requireLastInsertedSql () {
|
|
|
12649
12654
|
|
|
12650
12655
|
}
|
|
12651
12656
|
|
|
12652
|
-
lastInsertedSql_1 = lastInsertedSql;
|
|
12653
|
-
return lastInsertedSql_1;
|
|
12657
|
+
lastInsertedSql_1$1 = lastInsertedSql;
|
|
12658
|
+
return lastInsertedSql_1$1;
|
|
12654
12659
|
}
|
|
12655
12660
|
|
|
12656
|
-
var limitAndOffset_1;
|
|
12657
|
-
var hasRequiredLimitAndOffset;
|
|
12661
|
+
var limitAndOffset_1$1;
|
|
12662
|
+
var hasRequiredLimitAndOffset$1;
|
|
12658
12663
|
|
|
12659
|
-
function requireLimitAndOffset () {
|
|
12660
|
-
if (hasRequiredLimitAndOffset) return limitAndOffset_1;
|
|
12661
|
-
hasRequiredLimitAndOffset = 1;
|
|
12664
|
+
function requireLimitAndOffset$1 () {
|
|
12665
|
+
if (hasRequiredLimitAndOffset$1) return limitAndOffset_1$1;
|
|
12666
|
+
hasRequiredLimitAndOffset$1 = 1;
|
|
12662
12667
|
function limitAndOffset(span) {
|
|
12663
12668
|
if (span.offset)
|
|
12664
12669
|
return ` limit ${limit()} offset ${span.offset}`;
|
|
@@ -12676,17 +12681,17 @@ function requireLimitAndOffset () {
|
|
|
12676
12681
|
|
|
12677
12682
|
}
|
|
12678
12683
|
|
|
12679
|
-
limitAndOffset_1 = limitAndOffset;
|
|
12680
|
-
return limitAndOffset_1;
|
|
12684
|
+
limitAndOffset_1$1 = limitAndOffset;
|
|
12685
|
+
return limitAndOffset_1$1;
|
|
12681
12686
|
}
|
|
12682
12687
|
|
|
12683
|
-
var insertSql_1;
|
|
12684
|
-
var hasRequiredInsertSql;
|
|
12688
|
+
var insertSql_1$1;
|
|
12689
|
+
var hasRequiredInsertSql$1;
|
|
12685
12690
|
|
|
12686
|
-
function requireInsertSql () {
|
|
12687
|
-
if (hasRequiredInsertSql) return insertSql_1;
|
|
12688
|
-
hasRequiredInsertSql = 1;
|
|
12689
|
-
const quote = requireQuote();
|
|
12691
|
+
function requireInsertSql$1 () {
|
|
12692
|
+
if (hasRequiredInsertSql$1) return insertSql_1$1;
|
|
12693
|
+
hasRequiredInsertSql$1 = 1;
|
|
12694
|
+
const quote = requireQuote$1();
|
|
12690
12695
|
|
|
12691
12696
|
function insertSql(_context, table, row, options) {
|
|
12692
12697
|
let columnNames = [];
|
|
@@ -12752,8 +12757,8 @@ function requireInsertSql () {
|
|
|
12752
12757
|
}
|
|
12753
12758
|
}
|
|
12754
12759
|
|
|
12755
|
-
insertSql_1 = insertSql;
|
|
12756
|
-
return insertSql_1;
|
|
12760
|
+
insertSql_1$1 = insertSql;
|
|
12761
|
+
return insertSql_1$1;
|
|
12757
12762
|
}
|
|
12758
12763
|
|
|
12759
12764
|
var newInsertCommand_1;
|
|
@@ -12830,7 +12835,7 @@ function requireGetSqlTemplate () {
|
|
|
12830
12835
|
if (hasRequiredGetSqlTemplate) return getSqlTemplate_1;
|
|
12831
12836
|
hasRequiredGetSqlTemplate = 1;
|
|
12832
12837
|
let getSessionContext = requireGetSessionContext();
|
|
12833
|
-
let quote = requireQuote$
|
|
12838
|
+
let quote = requireQuote$2();
|
|
12834
12839
|
|
|
12835
12840
|
function getSqlTemplate(context, _table, _row) {
|
|
12836
12841
|
let rdb = getSessionContext(context);
|
|
@@ -12944,7 +12949,7 @@ function requireNewGetLastInsertedCommandCore () {
|
|
|
12944
12949
|
const newParameterized = requireNewParameterized();
|
|
12945
12950
|
const getSessionContext = requireGetSessionContext();
|
|
12946
12951
|
const newDiscriminatorSql = requireNewDiscriminatorSql$1();
|
|
12947
|
-
const quote = requireQuote$
|
|
12952
|
+
const quote = requireQuote$2();
|
|
12948
12953
|
|
|
12949
12954
|
function newGetLastInsertedCommandCore(context, table, row) {
|
|
12950
12955
|
let parameters = [];
|
|
@@ -13046,12 +13051,12 @@ function requireNewGetLastInsertedCommand () {
|
|
|
13046
13051
|
return newGetLastInsertedCommand_1;
|
|
13047
13052
|
}
|
|
13048
13053
|
|
|
13049
|
-
var insert;
|
|
13050
|
-
var hasRequiredInsert;
|
|
13054
|
+
var insert$1;
|
|
13055
|
+
var hasRequiredInsert$1;
|
|
13051
13056
|
|
|
13052
|
-
function requireInsert () {
|
|
13053
|
-
if (hasRequiredInsert) return insert;
|
|
13054
|
-
hasRequiredInsert = 1;
|
|
13057
|
+
function requireInsert$1 () {
|
|
13058
|
+
if (hasRequiredInsert$1) return insert$1;
|
|
13059
|
+
hasRequiredInsert$1 = 1;
|
|
13055
13060
|
let newInsertCommand = requireNewInsertCommand();
|
|
13056
13061
|
let newInsertCommandCore = requireNewInsertCommandCore();
|
|
13057
13062
|
let newGetLastInsertedCommand = requireNewGetLastInsertedCommand();
|
|
@@ -13072,24 +13077,24 @@ function requireInsert () {
|
|
|
13072
13077
|
|
|
13073
13078
|
}
|
|
13074
13079
|
|
|
13075
|
-
insert = insertDefault;
|
|
13076
|
-
return insert;
|
|
13080
|
+
insert$1 = insertDefault;
|
|
13081
|
+
return insert$1;
|
|
13077
13082
|
}
|
|
13078
13083
|
|
|
13079
|
-
var newTransaction;
|
|
13080
|
-
var hasRequiredNewTransaction;
|
|
13084
|
+
var newTransaction$1;
|
|
13085
|
+
var hasRequiredNewTransaction$1;
|
|
13081
13086
|
|
|
13082
|
-
function requireNewTransaction () {
|
|
13083
|
-
if (hasRequiredNewTransaction) return newTransaction;
|
|
13084
|
-
hasRequiredNewTransaction = 1;
|
|
13085
|
-
const wrapQuery = requireWrapQuery();
|
|
13087
|
+
function requireNewTransaction$1 () {
|
|
13088
|
+
if (hasRequiredNewTransaction$1) return newTransaction$1;
|
|
13089
|
+
hasRequiredNewTransaction$1 = 1;
|
|
13090
|
+
const wrapQuery = requireWrapQuery$1();
|
|
13086
13091
|
const encodeBoolean = requireEncodeBoolean();
|
|
13087
|
-
const deleteFromSql = requireDeleteFromSql();
|
|
13088
|
-
const selectForUpdateSql = requireSelectForUpdateSql();
|
|
13089
|
-
const lastInsertedSql = requireLastInsertedSql();
|
|
13090
|
-
const limitAndOffset = requireLimitAndOffset();
|
|
13091
|
-
const insertSql = requireInsertSql();
|
|
13092
|
-
const insert = requireInsert();
|
|
13092
|
+
const deleteFromSql = requireDeleteFromSql$1();
|
|
13093
|
+
const selectForUpdateSql = requireSelectForUpdateSql$1();
|
|
13094
|
+
const lastInsertedSql = requireLastInsertedSql$1();
|
|
13095
|
+
const limitAndOffset = requireLimitAndOffset$1();
|
|
13096
|
+
const insertSql = requireInsertSql$1();
|
|
13097
|
+
const insert = requireInsert$1();
|
|
13093
13098
|
|
|
13094
13099
|
function newResolveTransaction(domain, pool, { readonly = false } = {}) {
|
|
13095
13100
|
var rdb = {poolFactory: pool};
|
|
@@ -13165,8 +13170,8 @@ function requireNewTransaction () {
|
|
|
13165
13170
|
return JSON.parse(value);
|
|
13166
13171
|
}
|
|
13167
13172
|
|
|
13168
|
-
newTransaction = newResolveTransaction;
|
|
13169
|
-
return newTransaction;
|
|
13173
|
+
newTransaction$1 = newResolveTransaction;
|
|
13174
|
+
return newTransaction$1;
|
|
13170
13175
|
}
|
|
13171
13176
|
|
|
13172
13177
|
var beginCommand;
|
|
@@ -13247,12 +13252,12 @@ function requirePromisify () {
|
|
|
13247
13252
|
return promisify_1;
|
|
13248
13253
|
}
|
|
13249
13254
|
|
|
13250
|
-
var end;
|
|
13251
|
-
var hasRequiredEnd;
|
|
13255
|
+
var end$1;
|
|
13256
|
+
var hasRequiredEnd$1;
|
|
13252
13257
|
|
|
13253
|
-
function requireEnd () {
|
|
13254
|
-
if (hasRequiredEnd) return end;
|
|
13255
|
-
hasRequiredEnd = 1;
|
|
13258
|
+
function requireEnd$1 () {
|
|
13259
|
+
if (hasRequiredEnd$1) return end$1;
|
|
13260
|
+
hasRequiredEnd$1 = 1;
|
|
13256
13261
|
var pools = requirePools();
|
|
13257
13262
|
|
|
13258
13263
|
function endPool(genericPool, id, done) {
|
|
@@ -13265,8 +13270,8 @@ function requireEnd () {
|
|
|
13265
13270
|
}
|
|
13266
13271
|
}
|
|
13267
13272
|
|
|
13268
|
-
end = endPool;
|
|
13269
|
-
return end;
|
|
13273
|
+
end$1 = endPool;
|
|
13274
|
+
return end$1;
|
|
13270
13275
|
}
|
|
13271
13276
|
|
|
13272
13277
|
var poolDefaults;
|
|
@@ -13919,6 +13924,7 @@ function requireNewGenericPool () {
|
|
|
13919
13924
|
poolOptions = poolOptions || {};
|
|
13920
13925
|
// @ts-ignore
|
|
13921
13926
|
var pool = genericPool.Pool({
|
|
13927
|
+
min: poolOptions.min || 0,
|
|
13922
13928
|
max: 1,
|
|
13923
13929
|
idleTimeoutMillis: poolOptions.idleTimeout || defaults.poolIdleTimeout,
|
|
13924
13930
|
reapIntervalMillis: poolOptions.reapIntervalMillis || defaults.reapIntervalMillis,
|
|
@@ -13954,15 +13960,15 @@ function requireNewGenericPool () {
|
|
|
13954
13960
|
return newGenericPool_1;
|
|
13955
13961
|
}
|
|
13956
13962
|
|
|
13957
|
-
var newPool_1;
|
|
13958
|
-
var hasRequiredNewPool;
|
|
13963
|
+
var newPool_1$1;
|
|
13964
|
+
var hasRequiredNewPool$1;
|
|
13959
13965
|
|
|
13960
|
-
function requireNewPool () {
|
|
13961
|
-
if (hasRequiredNewPool) return newPool_1;
|
|
13962
|
-
hasRequiredNewPool = 1;
|
|
13966
|
+
function requireNewPool$1 () {
|
|
13967
|
+
if (hasRequiredNewPool$1) return newPool_1$1;
|
|
13968
|
+
hasRequiredNewPool$1 = 1;
|
|
13963
13969
|
const promisify = requirePromisify();
|
|
13964
13970
|
const pools = requirePools();
|
|
13965
|
-
const end = requireEnd();
|
|
13971
|
+
const end = requireEnd$1();
|
|
13966
13972
|
const newGenericPool = requireNewGenericPool();
|
|
13967
13973
|
const newId = requireNewId();
|
|
13968
13974
|
|
|
@@ -13978,22 +13984,22 @@ function requireNewPool () {
|
|
|
13978
13984
|
return c;
|
|
13979
13985
|
}
|
|
13980
13986
|
|
|
13981
|
-
newPool_1 = newPool;
|
|
13982
|
-
return newPool_1;
|
|
13987
|
+
newPool_1$1 = newPool;
|
|
13988
|
+
return newPool_1$1;
|
|
13983
13989
|
}
|
|
13984
13990
|
|
|
13985
|
-
var newDatabase_1;
|
|
13986
|
-
var hasRequiredNewDatabase;
|
|
13991
|
+
var newDatabase_1$1;
|
|
13992
|
+
var hasRequiredNewDatabase$1;
|
|
13987
13993
|
|
|
13988
|
-
function requireNewDatabase () {
|
|
13989
|
-
if (hasRequiredNewDatabase) return newDatabase_1;
|
|
13990
|
-
hasRequiredNewDatabase = 1;
|
|
13994
|
+
function requireNewDatabase$1 () {
|
|
13995
|
+
if (hasRequiredNewDatabase$1) return newDatabase_1$1;
|
|
13996
|
+
hasRequiredNewDatabase$1 = 1;
|
|
13991
13997
|
let createDomain = requireCreateDomain();
|
|
13992
|
-
let newTransaction = requireNewTransaction();
|
|
13998
|
+
let newTransaction = requireNewTransaction$1();
|
|
13993
13999
|
let _begin = requireBegin();
|
|
13994
14000
|
let commit = requireCommit();
|
|
13995
14001
|
let rollback = requireRollback();
|
|
13996
|
-
let newPool = requireNewPool();
|
|
14002
|
+
let newPool = requireNewPool$1();
|
|
13997
14003
|
let express = requireHostExpress();
|
|
13998
14004
|
let hostLocal = requireHostLocal();
|
|
13999
14005
|
let doQuery = requireQuery();
|
|
@@ -14003,11 +14009,8 @@ function requireNewDatabase () {
|
|
|
14003
14009
|
function newDatabase(d1Database, poolOptions) {
|
|
14004
14010
|
if (!d1Database)
|
|
14005
14011
|
throw new Error('Missing d1Database');
|
|
14006
|
-
|
|
14007
|
-
|
|
14008
|
-
pool = newPool.bind(null,d1Database, poolOptions);
|
|
14009
|
-
else
|
|
14010
|
-
pool = newPool(d1Database, poolOptions);
|
|
14012
|
+
poolOptions = poolOptions || { min: 1 };
|
|
14013
|
+
var pool = newPool(d1Database, poolOptions);
|
|
14011
14014
|
|
|
14012
14015
|
let c = {poolFactory: pool, hostLocal, express};
|
|
14013
14016
|
|
|
@@ -14106,52 +14109,775 @@ function requireNewDatabase () {
|
|
|
14106
14109
|
return c;
|
|
14107
14110
|
}
|
|
14108
14111
|
|
|
14109
|
-
newDatabase_1 = newDatabase;
|
|
14110
|
-
return newDatabase_1;
|
|
14112
|
+
newDatabase_1$1 = newDatabase;
|
|
14113
|
+
return newDatabase_1$1;
|
|
14111
14114
|
}
|
|
14112
14115
|
|
|
14113
|
-
var
|
|
14114
|
-
var
|
|
14116
|
+
var replaceParamChar_1;
|
|
14117
|
+
var hasRequiredReplaceParamChar;
|
|
14115
14118
|
|
|
14116
|
-
function
|
|
14117
|
-
if (
|
|
14118
|
-
|
|
14119
|
-
|
|
14120
|
-
|
|
14121
|
-
|
|
14122
|
-
|
|
14123
|
-
|
|
14119
|
+
function requireReplaceParamChar () {
|
|
14120
|
+
if (hasRequiredReplaceParamChar) return replaceParamChar_1;
|
|
14121
|
+
hasRequiredReplaceParamChar = 1;
|
|
14122
|
+
function replaceParamChar(query, params) {
|
|
14123
|
+
if (params.length === 0)
|
|
14124
|
+
return query.sql();
|
|
14125
|
+
var splitted = query.sql().split('?');
|
|
14126
|
+
var sql = '';
|
|
14127
|
+
var lastIndex = splitted.length - 1;
|
|
14128
|
+
for (var i = 0; i < lastIndex; i++) {
|
|
14129
|
+
sql += splitted[i] + '$' + (i + 1);
|
|
14130
|
+
}
|
|
14131
|
+
sql += splitted[lastIndex];
|
|
14132
|
+
return sql;
|
|
14133
|
+
}
|
|
14124
14134
|
|
|
14125
|
-
|
|
14126
|
-
|
|
14127
|
-
|
|
14128
|
-
connectViaPool.createPatch = client.createPatch;
|
|
14129
|
-
connectViaPool.table = requireTable();
|
|
14130
|
-
connectViaPool.filter = requireEmptyFilter();
|
|
14131
|
-
connectViaPool.commit = requireCommit();
|
|
14132
|
-
connectViaPool.rollback = requireRollback();
|
|
14133
|
-
connectViaPool.end = requirePools().end;
|
|
14134
|
-
connectViaPool.log = requireLog().registerLogger;
|
|
14135
|
-
connectViaPool.on = requireLog().on;
|
|
14136
|
-
connectViaPool.off = requireLog().off;
|
|
14137
|
-
connectViaPool.query = requireQuery();
|
|
14138
|
-
connectViaPool.lock = requireLock();
|
|
14139
|
-
connectViaPool.schema = requireSchema();
|
|
14140
|
-
connectViaPool.map = map.bind(null, connectViaPool);
|
|
14135
|
+
replaceParamChar_1 = replaceParamChar;
|
|
14136
|
+
return replaceParamChar_1;
|
|
14137
|
+
}
|
|
14141
14138
|
|
|
14142
|
-
|
|
14143
|
-
|
|
14139
|
+
var wrapQuery_1;
|
|
14140
|
+
var hasRequiredWrapQuery;
|
|
14141
|
+
|
|
14142
|
+
function requireWrapQuery () {
|
|
14143
|
+
if (hasRequiredWrapQuery) return wrapQuery_1;
|
|
14144
|
+
hasRequiredWrapQuery = 1;
|
|
14145
|
+
var log = requireLog();
|
|
14146
|
+
var replaceParamChar = requireReplaceParamChar();
|
|
14147
|
+
|
|
14148
|
+
function wrapQuery(_context, connection) {
|
|
14149
|
+
var runOriginalQuery = connection.query;
|
|
14150
|
+
return runQuery;
|
|
14151
|
+
|
|
14152
|
+
function runQuery(query, onCompleted) {
|
|
14153
|
+
var params = query.parameters;
|
|
14154
|
+
var sql = replaceParamChar(query, params);
|
|
14155
|
+
log.emitQuery({sql, parameters: params});
|
|
14156
|
+
runOriginalQuery.call(connection, sql, params).then((result) => onInnerCompleted(null, result), (e) => onInnerCompleted(e));
|
|
14157
|
+
|
|
14158
|
+
function onInnerCompleted(err, result) {
|
|
14159
|
+
if (err)
|
|
14160
|
+
onCompleted(err);
|
|
14161
|
+
else {
|
|
14162
|
+
if (Array.isArray(result))
|
|
14163
|
+
result = result[result.length-1];
|
|
14164
|
+
onCompleted(null, result.rows);
|
|
14165
|
+
}
|
|
14166
|
+
}
|
|
14167
|
+
}
|
|
14168
|
+
|
|
14169
|
+
}
|
|
14170
|
+
|
|
14171
|
+
wrapQuery_1 = wrapQuery;
|
|
14172
|
+
return wrapQuery_1;
|
|
14173
|
+
}
|
|
14174
|
+
|
|
14175
|
+
var encodeDate_1;
|
|
14176
|
+
var hasRequiredEncodeDate;
|
|
14177
|
+
|
|
14178
|
+
function requireEncodeDate () {
|
|
14179
|
+
if (hasRequiredEncodeDate) return encodeDate_1;
|
|
14180
|
+
hasRequiredEncodeDate = 1;
|
|
14181
|
+
function encodeDate(date) {
|
|
14182
|
+
if (date.toISOString)
|
|
14183
|
+
return '\'' + date.toISOString() + '\'';
|
|
14184
|
+
return '\'' + date + '\'';
|
|
14185
|
+
}
|
|
14186
|
+
|
|
14187
|
+
encodeDate_1 = encodeDate;
|
|
14188
|
+
return encodeDate_1;
|
|
14189
|
+
}
|
|
14190
|
+
|
|
14191
|
+
var encodeBinary_1;
|
|
14192
|
+
var hasRequiredEncodeBinary;
|
|
14193
|
+
|
|
14194
|
+
function requireEncodeBinary () {
|
|
14195
|
+
if (hasRequiredEncodeBinary) return encodeBinary_1;
|
|
14196
|
+
hasRequiredEncodeBinary = 1;
|
|
14197
|
+
function encodeBinary(base64) {
|
|
14198
|
+
// Decode base64 to a binary string
|
|
14199
|
+
const binaryString = atob(base64);
|
|
14200
|
+
|
|
14201
|
+
// Create a new Uint8Array with the same length as the binary string
|
|
14202
|
+
const len = binaryString.length;
|
|
14203
|
+
const bytes = new Uint8Array(len);
|
|
14204
|
+
|
|
14205
|
+
// Populate the Uint8Array with numeric character codes
|
|
14206
|
+
for (let i = 0; i < len; i++) {
|
|
14207
|
+
bytes[i] = binaryString.charCodeAt(i);
|
|
14208
|
+
}
|
|
14209
|
+
|
|
14210
|
+
return bytes;
|
|
14211
|
+
}
|
|
14212
|
+
|
|
14213
|
+
encodeBinary_1 = encodeBinary;
|
|
14214
|
+
return encodeBinary_1;
|
|
14215
|
+
}
|
|
14216
|
+
|
|
14217
|
+
var decodeBinary_1;
|
|
14218
|
+
var hasRequiredDecodeBinary;
|
|
14219
|
+
|
|
14220
|
+
function requireDecodeBinary () {
|
|
14221
|
+
if (hasRequiredDecodeBinary) return decodeBinary_1;
|
|
14222
|
+
hasRequiredDecodeBinary = 1;
|
|
14223
|
+
function decodeBinary(u8Arr) {
|
|
14224
|
+
let binaryString = '';
|
|
14225
|
+
for (let i = 0; i < u8Arr.length; i++) {
|
|
14226
|
+
binaryString += String.fromCharCode(u8Arr[i]);
|
|
14227
|
+
}
|
|
14228
|
+
return btoa(binaryString);
|
|
14229
|
+
}
|
|
14230
|
+
|
|
14231
|
+
decodeBinary_1 = decodeBinary;
|
|
14232
|
+
return decodeBinary_1;
|
|
14233
|
+
}
|
|
14234
|
+
|
|
14235
|
+
var quote;
|
|
14236
|
+
var hasRequiredQuote;
|
|
14237
|
+
|
|
14238
|
+
function requireQuote () {
|
|
14239
|
+
if (hasRequiredQuote) return quote;
|
|
14240
|
+
hasRequiredQuote = 1;
|
|
14241
|
+
quote = (name) => `"${name}"`;
|
|
14242
|
+
return quote;
|
|
14243
|
+
}
|
|
14244
|
+
|
|
14245
|
+
var deleteFromSql_1;
|
|
14246
|
+
var hasRequiredDeleteFromSql;
|
|
14247
|
+
|
|
14248
|
+
function requireDeleteFromSql () {
|
|
14249
|
+
if (hasRequiredDeleteFromSql) return deleteFromSql_1;
|
|
14250
|
+
hasRequiredDeleteFromSql = 1;
|
|
14251
|
+
const format = 'delete from %s %s%s';
|
|
14252
|
+
const formatString = requireFormat();
|
|
14253
|
+
const quote = requireQuote();
|
|
14254
|
+
|
|
14255
|
+
function deleteFromSql(table, alias, whereSql) {
|
|
14256
|
+
const name = quote(table._dbName);
|
|
14257
|
+
alias = quote(alias);
|
|
14258
|
+
return formatString(format, name, alias, whereSql);
|
|
14259
|
+
}
|
|
14260
|
+
deleteFromSql_1 = deleteFromSql;
|
|
14261
|
+
return deleteFromSql_1;
|
|
14262
|
+
}
|
|
14263
|
+
|
|
14264
|
+
var selectForUpdateSql;
|
|
14265
|
+
var hasRequiredSelectForUpdateSql;
|
|
14266
|
+
|
|
14267
|
+
function requireSelectForUpdateSql () {
|
|
14268
|
+
if (hasRequiredSelectForUpdateSql) return selectForUpdateSql;
|
|
14269
|
+
hasRequiredSelectForUpdateSql = 1;
|
|
14270
|
+
const quote = requireQuote$2();
|
|
14271
|
+
|
|
14272
|
+
selectForUpdateSql = function(alias) {
|
|
14273
|
+
return ' FOR UPDATE OF ' + quote(alias);
|
|
14144
14274
|
};
|
|
14275
|
+
return selectForUpdateSql;
|
|
14276
|
+
}
|
|
14145
14277
|
|
|
14278
|
+
var limitAndOffset_1;
|
|
14279
|
+
var hasRequiredLimitAndOffset;
|
|
14146
14280
|
|
|
14147
|
-
|
|
14148
|
-
|
|
14149
|
-
|
|
14150
|
-
|
|
14281
|
+
function requireLimitAndOffset () {
|
|
14282
|
+
if (hasRequiredLimitAndOffset) return limitAndOffset_1;
|
|
14283
|
+
hasRequiredLimitAndOffset = 1;
|
|
14284
|
+
function limitAndOffset(span) {
|
|
14285
|
+
if (span.offset)
|
|
14286
|
+
return ` limit ${limit()} offset ${span.offset}`;
|
|
14287
|
+
else if (span.limit || span.limit === 0)
|
|
14288
|
+
return ` limit ${span.limit}`;
|
|
14289
|
+
else
|
|
14290
|
+
return '';
|
|
14291
|
+
|
|
14292
|
+
function limit() {
|
|
14293
|
+
if (span.limit || span.limit === 0)
|
|
14294
|
+
return span.limit;
|
|
14295
|
+
else
|
|
14296
|
+
return 'all';
|
|
14297
|
+
}
|
|
14298
|
+
|
|
14299
|
+
}
|
|
14300
|
+
|
|
14301
|
+
limitAndOffset_1 = limitAndOffset;
|
|
14302
|
+
return limitAndOffset_1;
|
|
14303
|
+
}
|
|
14304
|
+
|
|
14305
|
+
var formatDateOut_1;
|
|
14306
|
+
var hasRequiredFormatDateOut;
|
|
14307
|
+
|
|
14308
|
+
function requireFormatDateOut () {
|
|
14309
|
+
if (hasRequiredFormatDateOut) return formatDateOut_1;
|
|
14310
|
+
hasRequiredFormatDateOut = 1;
|
|
14311
|
+
function formatDateOut(column, alias) {
|
|
14312
|
+
return `${alias}."${(column._dbName)}"::text`;
|
|
14313
|
+
}
|
|
14314
|
+
|
|
14315
|
+
formatDateOut_1 = formatDateOut;
|
|
14316
|
+
return formatDateOut_1;
|
|
14317
|
+
}
|
|
14318
|
+
|
|
14319
|
+
var lastInsertedSql_1;
|
|
14320
|
+
var hasRequiredLastInsertedSql;
|
|
14321
|
+
|
|
14322
|
+
function requireLastInsertedSql () {
|
|
14323
|
+
if (hasRequiredLastInsertedSql) return lastInsertedSql_1;
|
|
14324
|
+
hasRequiredLastInsertedSql = 1;
|
|
14325
|
+
const quote = requireQuote();
|
|
14326
|
+
|
|
14327
|
+
function lastInsertedSql(table) {
|
|
14328
|
+
let separator = '';
|
|
14329
|
+
let result = 'RETURNING ';
|
|
14330
|
+
for (let i = 0; i < table._columns.length; i++) {
|
|
14331
|
+
result += separator + quote(table._columns[i]._dbName);
|
|
14332
|
+
separator = ',';
|
|
14333
|
+
}
|
|
14334
|
+
return result;
|
|
14335
|
+
}
|
|
14336
|
+
|
|
14337
|
+
lastInsertedSql_1 = lastInsertedSql;
|
|
14338
|
+
return lastInsertedSql_1;
|
|
14339
|
+
}
|
|
14340
|
+
|
|
14341
|
+
var insertSql_1;
|
|
14342
|
+
var hasRequiredInsertSql;
|
|
14343
|
+
|
|
14344
|
+
function requireInsertSql () {
|
|
14345
|
+
if (hasRequiredInsertSql) return insertSql_1;
|
|
14346
|
+
hasRequiredInsertSql = 1;
|
|
14347
|
+
let lastInsertedSql = requireLastInsertedSql();
|
|
14348
|
+
const quote = requireQuote();
|
|
14349
|
+
|
|
14350
|
+
function insertSql(_context, table, row, options) {
|
|
14351
|
+
let columnNames = [];
|
|
14352
|
+
let conflictColumnUpdateSql = '';
|
|
14353
|
+
let values = [];
|
|
14354
|
+
let sql = 'INSERT INTO ' + quote(table._dbName) + ' ';
|
|
14355
|
+
addDiscriminators();
|
|
14356
|
+
addColumns();
|
|
14357
|
+
if (columnNames.length === 0)
|
|
14358
|
+
sql += `${outputInserted()}DEFAULT VALUES ${lastInsertedSql(table)}`;
|
|
14359
|
+
else
|
|
14360
|
+
sql = sql + '(' + columnNames.join(',') + ') ' + outputInserted() + 'VALUES (' + values.join(',') + ')' + onConflict() + lastInsertedSql(table);
|
|
14361
|
+
return sql;
|
|
14362
|
+
|
|
14363
|
+
function onConflict() {
|
|
14364
|
+
if (options.concurrency === 'skipOnConflict' || options.concurrency === 'overwrite') {
|
|
14365
|
+
const primaryKeys = table._primaryColumns.map(x => quote(x._dbName)).join(',');
|
|
14366
|
+
return ` ON CONFLICT(${primaryKeys}) ${conflictColumnUpdateSql} `;
|
|
14367
|
+
}
|
|
14368
|
+
else return '';
|
|
14369
|
+
}
|
|
14370
|
+
|
|
14371
|
+
function addDiscriminators() {
|
|
14372
|
+
let discriminators = table._columnDiscriminators;
|
|
14373
|
+
for (let i = 0; i < discriminators.length; i++) {
|
|
14374
|
+
let parts = discriminators[i].split('=');
|
|
14375
|
+
columnNames.push(quote(parts[0]));
|
|
14376
|
+
values.push(parts[1]);
|
|
14377
|
+
}
|
|
14378
|
+
}
|
|
14379
|
+
|
|
14380
|
+
function addColumns() {
|
|
14381
|
+
let conflictColumnUpdates = [];
|
|
14382
|
+
let columns = table._columns;
|
|
14383
|
+
for (let i = 0; i < columns.length; i++) {
|
|
14384
|
+
let column = columns[i];
|
|
14385
|
+
const columnName = quote(column._dbName);
|
|
14386
|
+
if (row['__' + column.alias] !== undefined) {
|
|
14387
|
+
columnNames.push(columnName);
|
|
14388
|
+
values.push('%s');
|
|
14389
|
+
addConflictUpdate(column);
|
|
14390
|
+
}
|
|
14391
|
+
}
|
|
14392
|
+
if (conflictColumnUpdates.length === 0)
|
|
14393
|
+
conflictColumnUpdateSql = 'DO NOTHING';
|
|
14394
|
+
else
|
|
14395
|
+
conflictColumnUpdateSql = 'DO UPDATE SET ' + conflictColumnUpdates.join(',');
|
|
14396
|
+
|
|
14397
|
+
function addConflictUpdate(column) {
|
|
14398
|
+
let concurrency = options[column.alias]?.concurrency || options.concurrency;
|
|
14399
|
+
const columnName = quote(column._dbName);
|
|
14400
|
+
const tableName = quote(table._dbName);
|
|
14401
|
+
if (concurrency === 'overwrite')
|
|
14402
|
+
conflictColumnUpdates.push(`${columnName}=EXCLUDED.${columnName}`);
|
|
14403
|
+
else if (concurrency === 'optimistic')
|
|
14404
|
+
conflictColumnUpdates.push(`${columnName} = CASE WHEN ${tableName}.${columnName} <> EXCLUDED.${columnName} THEN CAST(random()::int || '12345678-1234-1234-1234-123456789012Conflict when updating ${columnName}12345678-1234-1234-1234-123456789012' AS INTEGER) ELSE ${tableName}.${columnName} END`);
|
|
14405
|
+
}
|
|
14406
|
+
}
|
|
14407
|
+
|
|
14408
|
+
|
|
14409
|
+
function outputInserted() {
|
|
14410
|
+
return '';
|
|
14411
|
+
}
|
|
14412
|
+
}
|
|
14413
|
+
|
|
14414
|
+
insertSql_1 = insertSql;
|
|
14415
|
+
return insertSql_1;
|
|
14416
|
+
}
|
|
14417
|
+
|
|
14418
|
+
var insert;
|
|
14419
|
+
var hasRequiredInsert;
|
|
14420
|
+
|
|
14421
|
+
function requireInsert () {
|
|
14422
|
+
if (hasRequiredInsert) return insert;
|
|
14423
|
+
hasRequiredInsert = 1;
|
|
14424
|
+
let newInsertCommand = requireNewInsertCommand();
|
|
14425
|
+
let newInsertCommandCore = requireNewInsertCommandCore();
|
|
14426
|
+
let executeQueries = requireExecuteQueries();
|
|
14427
|
+
|
|
14428
|
+
|
|
14429
|
+
function insertDefault(context, table, row, options) {
|
|
14430
|
+
let insertCmd = newInsertCommand(newInsertCommandCore.bind(null, context), table, row, options);
|
|
14431
|
+
insertCmd.disallowCompress = true;
|
|
14432
|
+
|
|
14433
|
+
return executeQueries(context, [insertCmd]).then((result) => result[result.length - 1]);
|
|
14434
|
+
|
|
14435
|
+
}
|
|
14436
|
+
|
|
14437
|
+
insert = insertDefault;
|
|
14438
|
+
return insert;
|
|
14439
|
+
}
|
|
14440
|
+
|
|
14441
|
+
var newTransaction;
|
|
14442
|
+
var hasRequiredNewTransaction;
|
|
14443
|
+
|
|
14444
|
+
function requireNewTransaction () {
|
|
14445
|
+
if (hasRequiredNewTransaction) return newTransaction;
|
|
14446
|
+
hasRequiredNewTransaction = 1;
|
|
14447
|
+
var wrapQuery = requireWrapQuery();
|
|
14448
|
+
var encodeDate = requireEncodeDate();
|
|
14449
|
+
const encodeBinary = requireEncodeBinary();
|
|
14450
|
+
const decodeBinary = requireDecodeBinary();
|
|
14451
|
+
var deleteFromSql = requireDeleteFromSql();
|
|
14452
|
+
var selectForUpdateSql = requireSelectForUpdateSql();
|
|
14453
|
+
var limitAndOffset = requireLimitAndOffset();
|
|
14454
|
+
var formatDateOut = requireFormatDateOut();
|
|
14455
|
+
var insertSql = requireInsertSql();
|
|
14456
|
+
var insert = requireInsert();
|
|
14457
|
+
var quote = requireQuote();
|
|
14458
|
+
|
|
14459
|
+
function newResolveTransaction(domain, pool, { readonly = false } = {}) {
|
|
14460
|
+
var rdb = { poolFactory: pool };
|
|
14461
|
+
if (!pool.connect)
|
|
14462
|
+
pool = pool();
|
|
14463
|
+
|
|
14464
|
+
rdb.engine = 'pg';
|
|
14465
|
+
rdb.encodeDate = encodeDate;
|
|
14466
|
+
rdb.encodeBinary = encodeBinary;
|
|
14467
|
+
rdb.decodeBinary = decodeBinary;
|
|
14468
|
+
rdb.formatDateOut = formatDateOut;
|
|
14469
|
+
rdb.deleteFromSql = deleteFromSql;
|
|
14470
|
+
rdb.selectForUpdateSql = selectForUpdateSql;
|
|
14471
|
+
rdb.lastInsertedIsSeparate = false;
|
|
14472
|
+
rdb.insertSql = insertSql;
|
|
14473
|
+
rdb.insert = insert;
|
|
14474
|
+
rdb.multipleStatements = true;
|
|
14475
|
+
rdb.limitAndOffset = limitAndOffset;
|
|
14476
|
+
rdb.accept = function(caller) {
|
|
14477
|
+
caller.visitPg();
|
|
14478
|
+
};
|
|
14479
|
+
rdb.aggregateCount = 0;
|
|
14480
|
+
rdb.quote = quote;
|
|
14481
|
+
rdb.cache = {};
|
|
14482
|
+
|
|
14483
|
+
if (readonly) {
|
|
14484
|
+
rdb.dbClient = {
|
|
14485
|
+
executeQuery: function(query, callback) {
|
|
14486
|
+
pool.connect((err, client, done) => {
|
|
14487
|
+
if (err) {
|
|
14488
|
+
return callback(err);
|
|
14489
|
+
}
|
|
14490
|
+
try {
|
|
14491
|
+
wrapQuery(domain, client)(query, (err, res) => {
|
|
14492
|
+
done();
|
|
14493
|
+
callback(err, res);
|
|
14494
|
+
});
|
|
14495
|
+
} catch (e) {
|
|
14496
|
+
done();
|
|
14497
|
+
callback(e);
|
|
14498
|
+
}
|
|
14499
|
+
});
|
|
14500
|
+
}
|
|
14501
|
+
};
|
|
14502
|
+
domain.rdb = rdb;
|
|
14503
|
+
return (onSuccess) => onSuccess();
|
|
14504
|
+
}
|
|
14505
|
+
|
|
14506
|
+
return function(onSuccess, onError) {
|
|
14507
|
+
pool.connect(onConnected);
|
|
14508
|
+
|
|
14509
|
+
function onConnected(err, client, done) {
|
|
14510
|
+
try {
|
|
14511
|
+
if (err) {
|
|
14512
|
+
onError(err);
|
|
14513
|
+
return;
|
|
14514
|
+
}
|
|
14515
|
+
client.executeQuery = wrapQuery(domain, client);
|
|
14516
|
+
rdb.dbClient = client;
|
|
14517
|
+
rdb.dbClientDone = done;
|
|
14518
|
+
domain.rdb = rdb;
|
|
14519
|
+
onSuccess();
|
|
14520
|
+
} catch (e) {
|
|
14521
|
+
onError(e);
|
|
14522
|
+
}
|
|
14523
|
+
}
|
|
14524
|
+
};
|
|
14525
|
+
}
|
|
14526
|
+
|
|
14527
|
+
newTransaction = newResolveTransaction;
|
|
14528
|
+
return newTransaction;
|
|
14529
|
+
}
|
|
14530
|
+
|
|
14531
|
+
var end;
|
|
14532
|
+
var hasRequiredEnd;
|
|
14533
|
+
|
|
14534
|
+
function requireEnd () {
|
|
14535
|
+
if (hasRequiredEnd) return end;
|
|
14536
|
+
hasRequiredEnd = 1;
|
|
14537
|
+
var pools = requirePools();
|
|
14538
|
+
|
|
14539
|
+
function endPool(pgPool, id, done) {
|
|
14540
|
+
pgPool.drain(onDrained);
|
|
14541
|
+
|
|
14542
|
+
function onDrained() {
|
|
14543
|
+
//todo await
|
|
14544
|
+
pgPool.destroyAllNow();
|
|
14545
|
+
delete pools[id];
|
|
14546
|
+
done();
|
|
14547
|
+
}
|
|
14548
|
+
}
|
|
14549
|
+
|
|
14550
|
+
end = endPool;
|
|
14551
|
+
return end;
|
|
14552
|
+
}
|
|
14553
|
+
|
|
14554
|
+
/* eslint-disable no-prototype-builtins */
|
|
14555
|
+
|
|
14556
|
+
var newPgPool_1;
|
|
14557
|
+
var hasRequiredNewPgPool;
|
|
14558
|
+
|
|
14559
|
+
function requireNewPgPool () {
|
|
14560
|
+
if (hasRequiredNewPgPool) return newPgPool_1;
|
|
14561
|
+
hasRequiredNewPgPool = 1;
|
|
14562
|
+
// Simplified pool creator using URL API and handling search_path param
|
|
14563
|
+
|
|
14564
|
+
const log = requireLog();
|
|
14565
|
+
const defaults = requirePoolDefaults();
|
|
14566
|
+
const genericPool = requireGenericPool();
|
|
14567
|
+
let PGlite;
|
|
14568
|
+
|
|
14569
|
+
function newPgPool(connectionString, poolOptions = {}) {
|
|
14570
|
+
let { connStr, searchPath } = extractSearchPath(connectionString);
|
|
14571
|
+
|
|
14572
|
+
//@ts-ignore
|
|
14573
|
+
const pool = genericPool.Pool({
|
|
14574
|
+
min: poolOptions.min || 0,
|
|
14575
|
+
max: poolOptions.size || poolOptions.poolSize || defaults.poolSize,
|
|
14576
|
+
idleTimeoutMillis: poolOptions.idleTimeout || defaults.poolIdleTimeout,
|
|
14577
|
+
reapIntervalMillis: poolOptions.reapIntervalMillis || defaults.reapIntervalMillis,
|
|
14578
|
+
log: poolOptions.log,
|
|
14579
|
+
|
|
14580
|
+
create: async (cb) => {
|
|
14581
|
+
try {
|
|
14582
|
+
if (!PGlite) ({ PGlite } = await import('@electric-sql/pglite'));
|
|
14583
|
+
const client = connStr === undefined ? new PGlite() : new PGlite(connStr);
|
|
14584
|
+
client.poolCount = 0;
|
|
14585
|
+
await applySearchPath(client, searchPath);
|
|
14586
|
+
cb(null, client);
|
|
14587
|
+
} catch (err) {
|
|
14588
|
+
cb(err, null);
|
|
14589
|
+
}
|
|
14590
|
+
},
|
|
14591
|
+
|
|
14592
|
+
destroy: (client) => {
|
|
14593
|
+
client._destroying = true;
|
|
14594
|
+
client.poolCount = undefined;
|
|
14595
|
+
client.close();
|
|
14596
|
+
},
|
|
14597
|
+
});
|
|
14598
|
+
|
|
14599
|
+
pool.connect = (cb) => {
|
|
14600
|
+
pool.acquire((err, client) => {
|
|
14601
|
+
if (err) return cb(err, null, () => { });
|
|
14602
|
+
client.poolCount++;
|
|
14603
|
+
cb(null, client, (releaseErr) => {
|
|
14604
|
+
releaseErr ? pool.destroy(client) : pool.release(client);
|
|
14605
|
+
});
|
|
14606
|
+
});
|
|
14607
|
+
};
|
|
14608
|
+
|
|
14609
|
+
return pool;
|
|
14610
|
+
}
|
|
14611
|
+
|
|
14612
|
+
async function applySearchPath(client, searchPath) {
|
|
14613
|
+
if (searchPath) {
|
|
14614
|
+
const sql = `SET search_path TO ${searchPath}`;
|
|
14615
|
+
log.emitQuery({ sql, parameters: [] });
|
|
14616
|
+
await client.exec(sql);
|
|
14617
|
+
}
|
|
14618
|
+
}
|
|
14619
|
+
|
|
14620
|
+
function extractSearchPath(connectionString) {
|
|
14621
|
+
let connStr = connectionString;
|
|
14622
|
+
let searchPath;
|
|
14623
|
+
|
|
14624
|
+
// Guard: nothing to do
|
|
14625
|
+
if (typeof connectionString !== 'string' || connectionString.length === 0) {
|
|
14626
|
+
return { connStr, searchPath };
|
|
14627
|
+
}
|
|
14628
|
+
|
|
14629
|
+
// Split on the *first* "?" only
|
|
14630
|
+
const qPos = connectionString.indexOf('?');
|
|
14631
|
+
if (qPos === -1) {
|
|
14632
|
+
// No query-string segment
|
|
14633
|
+
return { connStr, searchPath };
|
|
14634
|
+
}
|
|
14635
|
+
|
|
14636
|
+
const pathPart = connectionString.slice(0, qPos);
|
|
14637
|
+
const qsPart = connectionString.slice(qPos + 1);
|
|
14638
|
+
|
|
14639
|
+
// Robust query-string handling via URLSearchParams
|
|
14640
|
+
const params = new URLSearchParams(qsPart);
|
|
14641
|
+
|
|
14642
|
+
const paramName = 'search_path';
|
|
14643
|
+
|
|
14644
|
+
{
|
|
14645
|
+
searchPath = params.get(paramName);
|
|
14646
|
+
params.delete(paramName);
|
|
14647
|
+
}
|
|
14648
|
+
|
|
14649
|
+
// Re-assemble the cleaned connection string
|
|
14650
|
+
const remainingQs = params.toString();
|
|
14651
|
+
connStr = remainingQs ? `${pathPart}?${remainingQs}` : pathPart;
|
|
14652
|
+
|
|
14653
|
+
return { connStr, searchPath };
|
|
14654
|
+
}
|
|
14655
|
+
|
|
14656
|
+
|
|
14657
|
+
newPgPool_1 = newPgPool;
|
|
14658
|
+
return newPgPool_1;
|
|
14659
|
+
}
|
|
14660
|
+
|
|
14661
|
+
var newPool_1;
|
|
14662
|
+
var hasRequiredNewPool;
|
|
14663
|
+
|
|
14664
|
+
function requireNewPool () {
|
|
14665
|
+
if (hasRequiredNewPool) return newPool_1;
|
|
14666
|
+
hasRequiredNewPool = 1;
|
|
14667
|
+
const promisify = requirePromisify();
|
|
14668
|
+
const pools = requirePools();
|
|
14669
|
+
const end = requireEnd();
|
|
14670
|
+
const newPgPool = requireNewPgPool();
|
|
14671
|
+
const newId = requireNewId();
|
|
14672
|
+
|
|
14673
|
+
function newPool(connectionString, poolOptions) {
|
|
14674
|
+
let pool = newPgPool(connectionString, poolOptions);
|
|
14675
|
+
let id = newId();
|
|
14676
|
+
let boundEnd = end.bind(null, pool, id);
|
|
14677
|
+
let c = {};
|
|
14678
|
+
|
|
14679
|
+
c.connect = pool.connect;
|
|
14680
|
+
c.end = promisify(boundEnd);
|
|
14681
|
+
pools[id] = c;
|
|
14682
|
+
return c;
|
|
14683
|
+
}
|
|
14684
|
+
|
|
14685
|
+
newPool_1 = newPool;
|
|
14686
|
+
return newPool_1;
|
|
14687
|
+
}
|
|
14688
|
+
|
|
14689
|
+
var newDatabase_1;
|
|
14690
|
+
var hasRequiredNewDatabase;
|
|
14691
|
+
|
|
14692
|
+
function requireNewDatabase () {
|
|
14693
|
+
if (hasRequiredNewDatabase) return newDatabase_1;
|
|
14694
|
+
hasRequiredNewDatabase = 1;
|
|
14695
|
+
let createDomain = requireCreateDomain();
|
|
14696
|
+
let newTransaction = requireNewTransaction();
|
|
14697
|
+
let _begin = requireBegin();
|
|
14698
|
+
let commit = requireCommit();
|
|
14699
|
+
let rollback = requireRollback();
|
|
14700
|
+
let newPool = requireNewPool();
|
|
14701
|
+
let lock = requireLock();
|
|
14702
|
+
let executeSchema = requireSchema();
|
|
14703
|
+
let express = requireHostExpress();
|
|
14704
|
+
let hostLocal = requireHostLocal();
|
|
14705
|
+
let doQuery = requireQuery();
|
|
14706
|
+
let releaseDbClient = requireReleaseDbClient();
|
|
14707
|
+
let setSessionSingleton = requireSetSessionSingleton();
|
|
14708
|
+
|
|
14709
|
+
function newDatabase(connectionString, poolOptions) {
|
|
14710
|
+
poolOptions = poolOptions || { min: 1 };
|
|
14711
|
+
var pool = newPool(connectionString, poolOptions);
|
|
14712
|
+
|
|
14713
|
+
let c = { poolFactory: pool, hostLocal, express };
|
|
14714
|
+
|
|
14715
|
+
c.transaction = function(options, fn) {
|
|
14716
|
+
if ((arguments.length === 1) && (typeof options === 'function')) {
|
|
14717
|
+
fn = options;
|
|
14718
|
+
options = undefined;
|
|
14719
|
+
}
|
|
14720
|
+
let domain = createDomain();
|
|
14721
|
+
|
|
14722
|
+
if (fn)
|
|
14723
|
+
return domain.run(runInTransaction);
|
|
14724
|
+
else
|
|
14725
|
+
return domain.run(run);
|
|
14726
|
+
|
|
14727
|
+
async function runInTransaction() {
|
|
14728
|
+
let result;
|
|
14729
|
+
let transaction = newTransaction(domain, pool, options);
|
|
14730
|
+
await new Promise(transaction)
|
|
14731
|
+
.then(begin)
|
|
14732
|
+
.then(negotiateSchema)
|
|
14733
|
+
.then(() => fn(domain))
|
|
14734
|
+
.then((res) => result = res)
|
|
14735
|
+
.then(() => commit(domain))
|
|
14736
|
+
.then(null, (e) => rollback(domain,e));
|
|
14737
|
+
return result;
|
|
14738
|
+
}
|
|
14739
|
+
|
|
14740
|
+
function begin() {
|
|
14741
|
+
return _begin(domain, options);
|
|
14742
|
+
}
|
|
14743
|
+
|
|
14744
|
+
function run() {
|
|
14745
|
+
let p;
|
|
14746
|
+
let transaction = newTransaction(domain, pool, options);
|
|
14747
|
+
p = new Promise(transaction);
|
|
14748
|
+
|
|
14749
|
+
return p.then(begin)
|
|
14750
|
+
.then(negotiateSchema);
|
|
14751
|
+
}
|
|
14752
|
+
|
|
14753
|
+
function negotiateSchema(previous) {
|
|
14754
|
+
let schema = options && options.schema;
|
|
14755
|
+
if (!schema)
|
|
14756
|
+
return previous;
|
|
14757
|
+
return executeSchema(domain, schema);
|
|
14758
|
+
}
|
|
14759
|
+
};
|
|
14760
|
+
|
|
14761
|
+
c.createTransaction = function(options) {
|
|
14762
|
+
let domain = createDomain();
|
|
14763
|
+
let transaction = newTransaction(domain, pool, options);
|
|
14764
|
+
let p = domain.run(() => new Promise(transaction)
|
|
14765
|
+
.then(begin).then(negotiateSchema));
|
|
14766
|
+
|
|
14767
|
+
function run(fn) {
|
|
14768
|
+
return p.then(domain.run.bind(domain, fn));
|
|
14769
|
+
}
|
|
14770
|
+
|
|
14771
|
+
function begin() {
|
|
14772
|
+
return _begin(domain, options);
|
|
14773
|
+
}
|
|
14774
|
+
|
|
14775
|
+
function negotiateSchema(previous) {
|
|
14776
|
+
let schema = options && options.schema;
|
|
14777
|
+
if (!schema)
|
|
14778
|
+
return previous;
|
|
14779
|
+
return executeSchema(domain,schema);
|
|
14780
|
+
}
|
|
14781
|
+
|
|
14782
|
+
run.rollback = rollback.bind(null, domain);
|
|
14783
|
+
run.commit = commit.bind(null, domain);
|
|
14784
|
+
|
|
14785
|
+
return run;
|
|
14786
|
+
};
|
|
14787
|
+
|
|
14788
|
+
c.query = function(query) {
|
|
14789
|
+
let domain = createDomain();
|
|
14790
|
+
let transaction = newTransaction(domain, pool);
|
|
14791
|
+
let p = domain.run(() => new Promise(transaction)
|
|
14792
|
+
.then(() => setSessionSingleton(domain, 'changes', []))
|
|
14793
|
+
.then(() => doQuery(domain, query).then(onResult, onError)));
|
|
14794
|
+
return p;
|
|
14795
|
+
|
|
14796
|
+
function onResult(result) {
|
|
14797
|
+
releaseDbClient(domain);
|
|
14798
|
+
return result;
|
|
14799
|
+
}
|
|
14800
|
+
|
|
14801
|
+
function onError(e) {
|
|
14802
|
+
releaseDbClient(domain);
|
|
14803
|
+
throw e;
|
|
14804
|
+
}
|
|
14805
|
+
};
|
|
14806
|
+
|
|
14807
|
+
c.rollback = rollback;
|
|
14808
|
+
c.commit = commit;
|
|
14809
|
+
c.lock = lock;
|
|
14810
|
+
c.schema = executeSchema;
|
|
14811
|
+
|
|
14812
|
+
c.end = function() {
|
|
14813
|
+
if (poolOptions)
|
|
14814
|
+
return pool.end();
|
|
14815
|
+
else
|
|
14816
|
+
return Promise.resolve();
|
|
14817
|
+
};
|
|
14818
|
+
|
|
14819
|
+
c.accept = function(caller) {
|
|
14820
|
+
caller.visitPg();
|
|
14821
|
+
};
|
|
14822
|
+
|
|
14823
|
+
return c;
|
|
14824
|
+
}
|
|
14825
|
+
|
|
14826
|
+
newDatabase_1 = newDatabase;
|
|
14827
|
+
return newDatabase_1;
|
|
14828
|
+
}
|
|
14829
|
+
|
|
14830
|
+
var indexBrowser$1;
|
|
14831
|
+
var hasRequiredIndexBrowser;
|
|
14832
|
+
|
|
14833
|
+
function requireIndexBrowser () {
|
|
14834
|
+
if (hasRequiredIndexBrowser) return indexBrowser$1;
|
|
14835
|
+
hasRequiredIndexBrowser = 1;
|
|
14836
|
+
const hostExpress = requireHostExpress();
|
|
14837
|
+
const hostLocal = requireHostLocal();
|
|
14838
|
+
const client = requireClient();
|
|
14839
|
+
const map = requireMap();
|
|
14840
|
+
let _d1;
|
|
14841
|
+
let _pglite;
|
|
14842
|
+
|
|
14843
|
+
var connectViaPool = function() {
|
|
14844
|
+
return client.apply(null, arguments);
|
|
14845
|
+
};
|
|
14846
|
+
connectViaPool.createPatch = client.createPatch;
|
|
14847
|
+
connectViaPool.table = requireTable();
|
|
14848
|
+
connectViaPool.filter = requireEmptyFilter();
|
|
14849
|
+
connectViaPool.commit = requireCommit();
|
|
14850
|
+
connectViaPool.rollback = requireRollback();
|
|
14851
|
+
connectViaPool.end = requirePools().end;
|
|
14852
|
+
connectViaPool.log = requireLog().registerLogger;
|
|
14853
|
+
connectViaPool.on = requireLog().on;
|
|
14854
|
+
connectViaPool.off = requireLog().off;
|
|
14855
|
+
connectViaPool.query = requireQuery();
|
|
14856
|
+
connectViaPool.lock = requireLock();
|
|
14857
|
+
connectViaPool.schema = requireSchema();
|
|
14858
|
+
connectViaPool.map = map.bind(null, connectViaPool);
|
|
14859
|
+
|
|
14860
|
+
connectViaPool.http = function(url) {
|
|
14861
|
+
return url;
|
|
14862
|
+
};
|
|
14863
|
+
|
|
14864
|
+
|
|
14865
|
+
Object.defineProperty(connectViaPool, 'd1', {
|
|
14866
|
+
get: function() {
|
|
14867
|
+
if (!_d1)
|
|
14868
|
+
_d1 = requireNewDatabase$1();
|
|
14151
14869
|
return _d1;
|
|
14152
14870
|
}
|
|
14153
14871
|
});
|
|
14154
14872
|
|
|
14873
|
+
Object.defineProperty(connectViaPool, 'pglite', {
|
|
14874
|
+
get: function() {
|
|
14875
|
+
if (!_pglite)
|
|
14876
|
+
_pglite = requireNewDatabase();
|
|
14877
|
+
return _pglite;
|
|
14878
|
+
}
|
|
14879
|
+
});
|
|
14880
|
+
|
|
14155
14881
|
connectViaPool.express = hostExpress.bind(null, hostLocal);
|
|
14156
14882
|
|
|
14157
14883
|
indexBrowser$1 = connectViaPool;
|