remult 0.25.5 → 0.25.6-exp.1

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.
@@ -19,6 +19,7 @@ export class KnexDataProvider {
19
19
  throw 'the data provider is not an KnexDataProvider';
20
20
  return r.knex;
21
21
  }
22
+ wrapIdentifier = (x) => this.knex.ref(x) + '';
22
23
  getEntityDataProvider(entity) {
23
24
  if (!supportsJsonLoadingAndSaving(this.knex))
24
25
  for (const f of entity.fields.toArray()) {
@@ -64,7 +65,7 @@ export class KnexDataProvider {
64
65
  }
65
66
  static async filterToRaw(entity, condition) {
66
67
  const repo = getRepository(entity);
67
- var b = new FilterConsumerBridgeToKnexRequest(await dbNamesOf(repo.metadata));
68
+ var b = new FilterConsumerBridgeToKnexRequest(await dbNamesOf(repo.metadata, (x) => x));
68
69
  b._addWhere = false;
69
70
  await (await getRepositoryInternals(repo).translateWhereToFilter(condition)).__applyToConsumer(b);
70
71
  let r = await b.resolveWhere();
@@ -150,7 +151,7 @@ class KnexEntityDataProvider {
150
151
  });
151
152
  }
152
153
  async init() {
153
- const r = (await dbNamesOf(this.entity));
154
+ const r = (await dbNamesOf(this.entity, (x) => x));
154
155
  return {
155
156
  $dbNameOf: (f) => {
156
157
  let fm = f;
@@ -347,7 +348,7 @@ export class KnexSchemaBuilder {
347
348
  }
348
349
  async ensureSchema(entities) {
349
350
  for (const entity of entities) {
350
- let e = await dbNamesOf(entity);
351
+ let e = await dbNamesOf(entity, (x) => x);
351
352
  try {
352
353
  if (!entity.options.sqlExpression) {
353
354
  if (e.$entityName.toLowerCase().indexOf('from ') < 0) {
@@ -363,7 +364,7 @@ export class KnexSchemaBuilder {
363
364
  }
364
365
  }
365
366
  async createIfNotExist(entity) {
366
- const e = await dbNamesOf(entity);
367
+ const e = await dbNamesOf(entity, (x) => x);
367
368
  if (!(await this.knex.schema.hasTable(e.$entityName))) {
368
369
  let cols = new Map();
369
370
  for (const f of entity.fields) {
@@ -388,7 +389,7 @@ export class KnexSchemaBuilder {
388
389
  }
389
390
  }
390
391
  async addColumnIfNotExist(entity, c) {
391
- let e = await dbNamesOf(entity);
392
+ let e = await dbNamesOf(entity, (x) => x);
392
393
  if (shouldNotCreateField(c(entity), e))
393
394
  return;
394
395
  let col = c(entity);
@@ -400,7 +401,7 @@ export class KnexSchemaBuilder {
400
401
  }
401
402
  }
402
403
  async verifyAllColumns(entity) {
403
- let e = await dbNamesOf(entity);
404
+ let e = await dbNamesOf(entity, (x) => x);
404
405
  try {
405
406
  for (const col of entity.fields.toArray()) {
406
407
  if (!shouldNotCreateField(col, e)) {
@@ -7,6 +7,7 @@ export function remultNext(options) {
7
7
  return Object.assign((req, res) => result.handle(req, res).then(() => { }), result, {
8
8
  getRemult: (req) => result.getRemult(req),
9
9
  openApiDoc: (arg) => result.openApiDoc(arg),
10
+ withRemult: (req, what) => result.withRemultAsync(req, what),
10
11
  }, {
11
12
  getServerSideProps: (getServerPropsFunction) => {
12
13
  return (context) => {
@@ -274,12 +274,16 @@ export class RemultServerImplementation {
274
274
  }
275
275
  process(what) {
276
276
  return async (req, origRes) => {
277
- const genReq = this.coreOptions.buildGenericRequestInfo(req);
278
- if (!genReq.query) {
279
- genReq.query = req['_tempQuery'];
277
+ const genReq = req
278
+ ? this.coreOptions.buildGenericRequestInfo(req)
279
+ : undefined;
280
+ if (req) {
281
+ if (!genReq.query) {
282
+ genReq.query = req['_tempQuery'];
283
+ }
284
+ if (!genReq.params)
285
+ genReq.params = req['_tempParams'];
280
286
  }
281
- if (!genReq.params)
282
- genReq.params = req['_tempParams'];
283
287
  let myReq = new ExpressRequestBridgeToDataApiRequest(genReq);
284
288
  let myRes = new ExpressResponseBridgeToDataApiResponse(origRes, req);
285
289
  await this.runWithRemult(async (remult) => {
@@ -653,7 +657,7 @@ export class RemultServerImplementation {
653
657
  class ExpressRequestBridgeToDataApiRequest {
654
658
  r;
655
659
  get(key) {
656
- return this.r.query[key];
660
+ return this.r?.query[key];
657
661
  }
658
662
  constructor(r) {
659
663
  this.r = r;
@@ -690,8 +694,8 @@ class ExpressResponseBridgeToDataApiResponse {
690
694
  console.error({
691
695
  message: data.message,
692
696
  stack: data.stack?.split('\n'),
693
- url: this.req.url,
694
- method: this.req.method,
697
+ url: this.req?.url,
698
+ method: this.req?.method,
695
699
  });
696
700
  this.setStatus(400).json(data);
697
701
  }
@@ -25,7 +25,7 @@ export class ArrayEntityDataProvider {
25
25
  async init() {
26
26
  if (this.__names)
27
27
  return this.__names;
28
- this.__names = await dbNamesOf(this.entity);
28
+ this.__names = await dbNamesOf(this.entity, (x) => x);
29
29
  for (const r of this.rows) {
30
30
  this.verifyThatRowHasAllNotNullColumns(r, this.__names);
31
31
  }
@@ -1,4 +1,5 @@
1
1
  import { SqlDatabase } from '../data-providers/sql-database.js';
2
+ import { remult } from '../remult-proxy.js';
2
3
  import { getEntityMetadata } from '../remult3/RepositoryImplementation.js';
3
4
  import { getRelationFieldInfo } from '../remult3/relationInfoMember.js';
4
5
  export class FilterConsumerBridgeToSqlRequest {
@@ -158,8 +159,13 @@ export function shouldNotCreateField(field, dbNames) {
158
159
  return (field.isServerExpression ||
159
160
  (field.options.sqlExpression && field.dbName != dbNames.$dbNameOf(field)));
160
161
  }
161
- export async function dbNamesOf(repo, wrapIdentifier = (x) => x) {
162
+ export async function dbNamesOf(repo, wrapIdentifier) {
162
163
  var meta = getEntityMetadata(repo);
164
+ if (!wrapIdentifier) {
165
+ wrapIdentifier = remult.dataProvider.wrapIdentifier;
166
+ }
167
+ if (!wrapIdentifier)
168
+ wrapIdentifier = (x) => x;
163
169
  const result = {
164
170
  $entityName: await entityDbName(meta, wrapIdentifier),
165
171
  toString: () => result.$entityName,
@@ -192,7 +198,15 @@ export async function fieldDbName(f, meta, wrapIdentifier = (x) => x) {
192
198
  if (f.options.sqlExpression) {
193
199
  let result;
194
200
  if (typeof f.options.sqlExpression === 'function') {
195
- result = await f.options.sqlExpression(meta);
201
+ const prev = f.options.sqlExpression;
202
+ try {
203
+ f.options.sqlExpression =
204
+ "recursive sqlExpression call for field '" + f.key + "'. ";
205
+ result = await prev(meta);
206
+ }
207
+ finally {
208
+ f.options.sqlExpression = prev;
209
+ }
196
210
  }
197
211
  else
198
212
  result = f.options.sqlExpression;
@@ -112,6 +112,7 @@ remult.apiClient.url='localhost:3007/api
112
112
  //y2 - should enforce integer - currently we probably round / truncate it
113
113
  //p1 - adjust react tutorial to esm
114
114
  //p1 - write docs on with remult - and usage in init api
115
+ //p1 - document value converter - including field type in the db
115
116
  /*y1 - discuss sql stuff:
116
117
  https://discord.com/channels/975754286384418847/975754286384418852/1198997156678357043
117
118
  https://codesandbox.io/p/devbox/demo-sql-expression-forked-f94p6m?file=%2Fsrc%2Findex.ts%3A21%2C3-21%2C12&workspaceId=c0f7eccf-c151-423b-ac8e-0f0f3e1ad350
@@ -119,3 +120,5 @@ remult.apiClient.url='localhost:3007/api
119
120
 
120
121
 
121
122
  */
123
+ //p1 - make dbNames of have a default wrapIdentifier based on the current data provider
124
+ //p1 - prevent circular in sql expression
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "remult",
3
- "version": "0.25.5",
3
+ "version": "0.25.6-exp.1",
4
4
  "description": "A CRUD framework for full-stack TypeScript",
5
5
  "homepage": "https://remult.dev",
6
6
  "repository": {
@@ -4,10 +4,12 @@ import type { FieldMetadata } from '../src/column-interfaces.js';
4
4
  import type { DataProvider, EntityDataProvider } from '../src/data-interfaces.js';
5
5
  import type { EntityFilter, EntityMetadata } from '../src/remult3/remult3.js';
6
6
  import type { RepositoryOverloads } from '../src/remult3/RepositoryImplementation.js';
7
- export declare class KnexDataProvider implements DataProvider {
7
+ import type { HasWrapIdentifier } from '../src/sql-command.js';
8
+ export declare class KnexDataProvider implements DataProvider, HasWrapIdentifier {
8
9
  knex: Knex;
9
10
  constructor(knex: Knex);
10
11
  static getDb(remult?: Remult): Knex<any, any[]>;
12
+ wrapIdentifier: (name: string) => string;
11
13
  getEntityDataProvider(entity: EntityMetadata<any>): EntityDataProvider;
12
14
  transaction(action: (dataProvider: DataProvider) => Promise<void>): Promise<void>;
13
15
  static rawFilter(build: CustomKnexFilterBuilderFunction): EntityFilter<any>;
@@ -14,7 +14,9 @@ var repository_internals_js_1 = require("../src/remult3/repository-internals.js"
14
14
  var remult_static_js_1 = require("../src/remult-static.js");
15
15
  var KnexDataProvider = /** @class */ (function () {
16
16
  function KnexDataProvider(knex) {
17
+ var _this = this;
17
18
  this.knex = knex;
19
+ this.wrapIdentifier = function (x) { return _this.knex.ref(x) + ''; };
18
20
  }
19
21
  KnexDataProvider.getDb = function (remult) {
20
22
  var r = (remult || remult_proxy_js_1.remult).dataProvider;
@@ -106,7 +108,7 @@ var KnexDataProvider = /** @class */ (function () {
106
108
  case 0:
107
109
  repo = (0, RepositoryImplementation_js_1.getRepository)(entity);
108
110
  _a = FilterConsumerBridgeToKnexRequest.bind;
109
- return [4 /*yield*/, (0, filter_consumer_bridge_to_sql_request_js_1.dbNamesOf)(repo.metadata)];
111
+ return [4 /*yield*/, (0, filter_consumer_bridge_to_sql_request_js_1.dbNamesOf)(repo.metadata, function (x) { return x; })];
110
112
  case 1:
111
113
  b = new (_a.apply(FilterConsumerBridgeToKnexRequest, [void 0, _b.sent()]))();
112
114
  b._addWhere = false;
@@ -255,7 +257,7 @@ var KnexEntityDataProvider = /** @class */ (function () {
255
257
  var _this = this;
256
258
  return tslib_1.__generator(this, function (_a) {
257
259
  switch (_a.label) {
258
- case 0: return [4 /*yield*/, (0, filter_consumer_bridge_to_sql_request_js_1.dbNamesOf)(this.entity)];
260
+ case 0: return [4 /*yield*/, (0, filter_consumer_bridge_to_sql_request_js_1.dbNamesOf)(this.entity, function (x) { return x; })];
259
261
  case 1:
260
262
  r = (_a.sent());
261
263
  return [2 /*return*/, {
@@ -679,7 +681,7 @@ var KnexSchemaBuilder = /** @class */ (function () {
679
681
  case 1:
680
682
  if (!!entities_1_1.done) return [3 /*break*/, 9];
681
683
  entity = entities_1_1.value;
682
- return [4 /*yield*/, (0, filter_consumer_bridge_to_sql_request_js_1.dbNamesOf)(entity)];
684
+ return [4 /*yield*/, (0, filter_consumer_bridge_to_sql_request_js_1.dbNamesOf)(entity, function (x) { return x; })];
683
685
  case 2:
684
686
  e = _b.sent();
685
687
  _b.label = 3;
@@ -725,7 +727,7 @@ var KnexSchemaBuilder = /** @class */ (function () {
725
727
  var _this = this;
726
728
  return tslib_1.__generator(this, function (_d) {
727
729
  switch (_d.label) {
728
- case 0: return [4 /*yield*/, (0, filter_consumer_bridge_to_sql_request_js_1.dbNamesOf)(entity)];
730
+ case 0: return [4 /*yield*/, (0, filter_consumer_bridge_to_sql_request_js_1.dbNamesOf)(entity, function (x) { return x; })];
729
731
  case 1:
730
732
  e = _d.sent();
731
733
  return [4 /*yield*/, this.knex.schema.hasTable(e.$entityName)];
@@ -786,7 +788,7 @@ var KnexSchemaBuilder = /** @class */ (function () {
786
788
  var _this = this;
787
789
  return tslib_1.__generator(this, function (_a) {
788
790
  switch (_a.label) {
789
- case 0: return [4 /*yield*/, (0, filter_consumer_bridge_to_sql_request_js_1.dbNamesOf)(entity)];
791
+ case 0: return [4 /*yield*/, (0, filter_consumer_bridge_to_sql_request_js_1.dbNamesOf)(entity, function (x) { return x; })];
790
792
  case 1:
791
793
  e = _a.sent();
792
794
  if ((0, filter_consumer_bridge_to_sql_request_js_1.shouldNotCreateField)(c(entity), e))
@@ -813,7 +815,7 @@ var KnexSchemaBuilder = /** @class */ (function () {
813
815
  var e_11, _c;
814
816
  return tslib_1.__generator(this, function (_d) {
815
817
  switch (_d.label) {
816
- case 0: return [4 /*yield*/, (0, filter_consumer_bridge_to_sql_request_js_1.dbNamesOf)(entity)];
818
+ case 0: return [4 /*yield*/, (0, filter_consumer_bridge_to_sql_request_js_1.dbNamesOf)(entity, function (x) { return x; })];
817
819
  case 1:
818
820
  e = _d.sent();
819
821
  _d.label = 2;
package/remult-next.d.ts CHANGED
@@ -9,6 +9,7 @@ export type RemultNextServer = RemultServerCore<NextApiRequest> & NextApiHandler
9
9
  } = {
10
10
  [key: string]: any;
11
11
  }, Q extends ParsedUrlQuery = ParsedUrlQuery, D extends PreviewData = PreviewData>(getServerPropsFunction: GetServerSideProps<P, Q, D>): GetServerSideProps<P, Q, D>;
12
+ withRemult<T>(req: NextApiRequest | undefined, what: () => Promise<T>): Promise<T>;
12
13
  /** Creates a `next.js` handler with remult defined in the correct context
13
14
  * @see
14
15
  * https://remult.dev/tutorials/react-next/appendix-1-get-server-side-props.html#using-remult-in-a-next-js-api-handler
package/remult-next.js CHANGED
@@ -14,6 +14,7 @@ function remultNext(options) {
14
14
  return Object.assign(function (req, res) { return result.handle(req, res).then(function () { }); }, result, {
15
15
  getRemult: function (req) { return result.getRemult(req); },
16
16
  openApiDoc: function (arg) { return result.openApiDoc(arg); },
17
+ withRemult: function (req, what) { return result.withRemultAsync(req, what); },
17
18
  }, {
18
19
  getServerSideProps: function (getServerPropsFunction) {
19
20
  return function (context) {
@@ -532,12 +532,16 @@ var RemultServerImplementation = /** @class */ (function () {
532
532
  return tslib_1.__generator(this, function (_a) {
533
533
  switch (_a.label) {
534
534
  case 0:
535
- genReq = this.coreOptions.buildGenericRequestInfo(req);
536
- if (!genReq.query) {
537
- genReq.query = req['_tempQuery'];
535
+ genReq = req
536
+ ? this.coreOptions.buildGenericRequestInfo(req)
537
+ : undefined;
538
+ if (req) {
539
+ if (!genReq.query) {
540
+ genReq.query = req['_tempQuery'];
541
+ }
542
+ if (!genReq.params)
543
+ genReq.params = req['_tempParams'];
538
544
  }
539
- if (!genReq.params)
540
- genReq.params = req['_tempParams'];
541
545
  myReq = new ExpressRequestBridgeToDataApiRequest(genReq);
542
546
  myRes = new ExpressResponseBridgeToDataApiResponse(origRes, req);
543
547
  return [4 /*yield*/, this.runWithRemult(function (remult) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
@@ -977,7 +981,8 @@ var ExpressRequestBridgeToDataApiRequest = /** @class */ (function () {
977
981
  this.r = r;
978
982
  }
979
983
  ExpressRequestBridgeToDataApiRequest.prototype.get = function (key) {
980
- return this.r.query[key];
984
+ var _a;
985
+ return (_a = this.r) === null || _a === void 0 ? void 0 : _a.query[key];
981
986
  };
982
987
  return ExpressRequestBridgeToDataApiRequest;
983
988
  }());
@@ -1006,13 +1011,13 @@ var ExpressResponseBridgeToDataApiResponse = /** @class */ (function () {
1006
1011
  this.setStatus(404).end();
1007
1012
  };
1008
1013
  ExpressResponseBridgeToDataApiResponse.prototype.error = function (data) {
1009
- var _a;
1014
+ var _a, _b, _c;
1010
1015
  data = (0, data_api_js_1.serializeError)(data);
1011
1016
  console.error({
1012
1017
  message: data.message,
1013
1018
  stack: (_a = data.stack) === null || _a === void 0 ? void 0 : _a.split('\n'),
1014
- url: this.req.url,
1015
- method: this.req.method,
1019
+ url: (_b = this.req) === null || _b === void 0 ? void 0 : _b.url,
1020
+ method: (_c = this.req) === null || _c === void 0 ? void 0 : _c.method,
1016
1021
  });
1017
1022
  this.setStatus(400).json(data);
1018
1023
  };
@@ -32,7 +32,7 @@ var ArrayEntityDataProvider = /** @class */ (function () {
32
32
  if (this.__names)
33
33
  return [2 /*return*/, this.__names];
34
34
  _a = this;
35
- return [4 /*yield*/, (0, filter_consumer_bridge_to_sql_request_js_1.dbNamesOf)(this.entity)];
35
+ return [4 /*yield*/, (0, filter_consumer_bridge_to_sql_request_js_1.dbNamesOf)(this.entity, function (x) { return x; })];
36
36
  case 1:
37
37
  _a.__names = _e.sent();
38
38
  try {
@@ -1,10 +1,10 @@
1
1
  import type { DataProvider, EntityDataProvider } from '../data-interfaces.js';
2
- import type { SqlCommand, SqlCommandWithParameters, SqlImplementation, SqlResult } from '../sql-command.js';
2
+ import type { HasWrapIdentifier, SqlCommand, SqlCommandWithParameters, SqlImplementation, SqlResult } from '../sql-command.js';
3
3
  import type { Remult } from '../context.js';
4
4
  import type { CustomSqlFilterBuilderFunction, EntityDbNamesBase } from '../filter/filter-consumer-bridge-to-sql-request.js';
5
5
  import type { EntityFilter, EntityMetadata } from '../remult3/remult3.js';
6
6
  import type { RepositoryOverloads } from '../remult3/RepositoryImplementation.js';
7
- export declare class SqlDatabase implements DataProvider {
7
+ export declare class SqlDatabase implements DataProvider, HasWrapIdentifier {
8
8
  private sql;
9
9
  static getDb(remult?: Remult): SqlDatabase;
10
10
  createCommand(): SqlCommand;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.fieldDbName = exports.entityDbName = exports.dbNamesOf = exports.shouldNotCreateField = exports.isDbReadonly = exports.CustomSqlFilterBuilder = exports.FilterConsumerBridgeToSqlRequest = void 0;
4
4
  var tslib_1 = require("tslib");
5
5
  var sql_database_js_1 = require("../data-providers/sql-database.js");
6
+ var remult_proxy_js_1 = require("../remult-proxy.js");
6
7
  var RepositoryImplementation_js_1 = require("../remult3/RepositoryImplementation.js");
7
8
  var relationInfoMember_js_1 = require("../remult3/relationInfoMember.js");
8
9
  var FilterConsumerBridgeToSqlRequest = /** @class */ (function () {
@@ -269,7 +270,6 @@ function shouldNotCreateField(field, dbNames) {
269
270
  }
270
271
  exports.shouldNotCreateField = shouldNotCreateField;
271
272
  function dbNamesOf(repo, wrapIdentifier) {
272
- if (wrapIdentifier === void 0) { wrapIdentifier = function (x) { return x; }; }
273
273
  return tslib_1.__awaiter(this, void 0, void 0, function () {
274
274
  var meta, result, _a, _b, field, _c, _d, e_3_1;
275
275
  var _e, e_3, _f;
@@ -277,6 +277,11 @@ function dbNamesOf(repo, wrapIdentifier) {
277
277
  switch (_g.label) {
278
278
  case 0:
279
279
  meta = (0, RepositoryImplementation_js_1.getEntityMetadata)(repo);
280
+ if (!wrapIdentifier) {
281
+ wrapIdentifier = remult_proxy_js_1.remult.dataProvider.wrapIdentifier;
282
+ }
283
+ if (!wrapIdentifier)
284
+ wrapIdentifier = function (x) { return x; };
280
285
  _e = {};
281
286
  return [4 /*yield*/, entityDbName(meta, wrapIdentifier)];
282
287
  case 1:
@@ -347,26 +352,36 @@ exports.entityDbName = entityDbName;
347
352
  function fieldDbName(f, meta, wrapIdentifier) {
348
353
  if (wrapIdentifier === void 0) { wrapIdentifier = function (x) { return x; }; }
349
354
  return tslib_1.__awaiter(this, void 0, void 0, function () {
350
- var result, rel, field, fInfo;
355
+ var result, prev, rel, field, fInfo;
351
356
  return tslib_1.__generator(this, function (_a) {
352
357
  switch (_a.label) {
353
358
  case 0:
354
- _a.trys.push([0, , 5, 6]);
355
- if (!f.options.sqlExpression) return [3 /*break*/, 4];
359
+ _a.trys.push([0, , 8, 9]);
360
+ if (!f.options.sqlExpression) return [3 /*break*/, 7];
356
361
  result = void 0;
357
- if (!(typeof f.options.sqlExpression === 'function')) return [3 /*break*/, 2];
358
- return [4 /*yield*/, f.options.sqlExpression(meta)];
362
+ if (!(typeof f.options.sqlExpression === 'function')) return [3 /*break*/, 5];
363
+ prev = f.options.sqlExpression;
364
+ _a.label = 1;
359
365
  case 1:
360
- result = _a.sent();
361
- return [3 /*break*/, 3];
366
+ _a.trys.push([1, , 3, 4]);
367
+ f.options.sqlExpression =
368
+ "recursive sqlExpression call for field '" + f.key + "'. ";
369
+ return [4 /*yield*/, prev(meta)];
362
370
  case 2:
363
- result = f.options.sqlExpression;
364
- _a.label = 3;
371
+ result = _a.sent();
372
+ return [3 /*break*/, 4];
365
373
  case 3:
374
+ f.options.sqlExpression = prev;
375
+ return [7 /*endfinally*/];
376
+ case 4: return [3 /*break*/, 6];
377
+ case 5:
378
+ result = f.options.sqlExpression;
379
+ _a.label = 6;
380
+ case 6:
366
381
  if (!result)
367
382
  return [2 /*return*/, f.dbName];
368
383
  return [2 /*return*/, result];
369
- case 4:
384
+ case 7:
370
385
  rel = (0, relationInfoMember_js_1.getRelationFieldInfo)(f);
371
386
  field = (rel === null || rel === void 0 ? void 0 : rel.type) === 'toOne' &&
372
387
  f.options.field;
@@ -376,8 +391,8 @@ function fieldDbName(f, meta, wrapIdentifier) {
376
391
  return [2 /*return*/, fieldDbName(fInfo, meta, wrapIdentifier)];
377
392
  }
378
393
  return [2 /*return*/, wrapIdentifier(f.dbName)];
379
- case 5: return [7 /*endfinally*/];
380
- case 6: return [2 /*return*/];
394
+ case 8: return [7 /*endfinally*/];
395
+ case 9: return [2 /*return*/];
381
396
  }
382
397
  });
383
398
  });
@@ -113,6 +113,7 @@ remult.apiClient.url='localhost:3007/api
113
113
  //y2 - should enforce integer - currently we probably round / truncate it
114
114
  //p1 - adjust react tutorial to esm
115
115
  //p1 - write docs on with remult - and usage in init api
116
+ //p1 - document value converter - including field type in the db
116
117
  /*y1 - discuss sql stuff:
117
118
  https://discord.com/channels/975754286384418847/975754286384418852/1198997156678357043
118
119
  https://codesandbox.io/p/devbox/demo-sql-expression-forked-f94p6m?file=%2Fsrc%2Findex.ts%3A21%2C3-21%2C12&workspaceId=c0f7eccf-c151-423b-ac8e-0f0f3e1ad350
@@ -120,3 +121,5 @@ remult.apiClient.url='localhost:3007/api
120
121
 
121
122
 
122
123
  */
124
+ //p1 - make dbNames of have a default wrapIdentifier based on the current data provider
125
+ //p1 - prevent circular in sql expression
@@ -1,14 +1,16 @@
1
1
  import type { EntityMetadata } from './remult3/remult3.js';
2
- export interface SqlImplementation {
2
+ export interface SqlImplementation extends HasWrapIdentifier {
3
3
  getLimitSqlSyntax(limit: number, offset: number): any;
4
4
  createCommand(): SqlCommand;
5
5
  transaction(action: (sql: SqlImplementation) => Promise<void>): Promise<void>;
6
6
  entityIsUsedForTheFirstTime(entity: EntityMetadata): Promise<void>;
7
7
  ensureSchema?(entities: EntityMetadata[]): Promise<void>;
8
8
  supportsJsonColumnType?: boolean;
9
- wrapIdentifier?(name: string): string;
10
9
  afterMutation?: VoidFunction;
11
10
  }
11
+ export interface HasWrapIdentifier {
12
+ wrapIdentifier?(name: string): string;
13
+ }
12
14
  export interface SqlCommand extends SqlCommandWithParameters {
13
15
  execute(sql: string): Promise<SqlResult>;
14
16
  }