pqb 0.7.11 → 0.7.12

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # pqb
2
2
 
3
+ ## 0.7.12
4
+
5
+ ### Patch Changes
6
+
7
+ - Improve usability of raw SQL
8
+
3
9
  ## 0.7.11
4
10
 
5
11
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -4,12 +4,12 @@ declare type AliasOrTable<T extends Pick<Query, 'tableAlias' | 'table'>> = T['ta
4
4
  declare type StringKey<K extends PropertyKey> = Exclude<K, symbol | number>;
5
5
  declare type RawExpression<C extends ColumnType = ColumnType> = {
6
6
  __raw: string;
7
- __values: unknown[];
7
+ __values?: Record<string, unknown> | false;
8
8
  __column: C;
9
9
  };
10
- declare const raw: (sql: string, ...values: unknown[]) => RawExpression;
10
+ declare const raw: (sql: string, values?: Record<string, unknown> | false) => RawExpression;
11
11
  declare const isRaw: (obj: object) => obj is RawExpression<ColumnType<unknown, Operators, unknown>>;
12
- declare const getRaw: (raw: RawExpression, values: unknown[]) => string;
12
+ declare const getRaw: (raw: RawExpression, valuesArray: unknown[]) => string;
13
13
  declare const getRawSql: (raw: RawExpression) => string;
14
14
  declare type Expression<T extends Query = Query, C extends ColumnType = ColumnType> = StringKey<keyof T['selectable']> | RawExpression<C>;
15
15
  declare type ExpressionOfType<T extends Query, C extends ColumnType, Type> = {
@@ -1356,7 +1356,7 @@ declare class MergeQueryMethods {
1356
1356
  _merge<T extends Query, Q extends Query>(this: T, q: Q): MergeQuery<T, Q>;
1357
1357
  }
1358
1358
 
1359
- declare type RawArgs<CT extends ColumnTypesBase, C extends ColumnType> = [column: (types: CT) => C, sql: string, ...values: unknown[]] | [sql: string, ...values: unknown[]];
1359
+ declare type RawArgs<CT extends ColumnTypesBase, C extends ColumnType> = [column: (types: CT) => C, sql: string, values?: Record<string, unknown>] | [sql: string, values?: Record<string, unknown>];
1360
1360
  declare class RawMethods {
1361
1361
  raw<T extends Query, C extends ColumnType>(this: T, ...args: RawArgs<T['columnTypes'], C>): RawExpression<C>;
1362
1362
  }
@@ -1900,11 +1900,11 @@ declare const Operators: {
1900
1900
  not: Fn<unknown> & {
1901
1901
  type: unknown;
1902
1902
  };
1903
- in: Fn<Query | unknown[] | RawExpression<ColumnType<unknown, Operators, unknown>>> & {
1904
- type: Query | unknown[] | RawExpression<ColumnType<unknown, Operators, unknown>>;
1903
+ in: Fn<Query | RawExpression<ColumnType<unknown, Operators, unknown>> | unknown[]> & {
1904
+ type: Query | RawExpression<ColumnType<unknown, Operators, unknown>> | unknown[];
1905
1905
  };
1906
- notIn: Fn<Query | unknown[] | RawExpression<ColumnType<unknown, Operators, unknown>>> & {
1907
- type: Query | unknown[] | RawExpression<ColumnType<unknown, Operators, unknown>>;
1906
+ notIn: Fn<Query | RawExpression<ColumnType<unknown, Operators, unknown>> | unknown[]> & {
1907
+ type: Query | RawExpression<ColumnType<unknown, Operators, unknown>> | unknown[];
1908
1908
  };
1909
1909
  };
1910
1910
  array: {
@@ -4195,11 +4195,11 @@ declare class JSONColumn<Type extends JSONTypeAny = JSONTypeAny> extends ColumnT
4195
4195
  not: ((key: string, value: unknown, values: unknown[]) => string) & {
4196
4196
  type: unknown;
4197
4197
  };
4198
- in: ((key: string, value: Query | unknown[] | RawExpression<ColumnType<unknown, Operators, unknown>>, values: unknown[]) => string) & {
4199
- type: Query | unknown[] | RawExpression<ColumnType<unknown, Operators, unknown>>;
4198
+ in: ((key: string, value: Query | RawExpression<ColumnType<unknown, Operators, unknown>> | unknown[], values: unknown[]) => string) & {
4199
+ type: Query | RawExpression<ColumnType<unknown, Operators, unknown>> | unknown[];
4200
4200
  };
4201
- notIn: ((key: string, value: Query | unknown[] | RawExpression<ColumnType<unknown, Operators, unknown>>, values: unknown[]) => string) & {
4202
- type: Query | unknown[] | RawExpression<ColumnType<unknown, Operators, unknown>>;
4201
+ notIn: ((key: string, value: Query | RawExpression<ColumnType<unknown, Operators, unknown>> | unknown[], values: unknown[]) => string) & {
4202
+ type: Query | RawExpression<ColumnType<unknown, Operators, unknown>> | unknown[];
4203
4203
  };
4204
4204
  };
4205
4205
  data: ColumnData & {
package/dist/index.esm.js CHANGED
@@ -156,181 +156,6 @@ const quote = (value) => {
156
156
  return `'${JSON.stringify(value).replace(singleQuoteRegex, "''")}'`;
157
157
  };
158
158
 
159
- const raw = (sql, ...values) => ({
160
- __raw: sql,
161
- __values: values
162
- });
163
- const isRaw = (obj) => "__raw" in obj;
164
- const getRaw = (raw2, values) => {
165
- values.push(...raw2.__values);
166
- return raw2.__raw;
167
- };
168
- const getRawSql = (raw2) => {
169
- return raw2.__raw;
170
- };
171
- const EMPTY_OBJECT = {};
172
- const getQueryParsers = (q) => {
173
- return q.query.parsers || q.columnsParsers;
174
- };
175
-
176
- const q = (sql) => `"${sql}"`;
177
- const qc = (column, quotedAs) => quotedAs ? `${quotedAs}.${q(column)}` : column;
178
- const quoteFullColumn = (fullColumn, quotedAs) => {
179
- const index = fullColumn.indexOf(".");
180
- if (index !== -1) {
181
- return `${q(fullColumn.slice(0, index))}.${q(fullColumn.slice(index + 1))}`;
182
- } else if (quotedAs) {
183
- return `${quotedAs}.${q(fullColumn)}`;
184
- } else {
185
- return q(fullColumn);
186
- }
187
- };
188
- const expressionToSql = (expr, values, quotedAs) => {
189
- return typeof expr === "object" && isRaw(expr) ? getRaw(expr, values) : quoteFullColumn(expr, quotedAs);
190
- };
191
- const quoteSchemaAndTable = (schema, table) => {
192
- return schema ? `${q(schema)}.${q(table)}` : q(table);
193
- };
194
- const addValue = (values, value) => {
195
- values.push(value);
196
- return `$${values.length}`;
197
- };
198
-
199
- var __defProp$p = Object.defineProperty;
200
- var __defProps$j = Object.defineProperties;
201
- var __getOwnPropDescs$j = Object.getOwnPropertyDescriptors;
202
- var __getOwnPropSymbols$q = Object.getOwnPropertySymbols;
203
- var __hasOwnProp$q = Object.prototype.hasOwnProperty;
204
- var __propIsEnum$q = Object.prototype.propertyIsEnumerable;
205
- var __defNormalProp$p = (obj, key, value) => key in obj ? __defProp$p(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
206
- var __spreadValues$p = (a, b) => {
207
- for (var prop in b || (b = {}))
208
- if (__hasOwnProp$q.call(b, prop))
209
- __defNormalProp$p(a, prop, b[prop]);
210
- if (__getOwnPropSymbols$q)
211
- for (var prop of __getOwnPropSymbols$q(b)) {
212
- if (__propIsEnum$q.call(b, prop))
213
- __defNormalProp$p(a, prop, b[prop]);
214
- }
215
- return a;
216
- };
217
- var __spreadProps$j = (a, b) => __defProps$j(a, __getOwnPropDescs$j(b));
218
- const createOperator = (fn) => {
219
- return Object.assign(fn, { type: void 0 });
220
- };
221
- const quoteValue = (arg, values, jsonArray) => {
222
- if (arg && typeof arg === "object") {
223
- if (!jsonArray && Array.isArray(arg)) {
224
- return `(${arg.map((value) => addValue(values, value)).join(", ")})`;
225
- }
226
- if ("toSql" in arg) {
227
- const sql = arg.toSql({ values });
228
- return `(${sql.text})`;
229
- }
230
- if (isRaw(arg)) {
231
- return getRaw(arg, values);
232
- }
233
- }
234
- return addValue(values, arg);
235
- };
236
- const all = {
237
- equals: () => createOperator(
238
- (key, value, values) => value === null ? `${key} IS NULL` : `${key} = ${quoteValue(value, values)}`
239
- ),
240
- not: () => createOperator(
241
- (key, value, values) => value === null ? `${key} IS NOT NULL` : `${key} <> ${quoteValue(value, values)}`
242
- ),
243
- in: () => createOperator(
244
- (key, value, values) => `${key} IN ${quoteValue(value, values)}`
245
- ),
246
- notIn: () => createOperator(
247
- (key, value, values) => `NOT ${key} IN ${quoteValue(value, values)}`
248
- ),
249
- lt: () => createOperator(
250
- (key, value, values) => `${key} < ${quoteValue(value, values)}`
251
- ),
252
- lte: () => createOperator(
253
- (key, value, values) => `${key} <= ${quoteValue(value, values)}`
254
- ),
255
- gt: () => createOperator(
256
- (key, value, values) => `${key} > ${quoteValue(value, values)}`
257
- ),
258
- gte: () => createOperator(
259
- (key, value, values) => `${key} >= ${quoteValue(value, values)}`
260
- ),
261
- contains: () => createOperator(
262
- (key, value, values) => `${key} ILIKE '%' || ${quoteValue(value, values)} || '%'`
263
- ),
264
- containsSensitive: () => createOperator(
265
- (key, value, values) => `${key} LIKE '%' || ${quoteValue(value, values)} || '%'`
266
- ),
267
- startsWith: () => createOperator(
268
- (key, value, values) => `${key} ILIKE ${quoteValue(value, values)} || '%'`
269
- ),
270
- startsWithSensitive: () => createOperator(
271
- (key, value, values) => `${key} LIKE ${quoteValue(value, values)} || '%'`
272
- ),
273
- endsWith: () => createOperator(
274
- (key, value, values) => `${key} ILIKE '%' || ${quoteValue(value, values)}`
275
- ),
276
- endsWithSensitive: () => createOperator(
277
- (key, value, values) => `${key} LIKE '%' || ${quoteValue(value, values)}`
278
- ),
279
- between: () => createOperator(
280
- (key, [from, to], values) => `${key} BETWEEN ${quoteValue(from, values)} AND ${quoteValue(
281
- to,
282
- values
283
- )}`
284
- ),
285
- jsonPath: () => createOperator(
286
- (key, [path, op, value], values) => `jsonb_path_query_first(${key}, ${quote(
287
- path
288
- )}) #>> '{}' ${op} ${quoteValue(value, values, true)}`
289
- ),
290
- jsonSupersetOf: () => createOperator(
291
- (key, value, values) => `${key} @> ${quoteValue(value, values, true)}`
292
- ),
293
- jsonSubsetOf: () => createOperator(
294
- (key, value, values) => `${key} <@ ${quoteValue(value, values, true)}`
295
- )
296
- };
297
- const base = () => ({
298
- equals: all.equals(),
299
- not: all.not(),
300
- in: all.in(),
301
- notIn: all.notIn()
302
- });
303
- const numeric = () => __spreadProps$j(__spreadValues$p({}, base()), {
304
- lt: all.lt(),
305
- lte: all.lte(),
306
- gt: all.gt(),
307
- gte: all.gte(),
308
- between: all.between()
309
- });
310
- const text$1 = () => __spreadProps$j(__spreadValues$p({}, base()), {
311
- contains: all.contains(),
312
- containsSensitive: all.containsSensitive(),
313
- startsWith: all.startsWith(),
314
- startsWithSensitive: all.startsWithSensitive(),
315
- endsWith: all.endsWith(),
316
- endsWithSensitive: all.endsWithSensitive()
317
- });
318
- const json = () => __spreadProps$j(__spreadValues$p({}, base()), {
319
- jsonPath: all.jsonPath(),
320
- jsonSupersetOf: all.jsonSupersetOf(),
321
- jsonSubsetOf: all.jsonSubsetOf()
322
- });
323
- const Operators = {
324
- any: base(),
325
- boolean: base(),
326
- number: numeric(),
327
- date: numeric(),
328
- time: numeric(),
329
- text: text$1(),
330
- json: json(),
331
- array: base()
332
- };
333
-
334
159
  const defaultsKey = Symbol("defaults");
335
160
  const queryTypeWithLimitOne = {
336
161
  one: true,
@@ -690,29 +515,29 @@ const pushIn = (ands, prefix, quotedAs, values, arg) => {
690
515
  );
691
516
  };
692
517
 
693
- var __defProp$o = Object.defineProperty;
694
- var __defProps$i = Object.defineProperties;
695
- var __getOwnPropDescs$i = Object.getOwnPropertyDescriptors;
696
- var __getOwnPropSymbols$p = Object.getOwnPropertySymbols;
697
- var __hasOwnProp$p = Object.prototype.hasOwnProperty;
698
- var __propIsEnum$p = Object.prototype.propertyIsEnumerable;
699
- var __defNormalProp$o = (obj, key, value) => key in obj ? __defProp$o(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
700
- var __spreadValues$o = (a, b) => {
518
+ var __defProp$p = Object.defineProperty;
519
+ var __defProps$j = Object.defineProperties;
520
+ var __getOwnPropDescs$j = Object.getOwnPropertyDescriptors;
521
+ var __getOwnPropSymbols$q = Object.getOwnPropertySymbols;
522
+ var __hasOwnProp$q = Object.prototype.hasOwnProperty;
523
+ var __propIsEnum$q = Object.prototype.propertyIsEnumerable;
524
+ var __defNormalProp$p = (obj, key, value) => key in obj ? __defProp$p(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
525
+ var __spreadValues$p = (a, b) => {
701
526
  for (var prop in b || (b = {}))
702
- if (__hasOwnProp$p.call(b, prop))
703
- __defNormalProp$o(a, prop, b[prop]);
704
- if (__getOwnPropSymbols$p)
705
- for (var prop of __getOwnPropSymbols$p(b)) {
706
- if (__propIsEnum$p.call(b, prop))
707
- __defNormalProp$o(a, prop, b[prop]);
527
+ if (__hasOwnProp$q.call(b, prop))
528
+ __defNormalProp$p(a, prop, b[prop]);
529
+ if (__getOwnPropSymbols$q)
530
+ for (var prop of __getOwnPropSymbols$q(b)) {
531
+ if (__propIsEnum$q.call(b, prop))
532
+ __defNormalProp$p(a, prop, b[prop]);
708
533
  }
709
534
  return a;
710
535
  };
711
- var __spreadProps$i = (a, b) => __defProps$i(a, __getOwnPropDescs$i(b));
536
+ var __spreadProps$j = (a, b) => __defProps$j(a, __getOwnPropDescs$j(b));
712
537
  const aggregateToSql = (ctx, model, item, quotedAs) => {
713
538
  var _a;
714
539
  const sql = [`${item.function}(`];
715
- ctx = __spreadProps$i(__spreadValues$o({}, ctx), { sql });
540
+ ctx = __spreadProps$j(__spreadValues$p({}, ctx), { sql });
716
541
  const options = item.options || EMPTY_OBJECT;
717
542
  if (options.distinct && !options.withinGroup)
718
543
  sql.push("DISTINCT ");
@@ -1153,7 +978,7 @@ const pushInsertSql = (ctx, model, query, quotedAs) => {
1153
978
  pushQueryValue(
1154
979
  q2,
1155
980
  "select",
1156
- isRaw(query.values) ? query.values : raw(encodeRow(ctx, query.values[0]))
981
+ isRaw(query.values) ? query.values : raw(encodeRow(ctx, query.values[0]), false)
1157
982
  );
1158
983
  ctx.sql.push(makeSql(q2, { values: ctx.values }).text);
1159
984
  } else {
@@ -1530,19 +1355,19 @@ const cloneQueryArrays = (q) => {
1530
1355
  }
1531
1356
  };
1532
1357
 
1533
- var __defProp$n = Object.defineProperty;
1534
- var __getOwnPropSymbols$o = Object.getOwnPropertySymbols;
1535
- var __hasOwnProp$o = Object.prototype.hasOwnProperty;
1536
- var __propIsEnum$o = Object.prototype.propertyIsEnumerable;
1537
- var __defNormalProp$n = (obj, key, value) => key in obj ? __defProp$n(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1538
- var __spreadValues$n = (a, b) => {
1358
+ var __defProp$o = Object.defineProperty;
1359
+ var __getOwnPropSymbols$p = Object.getOwnPropertySymbols;
1360
+ var __hasOwnProp$p = Object.prototype.hasOwnProperty;
1361
+ var __propIsEnum$p = Object.prototype.propertyIsEnumerable;
1362
+ var __defNormalProp$o = (obj, key, value) => key in obj ? __defProp$o(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1363
+ var __spreadValues$o = (a, b) => {
1539
1364
  for (var prop in b || (b = {}))
1540
- if (__hasOwnProp$o.call(b, prop))
1541
- __defNormalProp$n(a, prop, b[prop]);
1542
- if (__getOwnPropSymbols$o)
1543
- for (var prop of __getOwnPropSymbols$o(b)) {
1544
- if (__propIsEnum$o.call(b, prop))
1545
- __defNormalProp$n(a, prop, b[prop]);
1365
+ if (__hasOwnProp$p.call(b, prop))
1366
+ __defNormalProp$o(a, prop, b[prop]);
1367
+ if (__getOwnPropSymbols$p)
1368
+ for (var prop of __getOwnPropSymbols$p(b)) {
1369
+ if (__propIsEnum$p.call(b, prop))
1370
+ __defNormalProp$o(a, prop, b[prop]);
1546
1371
  }
1547
1372
  return a;
1548
1373
  };
@@ -1561,7 +1386,7 @@ const joinTruthy = (...strings) => {
1561
1386
  return strings.filter((string) => string).join("");
1562
1387
  };
1563
1388
  const getClonedQueryData = (query) => {
1564
- const cloned = __spreadValues$n({}, query);
1389
+ const cloned = __spreadValues$o({}, query);
1565
1390
  delete cloned[toSqlCacheKey];
1566
1391
  cloneQueryArrays(cloned);
1567
1392
  return cloned;
@@ -1591,6 +1416,206 @@ const pushOrNewArray = (arr, value) => {
1591
1416
  }
1592
1417
  };
1593
1418
 
1419
+ const raw = (sql, values) => ({
1420
+ __raw: sql,
1421
+ __values: values
1422
+ });
1423
+ const isRaw = (obj) => "__raw" in obj;
1424
+ const keys = [];
1425
+ const getRaw = (raw2, valuesArray) => {
1426
+ if (raw2.__values === false) {
1427
+ return raw2.__raw;
1428
+ }
1429
+ const arr = raw2.__raw.split("'");
1430
+ const values = raw2.__values || emptyObject;
1431
+ const len = arr.length;
1432
+ keys.length = 0;
1433
+ for (let i = 0; i < len; i += 2) {
1434
+ arr[i] = arr[i].replace(/\$(\w+)/g, (_, key) => {
1435
+ const value = values[key];
1436
+ if (value === void 0) {
1437
+ throw new Error(`Query variable \`${key}\` is not provided`);
1438
+ }
1439
+ keys.push(key);
1440
+ valuesArray.push(value);
1441
+ return `$${valuesArray.length}`;
1442
+ });
1443
+ }
1444
+ if (keys.length > 0 && keys.length < Object.keys(values).length) {
1445
+ for (const key in values) {
1446
+ if (!keys.includes(key)) {
1447
+ throw new Error(`Query variable \`${key}\` is unused`);
1448
+ }
1449
+ }
1450
+ }
1451
+ return arr.join("'");
1452
+ };
1453
+ const getRawSql = (raw2) => {
1454
+ return raw2.__raw;
1455
+ };
1456
+ const EMPTY_OBJECT = {};
1457
+ const getQueryParsers = (q) => {
1458
+ return q.query.parsers || q.columnsParsers;
1459
+ };
1460
+
1461
+ const q = (sql) => `"${sql}"`;
1462
+ const qc = (column, quotedAs) => quotedAs ? `${quotedAs}.${q(column)}` : column;
1463
+ const quoteFullColumn = (fullColumn, quotedAs) => {
1464
+ const index = fullColumn.indexOf(".");
1465
+ if (index !== -1) {
1466
+ return `${q(fullColumn.slice(0, index))}.${q(fullColumn.slice(index + 1))}`;
1467
+ } else if (quotedAs) {
1468
+ return `${quotedAs}.${q(fullColumn)}`;
1469
+ } else {
1470
+ return q(fullColumn);
1471
+ }
1472
+ };
1473
+ const expressionToSql = (expr, values, quotedAs) => {
1474
+ return typeof expr === "object" && isRaw(expr) ? getRaw(expr, values) : quoteFullColumn(expr, quotedAs);
1475
+ };
1476
+ const quoteSchemaAndTable = (schema, table) => {
1477
+ return schema ? `${q(schema)}.${q(table)}` : q(table);
1478
+ };
1479
+ const addValue = (values, value) => {
1480
+ values.push(value);
1481
+ return `$${values.length}`;
1482
+ };
1483
+
1484
+ var __defProp$n = Object.defineProperty;
1485
+ var __defProps$i = Object.defineProperties;
1486
+ var __getOwnPropDescs$i = Object.getOwnPropertyDescriptors;
1487
+ var __getOwnPropSymbols$o = Object.getOwnPropertySymbols;
1488
+ var __hasOwnProp$o = Object.prototype.hasOwnProperty;
1489
+ var __propIsEnum$o = Object.prototype.propertyIsEnumerable;
1490
+ var __defNormalProp$n = (obj, key, value) => key in obj ? __defProp$n(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1491
+ var __spreadValues$n = (a, b) => {
1492
+ for (var prop in b || (b = {}))
1493
+ if (__hasOwnProp$o.call(b, prop))
1494
+ __defNormalProp$n(a, prop, b[prop]);
1495
+ if (__getOwnPropSymbols$o)
1496
+ for (var prop of __getOwnPropSymbols$o(b)) {
1497
+ if (__propIsEnum$o.call(b, prop))
1498
+ __defNormalProp$n(a, prop, b[prop]);
1499
+ }
1500
+ return a;
1501
+ };
1502
+ var __spreadProps$i = (a, b) => __defProps$i(a, __getOwnPropDescs$i(b));
1503
+ const createOperator = (fn) => {
1504
+ return Object.assign(fn, { type: void 0 });
1505
+ };
1506
+ const quoteValue = (arg, values, jsonArray) => {
1507
+ if (arg && typeof arg === "object") {
1508
+ if (!jsonArray && Array.isArray(arg)) {
1509
+ return `(${arg.map((value) => addValue(values, value)).join(", ")})`;
1510
+ }
1511
+ if ("toSql" in arg) {
1512
+ const sql = arg.toSql({ values });
1513
+ return `(${sql.text})`;
1514
+ }
1515
+ if (isRaw(arg)) {
1516
+ return getRaw(arg, values);
1517
+ }
1518
+ }
1519
+ return addValue(values, arg);
1520
+ };
1521
+ const all = {
1522
+ equals: () => createOperator(
1523
+ (key, value, values) => value === null ? `${key} IS NULL` : `${key} = ${quoteValue(value, values)}`
1524
+ ),
1525
+ not: () => createOperator(
1526
+ (key, value, values) => value === null ? `${key} IS NOT NULL` : `${key} <> ${quoteValue(value, values)}`
1527
+ ),
1528
+ in: () => createOperator(
1529
+ (key, value, values) => `${key} IN ${quoteValue(value, values)}`
1530
+ ),
1531
+ notIn: () => createOperator(
1532
+ (key, value, values) => `NOT ${key} IN ${quoteValue(value, values)}`
1533
+ ),
1534
+ lt: () => createOperator(
1535
+ (key, value, values) => `${key} < ${quoteValue(value, values)}`
1536
+ ),
1537
+ lte: () => createOperator(
1538
+ (key, value, values) => `${key} <= ${quoteValue(value, values)}`
1539
+ ),
1540
+ gt: () => createOperator(
1541
+ (key, value, values) => `${key} > ${quoteValue(value, values)}`
1542
+ ),
1543
+ gte: () => createOperator(
1544
+ (key, value, values) => `${key} >= ${quoteValue(value, values)}`
1545
+ ),
1546
+ contains: () => createOperator(
1547
+ (key, value, values) => `${key} ILIKE '%' || ${quoteValue(value, values)} || '%'`
1548
+ ),
1549
+ containsSensitive: () => createOperator(
1550
+ (key, value, values) => `${key} LIKE '%' || ${quoteValue(value, values)} || '%'`
1551
+ ),
1552
+ startsWith: () => createOperator(
1553
+ (key, value, values) => `${key} ILIKE ${quoteValue(value, values)} || '%'`
1554
+ ),
1555
+ startsWithSensitive: () => createOperator(
1556
+ (key, value, values) => `${key} LIKE ${quoteValue(value, values)} || '%'`
1557
+ ),
1558
+ endsWith: () => createOperator(
1559
+ (key, value, values) => `${key} ILIKE '%' || ${quoteValue(value, values)}`
1560
+ ),
1561
+ endsWithSensitive: () => createOperator(
1562
+ (key, value, values) => `${key} LIKE '%' || ${quoteValue(value, values)}`
1563
+ ),
1564
+ between: () => createOperator(
1565
+ (key, [from, to], values) => `${key} BETWEEN ${quoteValue(from, values)} AND ${quoteValue(
1566
+ to,
1567
+ values
1568
+ )}`
1569
+ ),
1570
+ jsonPath: () => createOperator(
1571
+ (key, [path, op, value], values) => `jsonb_path_query_first(${key}, ${quote(
1572
+ path
1573
+ )}) #>> '{}' ${op} ${quoteValue(value, values, true)}`
1574
+ ),
1575
+ jsonSupersetOf: () => createOperator(
1576
+ (key, value, values) => `${key} @> ${quoteValue(value, values, true)}`
1577
+ ),
1578
+ jsonSubsetOf: () => createOperator(
1579
+ (key, value, values) => `${key} <@ ${quoteValue(value, values, true)}`
1580
+ )
1581
+ };
1582
+ const base = () => ({
1583
+ equals: all.equals(),
1584
+ not: all.not(),
1585
+ in: all.in(),
1586
+ notIn: all.notIn()
1587
+ });
1588
+ const numeric = () => __spreadProps$i(__spreadValues$n({}, base()), {
1589
+ lt: all.lt(),
1590
+ lte: all.lte(),
1591
+ gt: all.gt(),
1592
+ gte: all.gte(),
1593
+ between: all.between()
1594
+ });
1595
+ const text$1 = () => __spreadProps$i(__spreadValues$n({}, base()), {
1596
+ contains: all.contains(),
1597
+ containsSensitive: all.containsSensitive(),
1598
+ startsWith: all.startsWith(),
1599
+ startsWithSensitive: all.startsWithSensitive(),
1600
+ endsWith: all.endsWith(),
1601
+ endsWithSensitive: all.endsWithSensitive()
1602
+ });
1603
+ const json = () => __spreadProps$i(__spreadValues$n({}, base()), {
1604
+ jsonPath: all.jsonPath(),
1605
+ jsonSupersetOf: all.jsonSupersetOf(),
1606
+ jsonSubsetOf: all.jsonSubsetOf()
1607
+ });
1608
+ const Operators = {
1609
+ any: base(),
1610
+ boolean: base(),
1611
+ number: numeric(),
1612
+ date: numeric(),
1613
+ time: numeric(),
1614
+ text: text$1(),
1615
+ json: json(),
1616
+ array: base()
1617
+ };
1618
+
1594
1619
  const cloneInstance = (instance) => {
1595
1620
  return Object.assign(
1596
1621
  Object.create(Object.getPrototypeOf(instance)),
@@ -5503,13 +5528,13 @@ class RawMethods {
5503
5528
  if (typeof args[0] === "string") {
5504
5529
  return {
5505
5530
  __raw: args[0],
5506
- __values: args.slice(1)
5531
+ __values: args[1]
5507
5532
  };
5508
5533
  } else {
5509
5534
  return {
5510
5535
  __column: args[0](this.columnTypes),
5511
5536
  __raw: args[1],
5512
- __values: args.slice(2)
5537
+ __values: args[2]
5513
5538
  };
5514
5539
  }
5515
5540
  }