remult 3.2.3 → 3.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.
Files changed (37) hide show
  1. package/esm/graphql.js +1 -1
  2. package/esm/remult-knex/index.js +8 -2
  3. package/esm/remult-mongo.js +7 -3
  4. package/esm/server/remult-api-server.js +1 -1
  5. package/esm/src/data-api.js +30 -19
  6. package/esm/src/data-providers/rest-data-provider.js +50 -35
  7. package/esm/src/data-providers/sql-database.js +35 -13
  8. package/esm/src/filter/fieldDbName.js +4 -1
  9. package/esm/src/filter/filter-consumer-bridge-to-sql-request.js +5 -2
  10. package/esm/src/remult-proxy.js +4 -4
  11. package/esm/src/remult3/RepositoryImplementation.js +34 -17
  12. package/esm/src/remult3/remult3.js +8 -0
  13. package/esm/src/valueConverters.js +10 -5
  14. package/graphql.js +1 -1
  15. package/index.d.ts +1 -1
  16. package/package.json +1 -1
  17. package/remult-knex/index.js +16 -8
  18. package/remult-mongo.js +6 -2
  19. package/server/remult-api-server.js +1 -0
  20. package/src/column-interfaces.d.ts +3 -1
  21. package/src/data-api.d.ts +4 -4
  22. package/src/data-api.js +50 -30
  23. package/src/data-interfaces.d.ts +7 -6
  24. package/src/data-providers/rest-data-provider.d.ts +4 -4
  25. package/src/data-providers/rest-data-provider.js +50 -35
  26. package/src/data-providers/sql-database.js +158 -90
  27. package/src/filter/fieldDbName.d.ts +2 -1
  28. package/src/filter/fieldDbName.js +5 -1
  29. package/src/filter/filter-consumer-bridge-to-sql-request.d.ts +1 -0
  30. package/src/filter/filter-consumer-bridge-to-sql-request.js +7 -2
  31. package/src/remult-proxy.js +4 -4
  32. package/src/remult3/RepositoryImplementation.d.ts +6 -6
  33. package/src/remult3/RepositoryImplementation.js +209 -169
  34. package/src/remult3/remult3.d.ts +11 -7
  35. package/src/remult3/remult3.js +8 -0
  36. package/src/valueConverters.d.ts +3 -1
  37. package/src/valueConverters.js +10 -6
@@ -2,7 +2,7 @@ import type { DataProvider, EntityDataProvider, EntityDataProviderGroupByOptions
2
2
  import { UrlBuilder } from '../../urlBuilder.js';
3
3
  import type { ApiClient } from '../context.js';
4
4
  import { Filter } from '../filter/filter-interfaces.js';
5
- import type { EntityMetadata } from '../remult3/remult3.js';
5
+ import type { EntityMetadata, InsertOrUpdateOptions } from '../remult3/remult3.js';
6
6
  export declare class RestDataProvider implements DataProvider {
7
7
  private apiProvider;
8
8
  private entityRequested?;
@@ -33,11 +33,11 @@ export declare class RestEntityDataProvider implements EntityDataProvider, Proxy
33
33
  set: any;
34
34
  }[]): Promise<any[]>;
35
35
  find(options?: EntityDataProviderFindOptions): Promise<Array<any>>;
36
- update(id: any, data: any): Promise<any>;
36
+ update(id: any, data: any, options?: InsertOrUpdateOptions): Promise<any>;
37
37
  private toJsonOfIncludedKeys;
38
38
  delete(id: any): Promise<void>;
39
- insert(data: any): Promise<any>;
40
- insertMany(data: any[]): Promise<any[]>;
39
+ insert(data: any, options?: InsertOrUpdateOptions): Promise<any>;
40
+ insertMany(data: any[], options?: InsertOrUpdateOptions): Promise<any[]>;
41
41
  }
42
42
  export declare function addFilterToUrlAndReturnTrueIfSuccessful(filter: any, url: UrlBuilder): boolean;
43
43
  export declare const liveQueryAction = "liveQuery-";
