remult 3.4.2 → 3.5.0-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/internals.js +1 -0
- package/esm/postgres/postgres-data-provider.js +4 -5
- package/esm/remult-duckdb.js +4 -0
- package/esm/remult-knex/index.js +69 -14
- package/esm/remult-mongo.js +25 -7
- package/esm/remult-sqlite-core.js +4 -1
- package/esm/server/remult-api-server.js +14 -6
- package/esm/src/buildRestDataProvider.js +8 -6
- package/esm/src/context.js +1 -1
- package/esm/src/data-api.js +2 -2
- package/esm/src/data-interfaces.js +2 -1
- package/esm/src/data-providers/array-entity-data-provider.js +9 -4
- package/esm/src/data-providers/rest-data-provider-using-fetch.js +13 -6
- package/esm/src/data-providers/retry.js +11 -6
- package/esm/src/data-providers/sql-database.js +40 -30
- package/esm/src/filter/filter-consumer-bridge-to-sql-request.js +35 -4
- package/esm/src/filter/filter-interfaces.js +18 -4
- package/esm/src/live-query/SubscriptionChannel.js +13 -8
- package/esm/src/remult-proxy.js +12 -0
- package/esm/src/remult-static.js +2 -0
- package/esm/src/remult3/Fields.js +14 -14
- package/esm/src/remult3/RepositoryImplementation.js +69 -32
- package/esm/src/remult3/remult3.js +2 -0
- package/esm/src/server-action.js +43 -14
- package/esm/src/sort.js +18 -0
- package/index.d.ts +4 -3
- package/internals.d.ts +1 -0
- package/internals.js +3 -1
- package/package.json +41 -1
- package/postgres/postgres-data-provider.d.ts +2 -3
- package/postgres/postgres-data-provider.js +4 -4
- package/remult-duckdb.d.ts +2 -0
- package/remult-duckdb.js +4 -0
- package/remult-knex/index.d.ts +2 -0
- package/remult-knex/index.js +153 -83
- package/remult-mongo.js +28 -7
- package/remult-sqlite-core.d.ts +2 -1
- package/remult-sqlite-core.js +4 -0
- package/server/remult-api-server.d.ts +28 -1
- package/server/remult-api-server.js +19 -12
- package/src/buildRestDataProvider.d.ts +1 -1
- package/src/buildRestDataProvider.js +8 -6
- package/src/column-interfaces.d.ts +5 -1
- package/src/context.js +1 -1
- package/src/data-api.js +2 -2
- package/src/data-interfaces.d.ts +0 -1
- package/src/data-interfaces.js +3 -0
- package/src/data-providers/array-entity-data-provider.js +9 -4
- package/src/data-providers/rest-data-provider-using-fetch.d.ts +1 -1
- package/src/data-providers/rest-data-provider-using-fetch.js +11 -4
- package/src/data-providers/retry.d.ts +4 -1
- package/src/data-providers/retry.js +26 -16
- package/src/data-providers/sql-database.d.ts +7 -3
- package/src/data-providers/sql-database.js +99 -81
- package/src/filter/filter-consumer-bridge-to-sql-request.d.ts +8 -0
- package/src/filter/filter-consumer-bridge-to-sql-request.js +58 -19
- package/src/filter/filter-interfaces.js +19 -2
- package/src/live-query/SubscriptionChannel.js +16 -10
- package/src/remult-proxy.js +28 -0
- package/src/remult-static.d.ts +4 -0
- package/src/remult-static.js +2 -0
- package/src/remult3/Fields.d.ts +5 -3
- package/src/remult3/Fields.js +24 -13
- package/src/remult3/RepositoryImplementation.d.ts +7 -0
- package/src/remult3/RepositoryImplementation.js +325 -264
- package/src/remult3/remult3.d.ts +68 -5
- package/src/remult3/remult3.js +2 -0
- package/src/server-action.d.ts +34 -2
- package/src/server-action.js +195 -115
- package/src/sort.d.ts +19 -0
- package/src/sort.js +20 -1
- package/src/sql-command.d.ts +2 -1
package/remult-knex/index.js
CHANGED
|
@@ -74,6 +74,39 @@ var KnexDataProvider = /** @class */ (function () {
|
|
|
74
74
|
throw 'the data provider is not an KnexDataProvider';
|
|
75
75
|
return r.knex;
|
|
76
76
|
};
|
|
77
|
+
Object.defineProperty(KnexDataProvider.prototype, "nativeNullSort", {
|
|
78
|
+
// By `driverName`, as CockroachDB shares the `postgresql` dialect.
|
|
79
|
+
get: function () {
|
|
80
|
+
switch (this.knex.client.driverName) {
|
|
81
|
+
case 'pg':
|
|
82
|
+
case 'pgnative':
|
|
83
|
+
case 'pg-redshift':
|
|
84
|
+
case 'oracledb':
|
|
85
|
+
return {
|
|
86
|
+
order: { asc: 'NULLS LAST', desc: 'NULLS FIRST' },
|
|
87
|
+
syntax: 'NULLS FIRST/LAST',
|
|
88
|
+
};
|
|
89
|
+
case 'mysql':
|
|
90
|
+
case 'mysql2':
|
|
91
|
+
case 'mssql':
|
|
92
|
+
return {
|
|
93
|
+
order: { asc: 'NULLS FIRST', desc: 'NULLS LAST' },
|
|
94
|
+
syntax: 'CASE WHEN',
|
|
95
|
+
};
|
|
96
|
+
case 'sqlite3':
|
|
97
|
+
case 'better-sqlite3':
|
|
98
|
+
case 'cockroachdb':
|
|
99
|
+
return {
|
|
100
|
+
order: { asc: 'NULLS FIRST', desc: 'NULLS LAST' },
|
|
101
|
+
syntax: 'NULLS FIRST/LAST',
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
// `case when` runs on any SQL database.
|
|
105
|
+
return { order: 'unknown', syntax: 'CASE WHEN' };
|
|
106
|
+
},
|
|
107
|
+
enumerable: false,
|
|
108
|
+
configurable: true
|
|
109
|
+
});
|
|
77
110
|
Object.defineProperty(KnexDataProvider.prototype, "jsonColumnStorage", {
|
|
78
111
|
get: function () {
|
|
79
112
|
if (!supportsJsonLoadingAndSaving(this.knex))
|
|
@@ -187,7 +220,7 @@ var KnexEntityDataProvider = /** @class */ (function () {
|
|
|
187
220
|
_b = [options];
|
|
188
221
|
return [4 /*yield*/, (0, filter_consumer_bridge_to_sql_request_js_1.dbNamesOfWithForceSqlExpression)(this.entity, this.dp.wrapIdentifier, true)];
|
|
189
222
|
case 1: return [2 /*return*/, _a.apply(void 0, _b.concat([_c.sent(), this.dp.createCommand(),
|
|
190
|
-
|
|
223
|
+
this.dp.nativeNullSort,
|
|
191
224
|
function (limit, offset) {
|
|
192
225
|
var _a;
|
|
193
226
|
return ((_a = _this.knex.client.config.client) === null || _a === void 0 ? void 0 : _a.includes('mssql'))
|
|
@@ -236,14 +269,14 @@ var KnexEntityDataProvider = /** @class */ (function () {
|
|
|
236
269
|
};
|
|
237
270
|
KnexEntityDataProvider.prototype.find = function (options) {
|
|
238
271
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
239
|
-
var e, cols, colKeys, _a, _b, x, name_1, query, br, r_1, r;
|
|
240
|
-
var e_1,
|
|
272
|
+
var e, cols, colKeys, _a, _b, x, name_1, query, br, r_1, native, _c, _d, s, r;
|
|
273
|
+
var e_1, _e, e_2, _f;
|
|
241
274
|
var _this = this;
|
|
242
|
-
return tslib_1.__generator(this, function (
|
|
243
|
-
switch (
|
|
275
|
+
return tslib_1.__generator(this, function (_g) {
|
|
276
|
+
switch (_g.label) {
|
|
244
277
|
case 0: return [4 /*yield*/, this.init()];
|
|
245
278
|
case 1:
|
|
246
|
-
e =
|
|
279
|
+
e = _g.sent();
|
|
247
280
|
cols = [];
|
|
248
281
|
colKeys = [];
|
|
249
282
|
try {
|
|
@@ -265,7 +298,7 @@ var KnexEntityDataProvider = /** @class */ (function () {
|
|
|
265
298
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
266
299
|
finally {
|
|
267
300
|
try {
|
|
268
|
-
if (_b && !_b.done && (
|
|
301
|
+
if (_b && !_b.done && (_e = _a.return)) _e.call(_a);
|
|
269
302
|
}
|
|
270
303
|
finally { if (e_1) throw e_1.error; }
|
|
271
304
|
}
|
|
@@ -275,18 +308,29 @@ var KnexEntityDataProvider = /** @class */ (function () {
|
|
|
275
308
|
options.where.__applyToConsumer(br);
|
|
276
309
|
return [4 /*yield*/, br.resolveWhere()];
|
|
277
310
|
case 2:
|
|
278
|
-
r_1 =
|
|
311
|
+
r_1 = _g.sent();
|
|
279
312
|
query.where(function (b) { return r_1.forEach(function (y) { return y(b); }); });
|
|
280
|
-
|
|
313
|
+
_g.label = 3;
|
|
281
314
|
case 3:
|
|
282
315
|
if (!options.orderBy) {
|
|
283
316
|
options.orderBy = sort_js_1.Sort.createUniqueSort(this.entity, new sort_js_1.Sort());
|
|
284
317
|
}
|
|
285
318
|
if (options.orderBy) {
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
319
|
+
native = this.dp.nativeNullSort;
|
|
320
|
+
try {
|
|
321
|
+
// Not Knex's own `nulls` option: outside Postgres it sorts on `(x is null)` alone.
|
|
322
|
+
for (_c = tslib_1.__values(options.orderBy.Segments), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
323
|
+
s = _d.value;
|
|
324
|
+
query = query.orderByRaw((0, sql_database_js_1.orderBySql)(':column:', s.isDescending, s.field.allowNull, native), { column: e.$dbNameOf(s.field) });
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
328
|
+
finally {
|
|
329
|
+
try {
|
|
330
|
+
if (_d && !_d.done && (_f = _c.return)) _f.call(_c);
|
|
331
|
+
}
|
|
332
|
+
finally { if (e_2) throw e_2.error; }
|
|
333
|
+
}
|
|
290
334
|
}
|
|
291
335
|
if (options.limit) {
|
|
292
336
|
query = query.limit(options.limit);
|
|
@@ -295,7 +339,7 @@ var KnexEntityDataProvider = /** @class */ (function () {
|
|
|
295
339
|
}
|
|
296
340
|
return [4 /*yield*/, query];
|
|
297
341
|
case 4:
|
|
298
|
-
r =
|
|
342
|
+
r = _g.sent();
|
|
299
343
|
return [2 /*return*/, r.map(function (y) {
|
|
300
344
|
var result = {};
|
|
301
345
|
var i = 0;
|
|
@@ -339,8 +383,8 @@ var KnexEntityDataProvider = /** @class */ (function () {
|
|
|
339
383
|
};
|
|
340
384
|
KnexEntityDataProvider.prototype.update = function (id, data, options) {
|
|
341
385
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
342
|
-
var e, f, updateObject, _a, _b, x, v, key,
|
|
343
|
-
var
|
|
386
|
+
var e, f, updateObject, _a, _b, x, v, key, e_3_1, where;
|
|
387
|
+
var e_3, _c;
|
|
344
388
|
return tslib_1.__generator(this, function (_d) {
|
|
345
389
|
switch (_d.label) {
|
|
346
390
|
case 0: return [4 /*yield*/, this.init()];
|
|
@@ -373,14 +417,14 @@ var KnexEntityDataProvider = /** @class */ (function () {
|
|
|
373
417
|
return [3 /*break*/, 3];
|
|
374
418
|
case 7: return [3 /*break*/, 10];
|
|
375
419
|
case 8:
|
|
376
|
-
|
|
377
|
-
|
|
420
|
+
e_3_1 = _d.sent();
|
|
421
|
+
e_3 = { error: e_3_1 };
|
|
378
422
|
return [3 /*break*/, 10];
|
|
379
423
|
case 9:
|
|
380
424
|
try {
|
|
381
425
|
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
382
426
|
}
|
|
383
|
-
finally { if (
|
|
427
|
+
finally { if (e_3) throw e_3.error; }
|
|
384
428
|
return [7 /*endfinally*/];
|
|
385
429
|
case 10: return [4 /*yield*/, f.resolveWhere()];
|
|
386
430
|
case 11:
|
|
@@ -426,8 +470,8 @@ var KnexEntityDataProvider = /** @class */ (function () {
|
|
|
426
470
|
};
|
|
427
471
|
KnexEntityDataProvider.prototype.insert = function (data, options) {
|
|
428
472
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
429
|
-
var result_1, data_1, data_1_1, row, _a, _b,
|
|
430
|
-
var
|
|
473
|
+
var result_1, data_1, data_1_1, row, _a, _b, e_4_1, e, batches, result, batches_1, batches_1_1, batch, _c, _d, _e, _f, e_5_1;
|
|
474
|
+
var e_4, _g, e_5, _h;
|
|
431
475
|
var _this = this;
|
|
432
476
|
return tslib_1.__generator(this, function (_j) {
|
|
433
477
|
switch (_j.label) {
|
|
@@ -456,14 +500,14 @@ var KnexEntityDataProvider = /** @class */ (function () {
|
|
|
456
500
|
return [3 /*break*/, 2];
|
|
457
501
|
case 5: return [3 /*break*/, 8];
|
|
458
502
|
case 6:
|
|
459
|
-
|
|
460
|
-
|
|
503
|
+
e_4_1 = _j.sent();
|
|
504
|
+
e_4 = { error: e_4_1 };
|
|
461
505
|
return [3 /*break*/, 8];
|
|
462
506
|
case 7:
|
|
463
507
|
try {
|
|
464
508
|
if (data_1_1 && !data_1_1.done && (_g = data_1.return)) _g.call(data_1);
|
|
465
509
|
}
|
|
466
|
-
finally { if (
|
|
510
|
+
finally { if (e_4) throw e_4.error; }
|
|
467
511
|
return [7 /*endfinally*/];
|
|
468
512
|
case 8: return [2 /*return*/, result_1];
|
|
469
513
|
case 9: return [4 /*yield*/, this.init()];
|
|
@@ -493,14 +537,14 @@ var KnexEntityDataProvider = /** @class */ (function () {
|
|
|
493
537
|
return [3 /*break*/, 12];
|
|
494
538
|
case 15: return [3 /*break*/, 18];
|
|
495
539
|
case 16:
|
|
496
|
-
|
|
497
|
-
|
|
540
|
+
e_5_1 = _j.sent();
|
|
541
|
+
e_5 = { error: e_5_1 };
|
|
498
542
|
return [3 /*break*/, 18];
|
|
499
543
|
case 17:
|
|
500
544
|
try {
|
|
501
545
|
if (batches_1_1 && !batches_1_1.done && (_h = batches_1.return)) _h.call(batches_1);
|
|
502
546
|
}
|
|
503
|
-
finally { if (
|
|
547
|
+
finally { if (e_5) throw e_5.error; }
|
|
504
548
|
return [7 /*endfinally*/];
|
|
505
549
|
case 18: return [2 /*return*/, result];
|
|
506
550
|
}
|
|
@@ -509,8 +553,8 @@ var KnexEntityDataProvider = /** @class */ (function () {
|
|
|
509
553
|
};
|
|
510
554
|
KnexEntityDataProvider.prototype.insertBatch = function (batch, e, options) {
|
|
511
555
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
512
|
-
var cols, _loop_1, _a, _b, x, insertObjects, batch_1, batch_1_1, row, insertObject, cols_1, cols_1_1, x, v, key,
|
|
513
|
-
var
|
|
556
|
+
var cols, _loop_1, _a, _b, x, insertObjects, batch_1, batch_1_1, row, insertObject, cols_1, cols_1_1, x, v, key, e_6_1, e_7_1, insert, wantRows, result, ids;
|
|
557
|
+
var e_8, _c, e_7, _d, e_6, _e;
|
|
514
558
|
var _this = this;
|
|
515
559
|
return tslib_1.__generator(this, function (_f) {
|
|
516
560
|
switch (_f.label) {
|
|
@@ -530,12 +574,12 @@ var KnexEntityDataProvider = /** @class */ (function () {
|
|
|
530
574
|
_loop_1(x);
|
|
531
575
|
}
|
|
532
576
|
}
|
|
533
|
-
catch (
|
|
577
|
+
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
534
578
|
finally {
|
|
535
579
|
try {
|
|
536
580
|
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
537
581
|
}
|
|
538
|
-
finally { if (
|
|
582
|
+
finally { if (e_8) throw e_8.error; }
|
|
539
583
|
}
|
|
540
584
|
insertObjects = [];
|
|
541
585
|
_f.label = 1;
|
|
@@ -550,7 +594,7 @@ var KnexEntityDataProvider = /** @class */ (function () {
|
|
|
550
594
|
_f.label = 3;
|
|
551
595
|
case 3:
|
|
552
596
|
_f.trys.push([3, 8, 9, 10]);
|
|
553
|
-
cols_1 = (
|
|
597
|
+
cols_1 = (e_6 = void 0, tslib_1.__values(cols)), cols_1_1 = cols_1.next();
|
|
554
598
|
_f.label = 4;
|
|
555
599
|
case 4:
|
|
556
600
|
if (!!cols_1_1.done) return [3 /*break*/, 7];
|
|
@@ -571,14 +615,14 @@ var KnexEntityDataProvider = /** @class */ (function () {
|
|
|
571
615
|
return [3 /*break*/, 4];
|
|
572
616
|
case 7: return [3 /*break*/, 10];
|
|
573
617
|
case 8:
|
|
574
|
-
|
|
575
|
-
|
|
618
|
+
e_6_1 = _f.sent();
|
|
619
|
+
e_6 = { error: e_6_1 };
|
|
576
620
|
return [3 /*break*/, 10];
|
|
577
621
|
case 9:
|
|
578
622
|
try {
|
|
579
623
|
if (cols_1_1 && !cols_1_1.done && (_e = cols_1.return)) _e.call(cols_1);
|
|
580
624
|
}
|
|
581
|
-
finally { if (
|
|
625
|
+
finally { if (e_6) throw e_6.error; }
|
|
582
626
|
return [7 /*endfinally*/];
|
|
583
627
|
case 10:
|
|
584
628
|
insertObjects.push(insertObject);
|
|
@@ -588,14 +632,14 @@ var KnexEntityDataProvider = /** @class */ (function () {
|
|
|
588
632
|
return [3 /*break*/, 2];
|
|
589
633
|
case 12: return [3 /*break*/, 15];
|
|
590
634
|
case 13:
|
|
591
|
-
|
|
592
|
-
|
|
635
|
+
e_7_1 = _f.sent();
|
|
636
|
+
e_7 = { error: e_7_1 };
|
|
593
637
|
return [3 /*break*/, 15];
|
|
594
638
|
case 14:
|
|
595
639
|
try {
|
|
596
640
|
if (batch_1_1 && !batch_1_1.done && (_d = batch_1.return)) _d.call(batch_1);
|
|
597
641
|
}
|
|
598
|
-
finally { if (
|
|
642
|
+
finally { if (e_7) throw e_7.error; }
|
|
599
643
|
return [7 /*endfinally*/];
|
|
600
644
|
case 15:
|
|
601
645
|
insert = this.getEntityFrom(e).insert(insertObjects);
|
|
@@ -644,8 +688,8 @@ var KnexEntityDataProvider = /** @class */ (function () {
|
|
|
644
688
|
//@internal
|
|
645
689
|
KnexEntityDataProvider.prototype.insertOne = function (data, options) {
|
|
646
690
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
647
|
-
var e, insertObject, _a, _b, x, v, key,
|
|
648
|
-
var
|
|
691
|
+
var e, insertObject, _a, _b, x, v, key, e_9_1, insert, newId_1, result, result;
|
|
692
|
+
var e_9, _c;
|
|
649
693
|
var _this = this;
|
|
650
694
|
return tslib_1.__generator(this, function (_d) {
|
|
651
695
|
switch (_d.label) {
|
|
@@ -676,14 +720,14 @@ var KnexEntityDataProvider = /** @class */ (function () {
|
|
|
676
720
|
return [3 /*break*/, 3];
|
|
677
721
|
case 7: return [3 /*break*/, 10];
|
|
678
722
|
case 8:
|
|
679
|
-
|
|
680
|
-
|
|
723
|
+
e_9_1 = _d.sent();
|
|
724
|
+
e_9 = { error: e_9_1 };
|
|
681
725
|
return [3 /*break*/, 10];
|
|
682
726
|
case 9:
|
|
683
727
|
try {
|
|
684
728
|
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
685
729
|
}
|
|
686
|
-
finally { if (
|
|
730
|
+
finally { if (e_9) throw e_9.error; }
|
|
687
731
|
return [7 /*endfinally*/];
|
|
688
732
|
case 10:
|
|
689
733
|
insert = this.getEntityFrom(e).insert(insertObject);
|
|
@@ -731,11 +775,12 @@ var FilterConsumerBridgeToKnexRequest = /** @class */ (function () {
|
|
|
731
775
|
this._addWhere = true;
|
|
732
776
|
this.promises = [];
|
|
733
777
|
this.result = [];
|
|
778
|
+
this.handleNull = new filter_consumer_bridge_to_sql_request_js_1.HandleNull();
|
|
734
779
|
}
|
|
735
780
|
FilterConsumerBridgeToKnexRequest.prototype.resolveWhere = function () {
|
|
736
781
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
737
|
-
var p, p_1, p_1_1, pr,
|
|
738
|
-
var
|
|
782
|
+
var p, p_1, p_1_1, pr, e_10_1;
|
|
783
|
+
var e_10, _a;
|
|
739
784
|
return tslib_1.__generator(this, function (_b) {
|
|
740
785
|
switch (_b.label) {
|
|
741
786
|
case 0:
|
|
@@ -745,7 +790,7 @@ var FilterConsumerBridgeToKnexRequest = /** @class */ (function () {
|
|
|
745
790
|
_b.label = 1;
|
|
746
791
|
case 1:
|
|
747
792
|
_b.trys.push([1, 6, 7, 8]);
|
|
748
|
-
p_1 = (
|
|
793
|
+
p_1 = (e_10 = void 0, tslib_1.__values(p)), p_1_1 = p_1.next();
|
|
749
794
|
_b.label = 2;
|
|
750
795
|
case 2:
|
|
751
796
|
if (!!p_1_1.done) return [3 /*break*/, 5];
|
|
@@ -759,14 +804,14 @@ var FilterConsumerBridgeToKnexRequest = /** @class */ (function () {
|
|
|
759
804
|
return [3 /*break*/, 2];
|
|
760
805
|
case 5: return [3 /*break*/, 8];
|
|
761
806
|
case 6:
|
|
762
|
-
|
|
763
|
-
|
|
807
|
+
e_10_1 = _b.sent();
|
|
808
|
+
e_10 = { error: e_10_1 };
|
|
764
809
|
return [3 /*break*/, 8];
|
|
765
810
|
case 7:
|
|
766
811
|
try {
|
|
767
812
|
if (p_1_1 && !p_1_1.done && (_a = p_1.return)) _a.call(p_1);
|
|
768
813
|
}
|
|
769
|
-
finally { if (
|
|
814
|
+
finally { if (e_10) throw e_10.error; }
|
|
770
815
|
return [7 /*endfinally*/];
|
|
771
816
|
case 8: return [3 /*break*/, 0];
|
|
772
817
|
case 9: return [2 /*return*/, this.result];
|
|
@@ -780,12 +825,13 @@ var FilterConsumerBridgeToKnexRequest = /** @class */ (function () {
|
|
|
780
825
|
FilterConsumerBridgeToKnexRequest.prototype.or = function (orElements) {
|
|
781
826
|
var _this = this;
|
|
782
827
|
this.promises.push((function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
783
|
-
var result, _loop_2, this_1, orElements_1, orElements_1_1, element, state_1,
|
|
784
|
-
var
|
|
828
|
+
var result, branches, _loop_2, this_1, orElements_1, orElements_1_1, element, state_1, e_11_1;
|
|
829
|
+
var e_11, _a;
|
|
785
830
|
return tslib_1.__generator(this, function (_b) {
|
|
786
831
|
switch (_b.label) {
|
|
787
832
|
case 0:
|
|
788
833
|
result = [];
|
|
834
|
+
branches = new filter_consumer_bridge_to_sql_request_js_1.HandleNull();
|
|
789
835
|
_loop_2 = function (element) {
|
|
790
836
|
var f, where;
|
|
791
837
|
return tslib_1.__generator(this, function (_c) {
|
|
@@ -798,6 +844,7 @@ var FilterConsumerBridgeToKnexRequest = /** @class */ (function () {
|
|
|
798
844
|
case 1:
|
|
799
845
|
where = _c.sent();
|
|
800
846
|
if (where.length > 0) {
|
|
847
|
+
branches.add(f.handleNull);
|
|
801
848
|
result.push(function (b) {
|
|
802
849
|
b.orWhere(function (b) {
|
|
803
850
|
where.forEach(function (x) { return x(b); });
|
|
@@ -830,17 +877,18 @@ var FilterConsumerBridgeToKnexRequest = /** @class */ (function () {
|
|
|
830
877
|
return [3 /*break*/, 2];
|
|
831
878
|
case 5: return [3 /*break*/, 8];
|
|
832
879
|
case 6:
|
|
833
|
-
|
|
834
|
-
|
|
880
|
+
e_11_1 = _b.sent();
|
|
881
|
+
e_11 = { error: e_11_1 };
|
|
835
882
|
return [3 /*break*/, 8];
|
|
836
883
|
case 7:
|
|
837
884
|
try {
|
|
838
885
|
if (orElements_1_1 && !orElements_1_1.done && (_a = orElements_1.return)) _a.call(orElements_1);
|
|
839
886
|
}
|
|
840
|
-
finally { if (
|
|
887
|
+
finally { if (e_11) throw e_11.error; }
|
|
841
888
|
return [7 /*endfinally*/];
|
|
842
889
|
case 8:
|
|
843
890
|
if (result.length > 0) {
|
|
891
|
+
this.handleNull.add(branches);
|
|
844
892
|
this.result.push(function (b) { return b.where(function (x) { return result.find(function (y) { return y(x); }); }); });
|
|
845
893
|
}
|
|
846
894
|
return [2 /*return*/];
|
|
@@ -862,14 +910,25 @@ var FilterConsumerBridgeToKnexRequest = /** @class */ (function () {
|
|
|
862
910
|
case 1:
|
|
863
911
|
where = _a.sent();
|
|
864
912
|
if (where.length > 0) {
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
913
|
+
if (f.handleNull.nullable) {
|
|
914
|
+
this.result.push(function (b) {
|
|
915
|
+
var nested = b.client.queryBuilder();
|
|
916
|
+
where.forEach(function (x) { return x(nested); });
|
|
917
|
+
var compiled = nested.toSQL();
|
|
918
|
+
var pred = compiled.sql.replace(/^select \* where /i, '');
|
|
919
|
+
b.whereRaw("case when (".concat(pred, ") then 0 else 1 end = 1"), compiled.bindings);
|
|
868
920
|
});
|
|
869
|
-
}
|
|
921
|
+
}
|
|
922
|
+
else {
|
|
923
|
+
this.result.push(function (b) {
|
|
924
|
+
b.whereNot(function (x) {
|
|
925
|
+
where.forEach(function (w) { return w(x); });
|
|
926
|
+
});
|
|
927
|
+
});
|
|
928
|
+
}
|
|
870
929
|
}
|
|
871
930
|
else
|
|
872
|
-
|
|
931
|
+
this.result.push(function (b) { return b.whereRaw('1 = 0'); });
|
|
873
932
|
return [2 /*return*/];
|
|
874
933
|
}
|
|
875
934
|
});
|
|
@@ -877,16 +936,20 @@ var FilterConsumerBridgeToKnexRequest = /** @class */ (function () {
|
|
|
877
936
|
};
|
|
878
937
|
FilterConsumerBridgeToKnexRequest.prototype.isNull = function (col) {
|
|
879
938
|
var _this = this;
|
|
939
|
+
this.handleNull.column(col);
|
|
880
940
|
this.result.push(function (b) { return b.whereNull(_this.innerNameProvider.$dbNameOf(col)); });
|
|
881
941
|
};
|
|
882
942
|
FilterConsumerBridgeToKnexRequest.prototype.isNotNull = function (col) {
|
|
883
943
|
var _this = this;
|
|
944
|
+
this.handleNull.column(col);
|
|
884
945
|
this.result.push(function (b) {
|
|
885
946
|
return b.whereNotNull(_this.innerNameProvider.$dbNameOf(col));
|
|
886
947
|
});
|
|
887
948
|
};
|
|
888
949
|
FilterConsumerBridgeToKnexRequest.prototype.isIn = function (col, val) {
|
|
889
950
|
var _this = this;
|
|
951
|
+
if (val === null || val === void 0 ? void 0 : val.length)
|
|
952
|
+
this.handleNull.column(col);
|
|
890
953
|
this.result.push(function (knex) {
|
|
891
954
|
return knex.whereIn(_this.innerNameProvider.$dbNameOf(col), val.map(function (x) {
|
|
892
955
|
return translateValueAndHandleArrayAndHandleArray(col, x, _this.jsonColumnStorage);
|
|
@@ -926,6 +989,7 @@ var FilterConsumerBridgeToKnexRequest = /** @class */ (function () {
|
|
|
926
989
|
FilterConsumerBridgeToKnexRequest.prototype.like = function (col, pattern, not) {
|
|
927
990
|
var _this = this;
|
|
928
991
|
if (not === void 0) { not = ''; }
|
|
992
|
+
this.handleNull.column(col);
|
|
929
993
|
this.result.push(function (b) {
|
|
930
994
|
return b.whereRaw(not +
|
|
931
995
|
'lower (' +
|
|
@@ -939,6 +1003,7 @@ var FilterConsumerBridgeToKnexRequest = /** @class */ (function () {
|
|
|
939
1003
|
};
|
|
940
1004
|
FilterConsumerBridgeToKnexRequest.prototype.add = function (col, val, operator) {
|
|
941
1005
|
var _this = this;
|
|
1006
|
+
this.handleNull.column(col);
|
|
942
1007
|
this.result.push(function (b) {
|
|
943
1008
|
return b.where(_this.innerNameProvider.$dbNameOf(col), operator, translateValueAndHandleArrayAndHandleArray(col, val, _this.jsonColumnStorage));
|
|
944
1009
|
});
|
|
@@ -955,6 +1020,7 @@ var FilterConsumerBridgeToKnexRequest = /** @class */ (function () {
|
|
|
955
1020
|
return [4 /*yield*/, databaseCustom.buildKnex()];
|
|
956
1021
|
case 1:
|
|
957
1022
|
_b.apply(_a, [_c.sent()]);
|
|
1023
|
+
this.handleNull.custom();
|
|
958
1024
|
_c.label = 2;
|
|
959
1025
|
case 2:
|
|
960
1026
|
if (!(databaseCustom === null || databaseCustom === void 0 ? void 0 : databaseCustom.buildSql)) return [3 /*break*/, 4];
|
|
@@ -966,6 +1032,7 @@ var FilterConsumerBridgeToKnexRequest = /** @class */ (function () {
|
|
|
966
1032
|
if (typeof sql_1 !== 'string')
|
|
967
1033
|
sql_1 = item.sql;
|
|
968
1034
|
if (sql_1) {
|
|
1035
|
+
this.handleNull.custom();
|
|
969
1036
|
this.result.push(function (b) { return b.whereRaw(sql_1, r_2.values); });
|
|
970
1037
|
}
|
|
971
1038
|
_c.label = 4;
|
|
@@ -983,8 +1050,8 @@ var KnexSchemaBuilder = /** @class */ (function () {
|
|
|
983
1050
|
}
|
|
984
1051
|
KnexSchemaBuilder.prototype.ensureSchema = function (entities) {
|
|
985
1052
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
986
|
-
var entities_1, entities_1_1, entity, e, err_2,
|
|
987
|
-
var
|
|
1053
|
+
var entities_1, entities_1_1, entity, e, err_2, e_12_1;
|
|
1054
|
+
var e_12, _a;
|
|
988
1055
|
return tslib_1.__generator(this, function (_b) {
|
|
989
1056
|
switch (_b.label) {
|
|
990
1057
|
case 0:
|
|
@@ -1018,14 +1085,14 @@ var KnexSchemaBuilder = /** @class */ (function () {
|
|
|
1018
1085
|
return [3 /*break*/, 1];
|
|
1019
1086
|
case 9: return [3 /*break*/, 12];
|
|
1020
1087
|
case 10:
|
|
1021
|
-
|
|
1022
|
-
|
|
1088
|
+
e_12_1 = _b.sent();
|
|
1089
|
+
e_12 = { error: e_12_1 };
|
|
1023
1090
|
return [3 /*break*/, 12];
|
|
1024
1091
|
case 11:
|
|
1025
1092
|
try {
|
|
1026
1093
|
if (entities_1_1 && !entities_1_1.done && (_a = entities_1.return)) _a.call(entities_1);
|
|
1027
1094
|
}
|
|
1028
|
-
finally { if (
|
|
1095
|
+
finally { if (e_12) throw e_12.error; }
|
|
1029
1096
|
return [7 /*endfinally*/];
|
|
1030
1097
|
case 12: return [2 /*return*/];
|
|
1031
1098
|
}
|
|
@@ -1053,7 +1120,7 @@ var KnexSchemaBuilder = /** @class */ (function () {
|
|
|
1053
1120
|
});
|
|
1054
1121
|
};
|
|
1055
1122
|
KnexSchemaBuilder.prototype.createTableKnexCommand = function (entity, e) {
|
|
1056
|
-
var
|
|
1123
|
+
var e_13, _a;
|
|
1057
1124
|
var _this = this;
|
|
1058
1125
|
var cols = new Map();
|
|
1059
1126
|
try {
|
|
@@ -1065,15 +1132,15 @@ var KnexSchemaBuilder = /** @class */ (function () {
|
|
|
1065
1132
|
});
|
|
1066
1133
|
}
|
|
1067
1134
|
}
|
|
1068
|
-
catch (
|
|
1135
|
+
catch (e_13_1) { e_13 = { error: e_13_1 }; }
|
|
1069
1136
|
finally {
|
|
1070
1137
|
try {
|
|
1071
1138
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
1072
1139
|
}
|
|
1073
|
-
finally { if (
|
|
1140
|
+
finally { if (e_13) throw e_13.error; }
|
|
1074
1141
|
}
|
|
1075
1142
|
return this.knex.schema.createTable(e.$entityName, function (b) {
|
|
1076
|
-
var
|
|
1143
|
+
var e_14, _a;
|
|
1077
1144
|
try {
|
|
1078
1145
|
for (var _b = tslib_1.__values(entity.fields), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1079
1146
|
var x = _c.value;
|
|
@@ -1086,12 +1153,12 @@ var KnexSchemaBuilder = /** @class */ (function () {
|
|
|
1086
1153
|
}
|
|
1087
1154
|
}
|
|
1088
1155
|
}
|
|
1089
|
-
catch (
|
|
1156
|
+
catch (e_14_1) { e_14 = { error: e_14_1 }; }
|
|
1090
1157
|
finally {
|
|
1091
1158
|
try {
|
|
1092
1159
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
1093
1160
|
}
|
|
1094
|
-
finally { if (
|
|
1161
|
+
finally { if (e_14) throw e_14.error; }
|
|
1095
1162
|
}
|
|
1096
1163
|
b.primary(entity.idMetadata.fields.map(function (f) { return e.$dbNameOf(f); }));
|
|
1097
1164
|
});
|
|
@@ -1128,8 +1195,8 @@ var KnexSchemaBuilder = /** @class */ (function () {
|
|
|
1128
1195
|
};
|
|
1129
1196
|
KnexSchemaBuilder.prototype.verifyAllColumns = function (entity) {
|
|
1130
1197
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1131
|
-
var e, _loop_3, this_2, _a, _b, col,
|
|
1132
|
-
var
|
|
1198
|
+
var e, _loop_3, this_2, _a, _b, col, e_15_1, err_3;
|
|
1199
|
+
var e_15, _c;
|
|
1133
1200
|
return tslib_1.__generator(this, function (_d) {
|
|
1134
1201
|
switch (_d.label) {
|
|
1135
1202
|
case 0: return [4 /*yield*/, (0, filter_consumer_bridge_to_sql_request_js_2.dbNamesOf)(entity, function (x) { return x; })];
|
|
@@ -1169,14 +1236,14 @@ var KnexSchemaBuilder = /** @class */ (function () {
|
|
|
1169
1236
|
return [3 /*break*/, 4];
|
|
1170
1237
|
case 7: return [3 /*break*/, 10];
|
|
1171
1238
|
case 8:
|
|
1172
|
-
|
|
1173
|
-
|
|
1239
|
+
e_15_1 = _d.sent();
|
|
1240
|
+
e_15 = { error: e_15_1 };
|
|
1174
1241
|
return [3 /*break*/, 10];
|
|
1175
1242
|
case 9:
|
|
1176
1243
|
try {
|
|
1177
1244
|
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
1178
1245
|
}
|
|
1179
|
-
finally { if (
|
|
1246
|
+
finally { if (e_15) throw e_15.error; }
|
|
1180
1247
|
return [7 /*endfinally*/];
|
|
1181
1248
|
case 10: return [3 /*break*/, 12];
|
|
1182
1249
|
case 11:
|
|
@@ -1222,8 +1289,11 @@ function buildColumn(x, dbName, b, supportsJson) {
|
|
|
1222
1289
|
c.defaultTo(0).notNullable();
|
|
1223
1290
|
}
|
|
1224
1291
|
}
|
|
1225
|
-
else
|
|
1226
|
-
b.specificType(dbName, x.valueConverter.fieldTypeInDb);
|
|
1292
|
+
else {
|
|
1293
|
+
var c = b.specificType(dbName, x.valueConverter.fieldTypeInDb);
|
|
1294
|
+
if (!x.allowNull)
|
|
1295
|
+
c.defaultTo(0).notNullable();
|
|
1296
|
+
}
|
|
1227
1297
|
}
|
|
1228
1298
|
else if (x.valueType == Date) {
|
|
1229
1299
|
if (!x.valueConverter.fieldTypeInDb)
|
|
@@ -1302,7 +1372,7 @@ function knexMaxParametersInOneSqlStatement(knex) {
|
|
|
1302
1372
|
return defaultMaxParametersInOneSqlStatement;
|
|
1303
1373
|
}
|
|
1304
1374
|
function splitByMaxParameters(items, parametersInItem, maxParameters) {
|
|
1305
|
-
var
|
|
1375
|
+
var e_16, _a;
|
|
1306
1376
|
var batches = [];
|
|
1307
1377
|
var batch = [];
|
|
1308
1378
|
var params = 0;
|
|
@@ -1319,19 +1389,19 @@ function splitByMaxParameters(items, parametersInItem, maxParameters) {
|
|
|
1319
1389
|
params += n;
|
|
1320
1390
|
}
|
|
1321
1391
|
}
|
|
1322
|
-
catch (
|
|
1392
|
+
catch (e_16_1) { e_16 = { error: e_16_1 }; }
|
|
1323
1393
|
finally {
|
|
1324
1394
|
try {
|
|
1325
1395
|
if (items_1_1 && !items_1_1.done && (_a = items_1.return)) _a.call(items_1);
|
|
1326
1396
|
}
|
|
1327
|
-
finally { if (
|
|
1397
|
+
finally { if (e_16) throw e_16.error; }
|
|
1328
1398
|
}
|
|
1329
1399
|
if (batch.length)
|
|
1330
1400
|
batches.push(batch);
|
|
1331
1401
|
return batches;
|
|
1332
1402
|
}
|
|
1333
1403
|
function countKnexInsertBindParameters(entity, e, row, storage) {
|
|
1334
|
-
var
|
|
1404
|
+
var e_17, _a;
|
|
1335
1405
|
var n = 0;
|
|
1336
1406
|
try {
|
|
1337
1407
|
for (var _b = tslib_1.__values(entity.fields), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
@@ -1343,12 +1413,12 @@ function countKnexInsertBindParameters(entity, e, row, storage) {
|
|
|
1343
1413
|
n++;
|
|
1344
1414
|
}
|
|
1345
1415
|
}
|
|
1346
|
-
catch (
|
|
1416
|
+
catch (e_17_1) { e_17 = { error: e_17_1 }; }
|
|
1347
1417
|
finally {
|
|
1348
1418
|
try {
|
|
1349
1419
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
1350
1420
|
}
|
|
1351
|
-
finally { if (
|
|
1421
|
+
finally { if (e_17) throw e_17.error; }
|
|
1352
1422
|
}
|
|
1353
1423
|
return n;
|
|
1354
1424
|
}
|