unconventional 2.2.0 → 2.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.
@@ -228,13 +228,17 @@ function getConflict(model, action, constraint, where) {
228
228
  exports.getConflict = getConflict;
229
229
  /** A type-safe way to build filter strings */
230
230
  function buildFilter(field, operator, value) {
231
+ const quote = (item) => `'${item.replace(/'/g, "''")}'`;
231
232
  let formatted = `${value}`;
232
- if (typeof value === 'string')
233
- formatted = `'${value}'`;
234
- else if (Array.isArray(value))
235
- formatted = (typeof value[0] === 'string') ? `('${value.join("','")}')` : `(${value.join()})`;
236
- else if (value == null || db_types_1.NullSqlOperators.includes(operator))
233
+ if (value == null || db_types_1.NullSqlOperators.includes(operator)) {
237
234
  formatted = '';
235
+ }
236
+ else if (typeof value === 'string') {
237
+ formatted = quote(value);
238
+ }
239
+ else if (Array.isArray(value)) {
240
+ formatted = `(${value.map(item => typeof item === 'string' ? quote(item) : `${item}`).join(',')})`;
241
+ }
238
242
  return `${field} ${operator} ${formatted}`;
239
243
  }
240
244
  exports.buildFilter = buildFilter;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unconventional",
3
- "version": "2.2.0",
3
+ "version": "2.3.0",
4
4
  "description": "A complete server built on Cloudflare Workers/Pages",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -46,7 +46,7 @@
46
46
  },
47
47
  "peerDependencies": {
48
48
  "hono": "^4",
49
- "unconventional-pg-queries": "^1.8.0"
49
+ "unconventional-pg-queries": "^2.0.0"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@cloudflare/workers-types": "^4.20231121.0",
@@ -56,6 +56,6 @@
56
56
  "hono": "^4",
57
57
  "tsx": "^4.20.6",
58
58
  "typescript": "^5.3.3",
59
- "unconventional-pg-queries": "^1.8.0"
59
+ "unconventional-pg-queries": "^2.0.0"
60
60
  }
61
61
  }