@saltcorn/sql 0.3.5 → 0.3.6

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 (2) hide show
  1. package/package.json +1 -1
  2. package/table-provider.js +11 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saltcorn/sql",
3
- "version": "0.3.5",
3
+ "version": "0.3.6",
4
4
  "description": "Actions and views based on SQL",
5
5
  "main": "index.js",
6
6
  "dependencies": {
package/table-provider.js CHANGED
@@ -193,14 +193,23 @@ const runQuery = async (cfg, where, opts) => {
193
193
  table: sqlCol?.expr?.table,
194
194
  column: db.sqlsanitize(k),
195
195
  };
196
+ if (!sqlCol) {
197
+ const starCol = (ast[0].columns || []).find((c) => c.type === "star_ref");
198
+ if (starCol)
199
+ left = {
200
+ type: "column_ref",
201
+ table: starCol?.expr?.table,
202
+ column: db.sqlsanitize(k),
203
+ };
204
+ }
196
205
  const newClause = {
197
206
  type: "binary_expr",
198
- operator: "=",
207
+ operator: where[k]?.ilike ? "ILIKE" : "=",
199
208
  left,
200
209
  right: { type: "number", value: "$" + phIndex },
201
210
  };
202
211
  phIndex += 1;
203
- phValues.push(where[k]);
212
+ phValues.push(where[k]?.ilike ? where[k]?.ilike : where[k]);
204
213
  if (!ast[0].where) ast[0].where = newClause;
205
214
  else {
206
215
  ast[0].where = {
@@ -234,7 +243,6 @@ const runQuery = async (cfg, where, opts) => {
234
243
  }
235
244
 
236
245
  const sqlQ = parser.sqlify(ast, opt);
237
- console.log(sqlQ, phValues);
238
246
  const qres = await client.query(sqlQ, phValues);
239
247
  qres.query = sqlQ;
240
248
  await client.query(`ROLLBACK;`);