@@ -82,6 +82,7 @@ function findOptionsFromJson(json, meta) {
82
82
  'orderBy',
83
83
  'include',
84
84
  'select',
85
+ 'args',
85
86
  ]), _c = _b.next(); !_c.done; _c = _b.next()) {
86
87
  var key = _c.value;
87
88
  if (json[key] !== undefined) {
@@ -286,36 +287,42 @@ var RestEntityDataProvider = /** @class */ (function () {
286
287
  var url = new urlBuilder_js_1.UrlBuilder(this.url());
287
288
  var filterObject;
288
289
  if (options) {
289
- if (options.where) {
290
- filterObject = options.where.toJson(); // options.where.__applyToConsumer(new FilterConsumnerBridgeToUrlBuilder(url));
291
- if (addFilterToUrlAndReturnTrueIfSuccessful(filterObject, url))
292
- filterObject = undefined;
290
+ if (options.where === 'all') {
291
+ filterObject = 'all';
293
292
  }
294
- if (options.orderBy && options.orderBy.Segments) {
295
- var sort_1 = '';
296
- var order_1 = '';
297
- var hasDescending_1 = false;
298
- options.orderBy.Segments.forEach(function (c) {
299
- if (sort_1.length > 0) {
300
- sort_1 += ',';
301
- order_1 += ',';
302
- }
303
- sort_1 += c.field.key;
304
- order_1 += c.isDescending ? 'desc' : 'asc';
305
- if (c.isDescending)
306
- hasDescending_1 = true;
307
- });
308
- if (sort_1)
309
- url.add('_sort', sort_1);
310
- if (hasDescending_1)
311
- url.add('_order', order_1);
312
- }
313
- if (options.limit)
314
- url.add('_limit', options.limit);
315
- if (options.page)
316
- url.add('_page', options.page);
317
- if (options.select) {
318
- url.add('_select', options.select.join(','));
293
+ else {
294
+ if (options.where) {
295
+ filterObject = options.where.toJson();
296
+ if (options.args === undefined)
297
+ if (addFilterToUrlAndReturnTrueIfSuccessful(filterObject, url))
298
+ filterObject = undefined;
299
+ }
300
+ if (options.orderBy && options.orderBy.Segments) {
301
+ var sort_1 = '';
302
+ var order_1 = '';
303
+ var hasDescending_1 = false;
304
+ options.orderBy.Segments.forEach(function (c) {
305
+ if (sort_1.length > 0) {
306
+ sort_1 += ',';
307
+ order_1 += ',';
308
+ }
309
+ sort_1 += c.field.key;
310
+ order_1 += c.isDescending ? 'desc' : 'asc';
311
+ if (c.isDescending)
312
+ hasDescending_1 = true;
313
+ });
314
+ if (sort_1)
315
+ url.add('_sort', sort_1);
316
+ if (hasDescending_1)
317
+ url.add('_order', order_1);
318
+ }
319
+ if (options.limit)
320
+ url.add('_limit', options.limit);
321
+ if (options.page)
322
+ url.add('_page', options.page);
323
+ if (options.select) {
324
+ url.add('_select', options.select.join(','));
325
+ }
319
326
  }
320
327
  }
321
328
  var run = function (action, body) {
@@ -332,6 +339,8 @@ var RestEntityDataProvider = /** @class */ (function () {
332
339
  else
333
340
  body = tslib_1.__assign(tslib_1.__assign({}, body), { where: filterObject });
334
341
  }
342
+ if (options && 'args' in options)
343
+ body.args = options.args;
335
344
  if (body && method != 'put')
336
345
  return _this.http().post(u.url, body);
337
346
  else
@@ -366,11 +375,17 @@ var RestEntityDataProvider = /** @class */ (function () {
366
375
  }); },
367
376
  };
368
377
  };
369
- RestEntityDataProvider.prototype.update = function (id, data) {
378
+ RestEntityDataProvider.prototype.update = function (id, data, options) {
370
379
  var _this = this;
380
+ var urlArgs = [];
381
+ if (id == '')
382
+ urlArgs.push('__action=emptyId');
383
+ if ((options === null || options === void 0 ? void 0 : options.select) === 'none')
384
+ urlArgs.push('_select=$none');
371
385
  return this.http()
372
386
  .put(this.url() +
373
- (id != '' ? '/' + encodeURIComponent(id) : '?__action=emptyId'), this.toJsonOfIncludedKeys(data))
387
+ (id != '' ? '/' + encodeURIComponent(id) : '') +
388
+ (urlArgs.length > 0 ? '?' + urlArgs.join('&') : ''), this.toJsonOfIncludedKeys(data))
374
389
  .then(function (y) { return _this.translateFromJson(y); });
375
390
  };
376
391
  RestEntityDataProvider.prototype.toJsonOfIncludedKeys = function (data) {
@@ -409,16 +424,16 @@ var RestEntityDataProvider = /** @class */ (function () {
409
424
  });
410
425
  });
411
426
  };
412
- RestEntityDataProvider.prototype.insert = function (data) {
427
+ RestEntityDataProvider.prototype.insert = function (data, options) {
413
428
  var _this = this;
414
429
  return this.http()
415
- .post(this.url(), this.translateToJson(data))
430
+ .post(this.url() + ((options === null || options === void 0 ? void 0 : options.select) === 'none' ? '?_select=$none' : ''), this.translateToJson(data))
416
431
  .then(function (y) { return _this.translateFromJson(y); });
417
432
  };
418
- RestEntityDataProvider.prototype.insertMany = function (data) {
433
+ RestEntityDataProvider.prototype.insertMany = function (data, options) {
419
434
  var _this = this;
420
435
  return this.http()
421
- .post(this.url(), data.map(function (data) { return _this.translateToJson(data); }))
436
+ .post(this.url() + ((options === null || options === void 0 ? void 0 : options.select) === 'none' ? '?_select=$none' : ''), data.map(function (data) { return _this.translateToJson(data); }))
422
437
  .then(function (y) { return y.map(function (y) { return _this.translateFromJson(y); }); });
423
438
  };
424
439
  return RestEntityDataProvider;
@@ -13,6 +13,7 @@ var sort_js_1 = require("../sort.js");
13
13
  var valueConverters_js_1 = require("../valueConverters.js");
14
14
  var repository_internals_js_1 = require("../remult3/repository-internals.js");
15
15
  var isOfType_js_1 = require("../isOfType.js");
16
+ var fieldDbName_js_1 = require("../filter/fieldDbName.js");
16
17
  /**
17
18
  * A DataProvider for Sql Databases
18
19
  * @example
@@ -413,78 +414,100 @@ var ActualSQLEntityDataProvider = /** @class */ (function () {
413
414
  };
414
415
  ActualSQLEntityDataProvider.prototype.find = function (options) {
415
416
  return tslib_1.__awaiter(this, void 0, void 0, function () {
416
- var e, _a, colKeys, select, r, where, _b, first, segs, _c, _d, s, segs_1, segs_1_1, c, page;
417
- var e_2, _e, e_3, _f;
417
+ var e, r, _a, colKeys, select, where, _b, first, segs, _c, _d, s, segs_1, segs_1_1, c, _e, _f, e_2_1, page;
418
+ var e_3, _g, e_2, _h;
418
419
  var _this = this;
419
- return tslib_1.__generator(this, function (_g) {
420
- switch (_g.label) {
420
+ return tslib_1.__generator(this, function (_j) {
421
+ switch (_j.label) {
421
422
  case 0: return [4 /*yield*/, this.init()];
422
423
  case 1:
423
- e = _g.sent();
424
- _a = this.buildSelect(e, options === null || options === void 0 ? void 0 : options.select), colKeys = _a.colKeys, select = _a.select;
424
+ e = _j.sent();
425
+ r = this.sql.createCommand();
426
+ return [4 /*yield*/, this.buildSelect(e, r, options === null || options === void 0 ? void 0 : options.select, options === null || options === void 0 ? void 0 : options.args)];
427
+ case 2:
428
+ _a = _j.sent(), colKeys = _a.colKeys, select = _a.select;
425
429
  select = 'select ' + select;
426
430
  select += '\n from ' + e.$entityName;
427
- r = this.sql.createCommand();
428
- if (!options) return [3 /*break*/, 4];
429
- if (!options.where) return [3 /*break*/, 3];
431
+ if (!options) return [3 /*break*/, 15];
432
+ if (!options.where) return [3 /*break*/, 4];
430
433
  where = new filter_consumer_bridge_to_sql_request_js_1.FilterConsumerBridgeToSqlRequest(r, e);
431
434
  options.where.__applyToConsumer(where);
432
435
  _b = select;
433
436
  return [4 /*yield*/, where.resolveWhere()];
434
- case 2:
435
- select = _b + _g.sent();
436
- _g.label = 3;
437
437
  case 3:
438
+ select = _b + _j.sent();
439
+ _j.label = 4;
440
+ case 4:
438
441
  if (options.limit) {
439
442
  options.orderBy = sort_js_1.Sort.createUniqueSort(this.entity, options.orderBy);
440
443
  }
441
444
  if (!options.orderBy) {
442
445
  options.orderBy = sort_js_1.Sort.createUniqueSort(this.entity, new sort_js_1.Sort());
443
446
  }
444
- if (options.orderBy) {
445
- first = true;
446
- segs = [];
447
- try {
448
- for (_c = tslib_1.__values(options.orderBy.Segments), _d = _c.next(); !_d.done; _d = _c.next()) {
449
- s = _d.value;
450
- segs.push(s);
451
- }
452
- }
453
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
454
- finally {
455
- try {
456
- if (_d && !_d.done && (_e = _c.return)) _e.call(_c);
457
- }
458
- finally { if (e_2) throw e_2.error; }
447
+ if (!options.orderBy) return [3 /*break*/, 14];
448
+ first = true;
449
+ segs = [];
450
+ try {
451
+ for (_c = tslib_1.__values(options.orderBy.Segments), _d = _c.next(); !_d.done; _d = _c.next()) {
452
+ s = _d.value;
453
+ segs.push(s);
459
454
  }
455
+ }
456
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
457
+ finally {
460
458
  try {
461
- for (segs_1 = tslib_1.__values(segs), segs_1_1 = segs_1.next(); !segs_1_1.done; segs_1_1 = segs_1.next()) {
462
- c = segs_1_1.value;
463
- if (first) {
464
- select += ' Order By ';
465
- first = false;
466
- }
467
- else
468
- select += ', ';
469
- select += e.$dbNameOf(c.field);
470
- if (c.isDescending)
471
- select += ' desc';
472
- if (this.sql._getSourceSql().orderByNullsFirst) {
473
- if (c.isDescending)
474
- select += ' nulls last';
475
- else
476
- select += ' nulls first';
477
- }
478
- }
479
- }
480
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
481
- finally {
482
- try {
483
- if (segs_1_1 && !segs_1_1.done && (_f = segs_1.return)) _f.call(segs_1);
484
- }
485
- finally { if (e_3) throw e_3.error; }
459
+ if (_d && !_d.done && (_g = _c.return)) _g.call(_c);
486
460
  }
461
+ finally { if (e_3) throw e_3.error; }
487
462
  }
463
+ _j.label = 5;
464
+ case 5:
465
+ _j.trys.push([5, 12, 13, 14]);
466
+ segs_1 = tslib_1.__values(segs), segs_1_1 = segs_1.next();
467
+ _j.label = 6;
468
+ case 6:
469
+ if (!!segs_1_1.done) return [3 /*break*/, 11];
470
+ c = segs_1_1.value;
471
+ if (first) {
472
+ select += ' Order By ';
473
+ first = false;
474
+ }
475
+ else
476
+ select += ', ';
477
+ _e = select;
478
+ if (!c.field.options.sqlExpression) return [3 /*break*/, 7];
479
+ _f = c.field.options.key;
480
+ return [3 /*break*/, 9];
481
+ case 7: return [4 /*yield*/, e.$dbNameOf(c.field)];
482
+ case 8:
483
+ _f = _j.sent();
484
+ _j.label = 9;
485
+ case 9:
486
+ select = _e + _f;
487
+ if (c.isDescending)
488
+ select += ' desc';
489
+ if (this.sql._getSourceSql().orderByNullsFirst) {
490
+ if (c.isDescending)
491
+ select += ' nulls last';
492
+ else
493
+ select += ' nulls first';
494
+ }
495
+ _j.label = 10;
496
+ case 10:
497
+ segs_1_1 = segs_1.next();
498
+ return [3 /*break*/, 6];
499
+ case 11: return [3 /*break*/, 14];
500
+ case 12:
501
+ e_2_1 = _j.sent();
502
+ e_2 = { error: e_2_1 };
503
+ return [3 /*break*/, 14];
504
+ case 13:
505
+ try {
506
+ if (segs_1_1 && !segs_1_1.done && (_h = segs_1.return)) _h.call(segs_1);
507
+ }
508
+ finally { if (e_2) throw e_2.error; }
509
+ return [7 /*endfinally*/];
510
+ case 14:
488
511
  if (options.limit) {
489
512
  page = 1;
490
513
  if (options.page)
@@ -495,8 +518,8 @@ var ActualSQLEntityDataProvider = /** @class */ (function () {
495
518
  ' ' +
496
519
  this.strategy.getLimitSqlSyntax(options.limit, (page - 1) * options.limit);
497
520
  }
498
- _g.label = 4;
499
- case 4: return [2 /*return*/, r.execute(select).then(function (r) {
521
+ _j.label = 15;
522
+ case 15: return [2 /*return*/, r.execute(select).then(function (r) {
500
523
  return r.rows.map(function (y) {
501
524
  return _this.buildResultRow(colKeys, y, r);
502
525
  });
@@ -518,37 +541,67 @@ var ActualSQLEntityDataProvider = /** @class */ (function () {
518
541
  }
519
542
  return result;
520
543
  };
521
- ActualSQLEntityDataProvider.prototype.buildSelect = function (e, selectedFields) {
522
- var e_4, _a;
523
- var select = '';
524
- var colKeys = [];
525
- try {
526
- for (var _b = tslib_1.__values(this.entity.fields), _c = _b.next(); !_c.done; _c = _b.next()) {
527
- var x = _c.value;
528
- if (selectedFields && !selectedFields.includes(x.key))
529
- continue;
530
- if (x.isServerExpression) {
531
- }
532
- else {
533
- if (colKeys.length > 0)
534
- select += ', ';
535
- select += e.$dbNameOf(x);
536
- if (x.options.sqlExpression)
537
- select += ' as ' + x.key;
538
- colKeys.push(x);
544
+ ActualSQLEntityDataProvider.prototype.buildSelect = function (e, r, selectedFields, args) {
545
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
546
+ var select, colKeys, _a, _b, x, sql, e_4_1;
547
+ var e_4, _c;
548
+ return tslib_1.__generator(this, function (_d) {
549
+ switch (_d.label) {
550
+ case 0:
551
+ select = '';
552
+ colKeys = [];
553
+ _d.label = 1;
554
+ case 1:
555
+ _d.trys.push([1, 9, 10, 11]);
556
+ _a = tslib_1.__values(this.entity.fields), _b = _a.next();
557
+ _d.label = 2;
558
+ case 2:
559
+ if (!!_b.done) return [3 /*break*/, 8];
560
+ x = _b.value;
561
+ if (selectedFields && !selectedFields.includes(x.key))
562
+ return [3 /*break*/, 7];
563
+ if (!x.isServerExpression) return [3 /*break*/, 3];
564
+ return [3 /*break*/, 7];
565
+ case 3:
566
+ if (colKeys.length > 0)
567
+ select += ', ';
568
+ if (!(typeof x.options.sqlExpression === 'function')) return [3 /*break*/, 5];
569
+ return [4 /*yield*/, x[fieldDbName_js_1.originalSqlExpressionKey](this.entity, args, r)];
570
+ case 4:
571
+ sql = _d.sent();
572
+ if (sql.includes(' '))
573
+ select += '(' + sql + ')';
574
+ else
575
+ select += sql;
576
+ return [3 /*break*/, 6];
577
+ case 5:
578
+ select += e.$dbNameOf(x);
579
+ _d.label = 6;
580
+ case 6:
581
+ if (x.options.sqlExpression)
582
+ select += ' as ' + x.key;
583
+ colKeys.push(x);
584
+ _d.label = 7;
585
+ case 7:
586
+ _b = _a.next();
587
+ return [3 /*break*/, 2];
588
+ case 8: return [3 /*break*/, 11];
589
+ case 9:
590
+ e_4_1 = _d.sent();
591
+ e_4 = { error: e_4_1 };
592
+ return [3 /*break*/, 11];
593
+ case 10:
594
+ try {
595
+ if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
596
+ }
597
+ finally { if (e_4) throw e_4.error; }
598
+ return [7 /*endfinally*/];
599
+ case 11: return [2 /*return*/, { colKeys: colKeys, select: select }];
539
600
  }
540
- }
541
- }
542
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
543
- finally {
544
- try {
545
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
546
- }
547
- finally { if (e_4) throw e_4.error; }
548
- }
549
- return { colKeys: colKeys, select: select };
601
+ });
602
+ });
550
603
  };
551
- ActualSQLEntityDataProvider.prototype.update = function (id, data) {
604
+ ActualSQLEntityDataProvider.prototype.update = function (id, data, options) {
552
605
  return tslib_1.__awaiter(this, void 0, void 0, function () {
553
606
  var e, r, statement, added, _a, _b, x, v, idFilter, f, _c, _d, colKeys, select, returning;
554
607
  var e_5, _e;
@@ -573,7 +626,7 @@ var ActualSQLEntityDataProvider = /** @class */ (function () {
573
626
  added = true;
574
627
  else
575
628
  statement += ', ';
576
- statement += e.$dbNameOf(x) + ' = ' + r.param(v);
629
+ statement += e.$dbNameOf(x) + ' = ' + (0, filter_consumer_bridge_to_sql_request_js_1.toDbSql)(r, x, v);
577
630
  }
578
631
  }
579
632
  }
@@ -592,10 +645,14 @@ var ActualSQLEntityDataProvider = /** @class */ (function () {
592
645
  return [4 /*yield*/, f.resolveWhere()];
593
646
  case 2:
594
647
  statement = _c + _f.sent();
595
- _d = this.buildSelect(e), colKeys = _d.colKeys, select = _d.select;
648
+ return [4 /*yield*/, this.buildSelect(e, r, undefined, undefined)];
649
+ case 3:
650
+ _d = _f.sent(), colKeys = _d.colKeys, select = _d.select;
596
651
  returning = true;
597
652
  if (this.sql._getSourceSql().doesNotSupportReturningSyntax)
598
653
  returning = false;
654
+ if ((options === null || options === void 0 ? void 0 : options.select) === 'none')
655
+ returning = false;
599
656
  if (returning &&
600
657
  this.sql._getSourceSql().doesNotSupportReturningSyntaxOnlyForUpdate)
601
658
  returning = false;
@@ -605,6 +662,8 @@ var ActualSQLEntityDataProvider = /** @class */ (function () {
605
662
  var _a, _b;
606
663
  (_b = (_a = _this.sql._getSourceSql()).afterMutation) === null || _b === void 0 ? void 0 : _b.call(_a);
607
664
  if (!returning) {
665
+ if ((options === null || options === void 0 ? void 0 : options.select) === 'none')
666
+ return undefined;
608
667
  return getRowAfterUpdate(_this.entity, _this, data, id, 'update');
609
668
  }
610
669
  if (sqlResult.rows.length != 1)
@@ -643,7 +702,7 @@ var ActualSQLEntityDataProvider = /** @class */ (function () {
643
702
  });
644
703
  });
645
704
  };
646
- ActualSQLEntityDataProvider.prototype.insert = function (data) {
705
+ ActualSQLEntityDataProvider.prototype.insert = function (data, options) {
647
706
  return tslib_1.__awaiter(this, void 0, void 0, function () {
648
707
  var e, r, cols, vals, added, _a, _b, x, v, statement, _c, colKeys, select;
649
708
  var e_6, _d;
@@ -672,7 +731,7 @@ var ActualSQLEntityDataProvider = /** @class */ (function () {
672
731
  vals += ', ';
673
732
  }
674
733
  cols += e.$dbNameOf(x);
675
- vals += r.param(v);
734
+ vals += (0, filter_consumer_bridge_to_sql_request_js_1.toDbSql)(r, x, v);
676
735
  }
677
736
  }
678
737
  }
@@ -685,8 +744,11 @@ var ActualSQLEntityDataProvider = /** @class */ (function () {
685
744
  finally { if (e_6) throw e_6.error; }
686
745
  }
687
746
  statement = "insert into ".concat(e.$entityName, " (").concat(cols, ") values (").concat(vals, ")");
688
- _c = this.buildSelect(e), colKeys = _c.colKeys, select = _c.select;
689
- if (!this.sql._getSourceSql().doesNotSupportReturningSyntax)
747
+ return [4 /*yield*/, this.buildSelect(e, r, undefined, undefined)];
748
+ case 2:
749
+ _c = _e.sent(), colKeys = _c.colKeys, select = _c.select;
750
+ if (!this.sql._getSourceSql().doesNotSupportReturningSyntax &&
751
+ !((options === null || options === void 0 ? void 0 : options.select) === 'none'))
690
752
  statement += ' returning ' + select;
691
753
  return [4 /*yield*/, r.execute(statement).then(function (sql) {
692
754
  var _a, _b;
@@ -697,6 +759,8 @@ var ActualSQLEntityDataProvider = /** @class */ (function () {
697
759
  if (typeof id_1 !== 'number')
698
760
  throw new Error('Auto increment, for a database that is does not support returning syntax, should return an array with the single last added id. Instead it returned: ' +
699
761
  JSON.stringify(id_1));
762
+ if ((options === null || options === void 0 ? void 0 : options.select) === 'none')
763
+ return undefined;
700
764
  return _this.find({
701
765
  where: new filter_interfaces_js_1.Filter(function (x) {
702
766
  return x.isEqualTo(_this.entity.idMetadata.field, id_1);
@@ -704,12 +768,16 @@ var ActualSQLEntityDataProvider = /** @class */ (function () {
704
768
  }).then(function (r) { return r[0]; });
705
769
  }
706
770
  else {
771
+ if ((options === null || options === void 0 ? void 0 : options.select) === 'none')
772
+ return undefined;
707
773
  return getRowAfterUpdate(_this.entity, _this, data, undefined, 'insert');
708
774
  }
709
775
  }
776
+ if ((options === null || options === void 0 ? void 0 : options.select) === 'none')
777
+ return undefined;
710
778
  return _this.buildResultRow(colKeys, sql.rows[0], sql);
711
779
  })];
712
- case 2: return [2 /*return*/, _e.sent()];
780
+ case 3: return [2 /*return*/, _e.sent()];
713
781
  }
714
782
  });
715
783
  });
@@ -1,3 +1,4 @@
1
- import type { EntityMetadata } from "../remult3/remult3.js";
1
+ import type { EntityMetadata } from '../remult3/remult3.js';
2
2
  import type { FieldMetadata } from '../column-interfaces.js';
3
+ export declare const originalSqlExpressionKey: unique symbol;
3
4
  export declare function fieldDbName(f: FieldMetadata, meta: EntityMetadata, wrapIdentifier?: (name: string) => string, forceSqlExpression?: boolean): Promise<string>;
@@ -1,9 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.originalSqlExpressionKey = void 0;
3
4
  exports.fieldDbName = fieldDbName;
4
5
  var tslib_1 = require("tslib");
5
6
  var relationInfoMember_js_1 = require("../remult3/relationInfoMember.js");
6
7
  var sqlExpressionInProgressKey = Symbol.for("sqlExpressionInProgressKey");
8
+ exports.originalSqlExpressionKey = Symbol.for("originalSqlExpressionKey");
7
9
  function fieldDbName(f_1, meta_1) {
8
10
  return tslib_1.__awaiter(this, arguments, void 0, function (f, meta, wrapIdentifier, forceSqlExpression) {
9
11
  var result_1, rel, field, fInfo;
@@ -23,7 +25,9 @@ function fieldDbName(f_1, meta_1) {
23
25
  _a.trys.push([1, , 3, 4]);
24
26
  ;
25
27
  f[sqlExpressionInProgressKey] = true;
26
- return [4 /*yield*/, f.options.sqlExpression(meta)];
28
+ if (!f[exports.originalSqlExpressionKey])
29
+ f[exports.originalSqlExpressionKey] = f.options.sqlExpression;
30
+ return [4 /*yield*/, f.options.sqlExpression(meta, undefined, undefined)];
27
31
  case 2:
28
32
  result_1 = _a.sent();
29
33
  if (!result_1.includes('\0'))
@@ -84,3 +84,4 @@ export interface dbNamesOfOptions {
84
84
  }
85
85
  export declare function dbNamesOf<entityType>(repo: EntityMetadataOverloads<entityType>, wrapIdentifierOrOptions?: ((name: string) => string) | dbNamesOfOptions): Promise<EntityDbNames<entityType>>;
86
86
  export declare function dbNamesOfWithForceSqlExpression<entityType>(repo: EntityMetadataOverloads<entityType>, wrapIdentifierOrOptions?: ((name: string) => string) | dbNamesOfOptions): Promise<EntityDbNames<entityType>>;
87
+ export declare function toDbSql(r: SqlCommandWithParameters, field: FieldMetadata, val: any): string;
@@ -6,6 +6,7 @@ exports.shouldNotCreateField = shouldNotCreateField;
6
6
  exports.shouldCreateEntity = shouldCreateEntity;
7
7
  exports.dbNamesOf = dbNamesOf;
8
8
  exports.dbNamesOfWithForceSqlExpression = dbNamesOfWithForceSqlExpression;
9
+ exports.toDbSql = toDbSql;
9
10
  var tslib_1 = require("tslib");
10
11
  var sql_database_js_1 = require("../data-providers/sql-database.js");
11
12
  var remult_proxy_js_1 = require("../remult-proxy.js");
@@ -162,7 +163,7 @@ var FilterConsumerBridgeToSqlRequest = /** @class */ (function () {
162
163
  this.addToWhere(this.nameProvider.$dbNameOf(col) +
163
164
  ' in (' +
164
165
  val
165
- .map(function (x) { return _this.r.param(col.valueConverter.toDb(x)); })
166
+ .map(function (x) { return toDbSql(_this.r, col, col.valueConverter.toDb(x)); })
166
167
  .join(',') +
167
168
  ')');
168
169
  else
@@ -250,7 +251,7 @@ var FilterConsumerBridgeToSqlRequest = /** @class */ (function () {
250
251
  ' ' +
251
252
  operator +
252
253
  ' ' +
253
- this.r.param(col.valueConverter.toDb(val));
254
+ toDbSql(this.r, col, col.valueConverter.toDb(val));
254
255
  this.addToWhere(x);
255
256
  return [2 /*return*/];
256
257
  });
@@ -431,3 +432,7 @@ function internalDbNamesOf(repo_1, wrapIdentifierOrOptions_1) {
431
432
  });
432
433
  });
433
434
  }
435
+ function toDbSql(r, field, val) {
436
+ var _a;
437
+ return ((_a = field.valueConverter.toDbSql) !== null && _a !== void 0 ? _a : (function (x) { return x; }))(r.param(val));
438
+ }
@@ -195,11 +195,11 @@ var RemultProxy = /** @class */ (function () {
195
195
  .repo.apply(_b, tslib_1.__spreadArray([], tslib_1.__read(args), false)))
196
196
  .getEntityRef.apply(_a, tslib_1.__spreadArray([], tslib_1.__read(args2), false));
197
197
  },
198
- _a.insert = function (args2) {
198
+ _a.insert = function (args2, args3) {
199
199
  var _a;
200
200
  return (_a = self
201
201
  .remultFactory())
202
- .repo.apply(_a, tslib_1.__spreadArray([], tslib_1.__read(args), false)).insert(args2);
202
+ .repo.apply(_a, tslib_1.__spreadArray([], tslib_1.__read(args), false)).insert(args2, args3);
203
203
  },
204
204
  _a.liveQuery = function () {
205
205
  var _a, _b;
@@ -238,11 +238,11 @@ var RemultProxy = /** @class */ (function () {
238
238
  .remultFactory())
239
239
  .repo.apply(_a, tslib_1.__spreadArray([], tslib_1.__read(args), false)).upsert(args2);
240
240
  },
241
- _a.update = function (a, b) {
241
+ _a.update = function (a, b, c) {
242
242
  var _a;
243
243
  return (_a = self
244
244
  .remultFactory())
245
- .repo.apply(_a, tslib_1.__spreadArray([], tslib_1.__read(args), false)).update(a, b);
245
+ .repo.apply(_a, tslib_1.__spreadArray([], tslib_1.__read(args), false)).update(a, b, c);
246
246
  },
247
247
  _a);
248
248
  entityCache.set(args[1], result);