@technicity/data-service-generator 0.4.6 → 0.4.7

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/dist/getSqlAst.js CHANGED
@@ -25,7 +25,9 @@ function getSqlAst(input) {
25
25
  argsMapped = _.cloneDeep(argsMapped);
26
26
  argsMapped.$where = argsMapped.$where[0];
27
27
  }
28
- const whereResult = getWhere(table, argsMapped, dialect, orderBy, rowWithMatchingCursor);
28
+ const whereResult = getWhere(
29
+ // table is escaped already
30
+ table, argsMapped, dialect, orderBy, rowWithMatchingCursor);
29
31
  if (whereResult == null) {
30
32
  return undefined;
31
33
  }
@@ -112,7 +114,9 @@ function getSqlAst(input) {
112
114
  }
113
115
  const argsMapped = _.cloneDeep(args);
114
116
  argsMapped.$where = argsMapped.$where[1];
115
- const whereResult = getWhere(table, argsMapped, dialect, orderBy, rowWithMatchingCursor);
117
+ const whereResult = getWhere(
118
+ // table is escaped already
119
+ table, argsMapped, dialect, orderBy, rowWithMatchingCursor);
116
120
  if (whereResult == null) {
117
121
  return undefined;
118
122
  }
package/dist/getWhere.js CHANGED
@@ -2,7 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getWhere = void 0;
4
4
  const stringifyWhere_1 = require("./stringifyWhere");
5
- function getWhere(table, args, dialect, orderBy, rowWithMatchingCursor) {
5
+ function getWhere(
6
+ // Note: `table` is not escaped in getWhere, so it should be escaped beforehand.
7
+ table, args, dialect, orderBy, rowWithMatchingCursor) {
6
8
  if (args?.$where == null && args?.$paginate == null) {
7
9
  return null;
8
10
  }
@@ -74,7 +74,7 @@ class RuntimeKSQL {
74
74
  delete input.args.$where[k];
75
75
  }
76
76
  }
77
- const where = getWhere_1.getWhere(tableKSQL, input.args, "mysql");
77
+ const where = getWhere_1.getWhere(SqlString.escapeId(tableKSQL), input.args, "mysql");
78
78
  if (!where) {
79
79
  throw new Error("Invalid $where");
80
80
  }
@@ -240,9 +240,10 @@ async function post(input) {
240
240
  exports.post = post;
241
241
  async function patch(input) {
242
242
  async function _patch() {
243
- const { dbCall, formatQuery } = input;
243
+ const { dbCall, formatQuery, dialect } = input;
244
+ const escapeId = stringifyWhere_1.getEscapeId(dialect);
244
245
  const tableArtifacts = input.artifacts[input.table];
245
- const where = getWhere_1.getWhere(input.table, input.args, input.dialect);
246
+ const where = getWhere_1.getWhere(escapeId(input.table), input.args, input.dialect);
246
247
  if (where == null) {
247
248
  throw new Error("Null where");
248
249
  }
@@ -337,9 +338,10 @@ function getUpdateQuery(table, data, where, dialect, formatQuery) {
337
338
  }
338
339
  async function patchList(input) {
339
340
  async function _patchList() {
340
- const { dbCall, formatQuery } = input;
341
+ const { dbCall, formatQuery, dialect } = input;
342
+ const escapeId = stringifyWhere_1.getEscapeId(dialect);
341
343
  const tableArtifacts = input.artifacts[input.table];
342
- const where = getWhere_1.getWhere(input.table, input.args, input.dialect);
344
+ const where = getWhere_1.getWhere(escapeId(input.table), input.args, input.dialect);
343
345
  if (where == null) {
344
346
  throw new Error("Null where");
345
347
  }
@@ -401,8 +403,9 @@ async function del(input) {
401
403
  }
402
404
  exports.del = del;
403
405
  async function deleteList(input) {
404
- const { dbCall, formatQuery } = input;
405
- const where = getWhere_1.getWhere(input.table, input.args, input.dialect);
406
+ const { dbCall, formatQuery, dialect } = input;
407
+ const escapeId = stringifyWhere_1.getEscapeId(dialect);
408
+ const where = getWhere_1.getWhere(escapeId(input.table), input.args, input.dialect);
406
409
  if (where == null) {
407
410
  throw new Error("Null where");
408
411
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@technicity/data-service-generator",
3
- "version": "0.4.6",
3
+ "version": "0.4.7",
4
4
  "main": "./dist/index.js",
5
5
  "files": [
6
6
  "dist"