@expo/entity-database-adapter-knex 0.60.0 → 0.62.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.
Files changed (103) hide show
  1. package/build/src/AuthorizationResultBasedKnexEntityLoader.d.ts +8 -9
  2. package/build/src/AuthorizationResultBasedKnexEntityLoader.js +5 -11
  3. package/build/src/BasePostgresEntityDatabaseAdapter.d.ts +4 -3
  4. package/build/src/BasePostgresEntityDatabaseAdapter.js +13 -19
  5. package/build/src/BaseSQLQueryBuilder.d.ts +4 -3
  6. package/build/src/BaseSQLQueryBuilder.js +4 -9
  7. package/build/src/EnforcingKnexEntityLoader.d.ts +7 -7
  8. package/build/src/EnforcingKnexEntityLoader.js +4 -10
  9. package/build/src/EntityFields.js +4 -11
  10. package/build/src/KnexEntityLoaderFactory.d.ts +4 -4
  11. package/build/src/KnexEntityLoaderFactory.js +8 -13
  12. package/build/src/PaginationStrategy.js +2 -6
  13. package/build/src/PostgresEntity.d.ts +4 -3
  14. package/build/src/PostgresEntity.js +5 -10
  15. package/build/src/PostgresEntityDatabaseAdapter.d.ts +6 -5
  16. package/build/src/PostgresEntityDatabaseAdapter.js +19 -24
  17. package/build/src/PostgresEntityDatabaseAdapterProvider.d.ts +1 -1
  18. package/build/src/PostgresEntityDatabaseAdapterProvider.js +3 -8
  19. package/build/src/PostgresEntityQueryContextProvider.d.ts +3 -2
  20. package/build/src/PostgresEntityQueryContextProvider.js +5 -10
  21. package/build/src/ReadonlyPostgresEntity.d.ts +4 -3
  22. package/build/src/ReadonlyPostgresEntity.js +5 -10
  23. package/build/src/SQLOperator.d.ts +620 -103
  24. package/build/src/SQLOperator.js +332 -198
  25. package/build/src/errors/wrapNativePostgresCallAsync.js +11 -15
  26. package/build/src/index.d.ts +20 -20
  27. package/build/src/index.js +20 -37
  28. package/build/src/internal/EntityKnexDataManager.d.ts +5 -5
  29. package/build/src/internal/EntityKnexDataManager.js +78 -86
  30. package/build/src/internal/getKnexDataManager.d.ts +2 -2
  31. package/build/src/internal/getKnexDataManager.js +7 -14
  32. package/build/src/internal/getKnexEntityLoaderFactory.d.ts +2 -2
  33. package/build/src/internal/getKnexEntityLoaderFactory.js +5 -9
  34. package/build/src/internal/utilityTypes.js +1 -3
  35. package/build/src/internal/weakMaps.js +1 -6
  36. package/build/src/knexLoader.d.ts +3 -3
  37. package/build/src/knexLoader.js +5 -10
  38. package/package.json +8 -7
  39. package/src/AuthorizationResultBasedKnexEntityLoader.ts +15 -12
  40. package/src/BasePostgresEntityDatabaseAdapter.ts +3 -3
  41. package/src/BaseSQLQueryBuilder.ts +5 -4
  42. package/src/EnforcingKnexEntityLoader.ts +8 -8
  43. package/src/KnexEntityLoaderFactory.ts +6 -6
  44. package/src/PostgresEntity.ts +5 -5
  45. package/src/PostgresEntityDatabaseAdapter.ts +13 -15
  46. package/src/PostgresEntityDatabaseAdapterProvider.ts +2 -2
  47. package/src/PostgresEntityQueryContextProvider.ts +3 -6
  48. package/src/ReadonlyPostgresEntity.ts +5 -5
  49. package/src/SQLOperator.ts +1044 -278
  50. package/src/__integration-tests__/EntityCreationUtils-test.ts +5 -4
  51. package/src/__integration-tests__/PostgresEntityIntegration-test.ts +42 -16
  52. package/src/__integration-tests__/PostgresEntityQueryContextProvider-test.ts +6 -5
  53. package/src/__integration-tests__/PostgresInvalidSetup-test.ts +5 -4
  54. package/src/__integration-tests__/errors-test.ts +5 -4
  55. package/src/__testfixtures__/ErrorsTestEntity.ts +2 -3
  56. package/src/__testfixtures__/InvalidTestEntity.ts +2 -3
  57. package/src/__testfixtures__/PostgresTestEntity.ts +5 -6
  58. package/src/__testfixtures__/PostgresTriggerTestEntity.ts +7 -5
  59. package/src/__testfixtures__/PostgresUniqueTestEntity.ts +6 -4
  60. package/src/__testfixtures__/PostgresValidatorTestEntity.ts +7 -5
  61. package/src/__testfixtures__/createKnexIntegrationTestEntityCompanionProvider.ts +5 -8
  62. package/src/__tests__/AuthorizationResultBasedKnexEntityLoader-test.ts +12 -14
  63. package/src/__tests__/BasePostgresEntityDatabaseAdapter-test.ts +7 -5
  64. package/src/__tests__/EnforcingKnexEntityLoader-test.ts +7 -6
  65. package/src/__tests__/EntityFields-test.ts +1 -1
  66. package/src/__tests__/PostgresEntity-test.ts +6 -6
  67. package/src/__tests__/ReadonlyEntity-test.ts +5 -5
  68. package/src/__tests__/SQLOperator-test.ts +403 -206
  69. package/src/__tests__/fixtures/StubPostgresDatabaseAdapter.ts +9 -8
  70. package/src/__tests__/fixtures/StubPostgresDatabaseAdapterProvider.ts +2 -2
  71. package/src/__tests__/fixtures/TestEntity.ts +7 -7
  72. package/src/__tests__/fixtures/TestPaginationEntity.ts +9 -7
  73. package/src/__tests__/fixtures/createUnitTestPostgresEntityCompanionProvider.ts +3 -6
  74. package/src/errors/__tests__/wrapNativePostgresCallAsync-test.ts +1 -1
  75. package/src/errors/wrapNativePostgresCallAsync.ts +2 -2
  76. package/src/index.ts +20 -20
  77. package/src/internal/EntityKnexDataManager.ts +19 -21
  78. package/src/internal/__tests__/EntityKnexDataManager-test.ts +8 -15
  79. package/src/internal/__tests__/weakMaps-test.ts +1 -1
  80. package/src/internal/getKnexDataManager.ts +4 -4
  81. package/src/internal/getKnexEntityLoaderFactory.ts +4 -4
  82. package/src/knexLoader.ts +4 -4
  83. package/build/src/AuthorizationResultBasedKnexEntityLoader.js.map +0 -1
  84. package/build/src/BasePostgresEntityDatabaseAdapter.js.map +0 -1
  85. package/build/src/BaseSQLQueryBuilder.js.map +0 -1
  86. package/build/src/EnforcingKnexEntityLoader.js.map +0 -1
  87. package/build/src/EntityFields.js.map +0 -1
  88. package/build/src/KnexEntityLoaderFactory.js.map +0 -1
  89. package/build/src/PaginationStrategy.js.map +0 -1
  90. package/build/src/PostgresEntity.js.map +0 -1
  91. package/build/src/PostgresEntityDatabaseAdapter.js.map +0 -1
  92. package/build/src/PostgresEntityDatabaseAdapterProvider.js.map +0 -1
  93. package/build/src/PostgresEntityQueryContextProvider.js.map +0 -1
  94. package/build/src/ReadonlyPostgresEntity.js.map +0 -1
  95. package/build/src/SQLOperator.js.map +0 -1
  96. package/build/src/errors/wrapNativePostgresCallAsync.js.map +0 -1
  97. package/build/src/index.js.map +0 -1
  98. package/build/src/internal/EntityKnexDataManager.js.map +0 -1
  99. package/build/src/internal/getKnexDataManager.js.map +0 -1
  100. package/build/src/internal/getKnexEntityLoaderFactory.js.map +0 -1
  101. package/build/src/internal/utilityTypes.js.map +0 -1
  102. package/build/src/internal/weakMaps.js.map +0 -1
  103. package/build/src/knexLoader.js.map +0 -1
@@ -81,9 +81,9 @@ export declare class SQLIdentifier {
81
81
  * Helper for referencing entity fields that can be used in SQL queries. This allows for type-safe references to fields of an entity
82
82
  * and does automatic translation to DB field names.
83
83
  */
84
- export declare class SQLEntityField<TFields extends Record<string, any>> {
85
- readonly fieldName: keyof TFields;
86
- constructor(fieldName: keyof TFields);
84
+ export declare class SQLEntityField<TFields extends Record<string, any>, N extends keyof TFields> {
85
+ readonly fieldName: N;
86
+ constructor(fieldName: N);
87
87
  }
88
88
  /**
89
89
  * Helper for passing an array as a single bound parameter (e.g. for PostgreSQL's = ANY(?)).
@@ -119,7 +119,7 @@ export declare function identifier(name: string): SQLIdentifier;
119
119
  *
120
120
  * @param fieldName - The entity field name to reference.
121
121
  */
122
- export declare function entityField<TFields extends Record<string, any>>(fieldName: keyof TFields): SQLEntityField<TFields>;
122
+ export declare function entityField<TFields extends Record<string, any>, N extends keyof TFields>(fieldName: N): SQLEntityField<TFields, N>;
123
123
  /**
124
124
  * Wrap an array so it is bound as a single parameter rather than expanded for IN clauses.
125
125
  * Generates PostgreSQL's = ANY(?) syntax.
@@ -147,17 +147,6 @@ export declare function arrayValue(values: readonly SupportedSQLValue[]): SQLArr
147
147
  * ```
148
148
  */
149
149
  export declare function unsafeRaw(sqlString: string): SQLUnsafeRaw;
150
- /**
151
- * Wraps a SQLFragment or entity field name into an SQLExpression for fluent comparison usage.
152
- *
153
- * @example
154
- * ```ts
155
- * expression<MyFields>('age').gte(18)
156
- * expression<MyFields>('name').ilike('%john%')
157
- * expression(sql`${entityField('status')}`).eq('active')
158
- * ```
159
- */
160
- export declare function expression<TFields extends Record<string, any>>(fragmentOrFieldName: SQLFragment<TFields> | keyof TFields): SQLExpression<TFields>;
161
150
  /**
162
151
  * Tagged template literal function for SQL queries
163
152
  *
@@ -167,7 +156,7 @@ export declare function expression<TFields extends Record<string, any>>(fragment
167
156
  * const query = sql`age >= ${age} AND status = ${'active'}`;
168
157
  * ```
169
158
  */
170
- export declare function sql<TFields extends Record<string, any>>(strings: TemplateStringsArray, ...values: readonly (SupportedSQLValue | SQLFragment<TFields> | SQLIdentifier | SQLUnsafeRaw | SQLEntityField<TFields> | SQLArrayValue)[]): SQLFragment<TFields>;
159
+ export declare function sql<TFields extends Record<string, any>>(strings: TemplateStringsArray, ...values: readonly (SupportedSQLValue | SQLFragment<TFields> | SQLIdentifier | SQLUnsafeRaw | SQLEntityField<TFields, keyof TFields> | SQLArrayValue)[]): SQLFragment<TFields>;
171
160
  type PickSupportedSQLValueKeys<T> = {
172
161
  [K in keyof T]: T[K] extends SupportedSQLValue ? K : never;
173
162
  }[keyof T];
@@ -183,24 +172,134 @@ type JsonSerializable = string | number | boolean | null | undefined | readonly
183
172
  * The fluent methods return plain SQLFragment instances since they produce
184
173
  * complete conditions, not further chainable expressions.
185
174
  */
186
- export declare class SQLExpression<TFields extends Record<string, any>> extends SQLFragment<TFields> {
187
- eq(value: SupportedSQLValue): SQLFragment<TFields>;
188
- neq(value: SupportedSQLValue): SQLFragment<TFields>;
189
- gt(value: SupportedSQLValue): SQLFragment<TFields>;
190
- gte(value: SupportedSQLValue): SQLFragment<TFields>;
191
- lt(value: SupportedSQLValue): SQLFragment<TFields>;
192
- lte(value: SupportedSQLValue): SQLFragment<TFields>;
175
+ export declare class SQLChainableFragment<TFields extends Record<string, any>, TValue extends SupportedSQLValue> extends SQLFragment<TFields> {
176
+ /**
177
+ * Generates an equality condition (`= value`).
178
+ * Automatically converts `null`/`undefined` to `IS NULL`.
179
+ *
180
+ * @param value - The value to compare against
181
+ * @returns A {@link SQLFragment} representing the equality condition
182
+ */
183
+ eq(value: TValue | null | undefined): SQLFragment<TFields>;
184
+ /**
185
+ * Generates an inequality condition (`!= value`).
186
+ * Automatically converts `null`/`undefined` to `IS NOT NULL`.
187
+ *
188
+ * @param value - The value to compare against
189
+ * @returns A {@link SQLFragment} representing the inequality condition
190
+ */
191
+ neq(value: TValue | null | undefined): SQLFragment<TFields>;
192
+ /**
193
+ * Generates a greater-than condition (`> value`).
194
+ *
195
+ * @param value - The value to compare against
196
+ * @returns A {@link SQLFragment} representing the condition
197
+ */
198
+ gt(value: TValue): SQLFragment<TFields>;
199
+ /**
200
+ * Generates a greater-than-or-equal-to condition (`>= value`).
201
+ *
202
+ * @param value - The value to compare against
203
+ * @returns A {@link SQLFragment} representing the condition
204
+ */
205
+ gte(value: TValue): SQLFragment<TFields>;
206
+ /**
207
+ * Generates a less-than condition (`< value`).
208
+ *
209
+ * @param value - The value to compare against
210
+ * @returns A {@link SQLFragment} representing the condition
211
+ */
212
+ lt(value: TValue): SQLFragment<TFields>;
213
+ /**
214
+ * Generates a less-than-or-equal-to condition (`<= value`).
215
+ *
216
+ * @param value - The value to compare against
217
+ * @returns A {@link SQLFragment} representing the condition
218
+ */
219
+ lte(value: TValue): SQLFragment<TFields>;
220
+ /**
221
+ * Generates an `IS NULL` condition.
222
+ *
223
+ * @returns A {@link SQLFragment} representing the IS NULL check
224
+ */
193
225
  isNull(): SQLFragment<TFields>;
226
+ /**
227
+ * Generates an `IS NOT NULL` condition.
228
+ *
229
+ * @returns A {@link SQLFragment} representing the IS NOT NULL check
230
+ */
194
231
  isNotNull(): SQLFragment<TFields>;
232
+ /**
233
+ * Generates a case-sensitive `LIKE` condition for pattern matching.
234
+ *
235
+ * @param pattern - The LIKE pattern (use `%` for wildcards, `_` for single character)
236
+ * @returns A {@link SQLFragment} representing the LIKE condition
237
+ */
195
238
  like(pattern: string): SQLFragment<TFields>;
239
+ /**
240
+ * Generates a case-sensitive `NOT LIKE` condition.
241
+ *
242
+ * @param pattern - The LIKE pattern (use `%` for wildcards, `_` for single character)
243
+ * @returns A {@link SQLFragment} representing the NOT LIKE condition
244
+ */
196
245
  notLike(pattern: string): SQLFragment<TFields>;
246
+ /**
247
+ * Generates a case-insensitive `ILIKE` condition (PostgreSQL-specific).
248
+ *
249
+ * @param pattern - The LIKE pattern (use `%` for wildcards, `_` for single character)
250
+ * @returns A {@link SQLFragment} representing the ILIKE condition
251
+ */
197
252
  ilike(pattern: string): SQLFragment<TFields>;
253
+ /**
254
+ * Generates a case-insensitive `NOT ILIKE` condition (PostgreSQL-specific).
255
+ *
256
+ * @param pattern - The LIKE pattern (use `%` for wildcards, `_` for single character)
257
+ * @returns A {@link SQLFragment} representing the NOT ILIKE condition
258
+ */
198
259
  notIlike(pattern: string): SQLFragment<TFields>;
199
- inArray(values: readonly SupportedSQLValue[]): SQLFragment<TFields>;
200
- notInArray(values: readonly SupportedSQLValue[]): SQLFragment<TFields>;
201
- anyArray(values: readonly SupportedSQLValue[]): SQLFragment<TFields>;
202
- between(min: SupportedSQLValue, max: SupportedSQLValue): SQLFragment<TFields>;
203
- notBetween(min: SupportedSQLValue, max: SupportedSQLValue): SQLFragment<TFields>;
260
+ /**
261
+ * Generates an `IN (...)` condition. Each array element becomes a separate
262
+ * bound parameter (`IN (?, ?, ?)`).
263
+ * Returns `FALSE` when the values array is empty.
264
+ *
265
+ * @param values - The values to check membership against
266
+ * @returns A {@link SQLFragment} representing the IN condition
267
+ */
268
+ inArray(values: readonly TValue[]): SQLFragment<TFields>;
269
+ /**
270
+ * Generates a `NOT IN (...)` condition. Each array element becomes a separate
271
+ * bound parameter.
272
+ * Returns `TRUE` when the values array is empty.
273
+ *
274
+ * @param values - The values to check non-membership against
275
+ * @returns A {@link SQLFragment} representing the NOT IN condition
276
+ */
277
+ notInArray(values: readonly TValue[]): SQLFragment<TFields>;
278
+ /**
279
+ * Generates an `= ANY(?)` condition. Unlike {@link inArray}, the array is bound
280
+ * as a single parameter, producing a consistent query shape for query metrics.
281
+ * Returns `FALSE` when the values array is empty.
282
+ *
283
+ * @param values - The values to check membership against
284
+ * @returns A {@link SQLFragment} representing the = ANY condition
285
+ */
286
+ anyArray(values: readonly TValue[]): SQLFragment<TFields>;
287
+ /**
288
+ * Generates a `BETWEEN min AND max` condition (inclusive on both ends).
289
+ *
290
+ * @param min - The lower bound
291
+ * @param max - The upper bound
292
+ * @returns A {@link SQLFragment} representing the BETWEEN condition
293
+ */
294
+ between(min: TValue, max: TValue): SQLFragment<TFields>;
295
+ /**
296
+ * Generates a `NOT BETWEEN min AND max` condition.
297
+ *
298
+ * @param min - The lower bound
299
+ * @param max - The upper bound
300
+ * @returns A {@link SQLFragment} representing the NOT BETWEEN condition
301
+ */
302
+ notBetween(min: TValue, max: TValue): SQLFragment<TFields>;
204
303
  }
205
304
  /**
206
305
  * Allowed PostgreSQL type names for the cast() helper.
@@ -212,20 +311,440 @@ declare const ALLOWED_CAST_TYPES: readonly ["int", "integer", "int2", "int4", "i
212
311
  * Only these types can be used to prevent SQL injection through type name interpolation.
213
312
  */
214
313
  export type PostgresCastType = (typeof ALLOWED_CAST_TYPES)[number];
314
+ type ExtractFragmentFields<T> = T extends SQLFragment<infer F> ? F : never;
315
+ type FragmentValueNullable<TFragment> = TFragment extends SQLChainableFragment<any, infer TValue> ? TValue | null | undefined : SupportedSQLValue;
316
+ type FragmentValue<TFragment> = TFragment extends SQLChainableFragment<any, infer TValue> ? TValue : SupportedSQLValue;
317
+ type FragmentValueArray<TFragment> = TFragment extends SQLChainableFragment<any, infer TValue> ? readonly TValue[] : readonly SupportedSQLValue[];
215
318
  /**
216
- * Common SQL helper functions for building queries
319
+ * Generates an `IN (...)` condition from a fragment and array of values.
320
+ * Each array element becomes a separate bound parameter. Returns `FALSE` for empty arrays.
321
+ *
322
+ * @param fragment - A SQLFragment or SQLChainableFragment to check
323
+ * @param values - The values to check membership against
324
+ */
325
+ declare function inArrayHelper<TFragment extends SQLFragment<any>>(fragment: TFragment, values: FragmentValueArray<TFragment>): SQLFragment<ExtractFragmentFields<TFragment>>;
326
+ /**
327
+ * Generates an `IN (...)` condition from a field name and array of values.
328
+ * Each array element becomes a separate bound parameter. Returns `FALSE` for empty arrays.
329
+ *
330
+ * @param fieldName - The entity field name to check
331
+ * @param values - The values to check membership against
332
+ */
333
+ declare function inArrayHelper<TFields extends Record<string, any>, N extends PickSupportedSQLValueKeys<TFields>>(fieldName: N, values: readonly TFields[N][]): SQLFragment<TFields>;
334
+ /**
335
+ * Generates an `= ANY(?)` condition from a fragment and array of values.
336
+ * The array is bound as a single parameter for consistent query shape. Returns `FALSE` for empty arrays.
337
+ *
338
+ * @param fragment - A SQLFragment or SQLChainableFragment to check
339
+ * @param values - The values to check membership against
340
+ */
341
+ declare function anyArrayHelper<TFragment extends SQLFragment<any>>(fragment: TFragment, values: FragmentValueArray<TFragment>): SQLFragment<ExtractFragmentFields<TFragment>>;
342
+ /**
343
+ * Generates an `= ANY(?)` condition from a field name and array of values.
344
+ * The array is bound as a single parameter for consistent query shape. Returns `FALSE` for empty arrays.
345
+ *
346
+ * @param fieldName - The entity field name to check
347
+ * @param values - The values to check membership against
348
+ */
349
+ declare function anyArrayHelper<TFields extends Record<string, any>, N extends PickSupportedSQLValueKeys<TFields>>(fieldName: N, values: readonly TFields[N][]): SQLFragment<TFields>;
350
+ /**
351
+ * Generates a `NOT IN (...)` condition from a fragment and array of values.
352
+ * Each array element becomes a separate bound parameter. Returns `TRUE` for empty arrays.
353
+ *
354
+ * @param fragment - A SQLFragment or SQLChainableFragment to check
355
+ * @param values - The values to check non-membership against
356
+ */
357
+ declare function notInArrayHelper<TFragment extends SQLFragment<any>>(fragment: TFragment, values: FragmentValueArray<TFragment>): SQLFragment<ExtractFragmentFields<TFragment>>;
358
+ /**
359
+ * Generates a `NOT IN (...)` condition from a field name and array of values.
360
+ * Each array element becomes a separate bound parameter. Returns `TRUE` for empty arrays.
361
+ *
362
+ * @param fieldName - The entity field name to check
363
+ * @param values - The values to check non-membership against
364
+ */
365
+ declare function notInArrayHelper<TFields extends Record<string, any>, N extends PickSupportedSQLValueKeys<TFields>>(fieldName: N, values: readonly TFields[N][]): SQLFragment<TFields>;
366
+ /**
367
+ * Generates a `BETWEEN min AND max` condition (inclusive) from a fragment.
368
+ *
369
+ * @param fragment - A SQLFragment or SQLChainableFragment to check
370
+ * @param min - The lower bound
371
+ * @param max - The upper bound
372
+ */
373
+ declare function betweenHelper<TFragment extends SQLFragment<any>>(fragment: TFragment, min: FragmentValue<TFragment>, max: FragmentValue<TFragment>): SQLFragment<ExtractFragmentFields<TFragment>>;
374
+ /**
375
+ * Generates a `BETWEEN min AND max` condition (inclusive) from a field name.
376
+ *
377
+ * @param fieldName - The entity field name to check
378
+ * @param min - The lower bound
379
+ * @param max - The upper bound
380
+ */
381
+ declare function betweenHelper<TFields extends Record<string, any>, N extends PickSupportedSQLValueKeys<TFields>>(fieldName: N, min: TFields[N], max: TFields[N]): SQLFragment<TFields>;
382
+ /**
383
+ * Generates a `NOT BETWEEN min AND max` condition from a fragment.
384
+ *
385
+ * @param fragment - A SQLFragment or SQLChainableFragment to check
386
+ * @param min - The lower bound
387
+ * @param max - The upper bound
388
+ */
389
+ declare function notBetweenHelper<TFragment extends SQLFragment<any>>(fragment: TFragment, min: FragmentValue<TFragment>, max: FragmentValue<TFragment>): SQLFragment<ExtractFragmentFields<TFragment>>;
390
+ /**
391
+ * Generates a `NOT BETWEEN min AND max` condition from a field name.
392
+ *
393
+ * @param fieldName - The entity field name to check
394
+ * @param min - The lower bound
395
+ * @param max - The upper bound
396
+ */
397
+ declare function notBetweenHelper<TFields extends Record<string, any>, N extends PickSupportedSQLValueKeys<TFields>>(fieldName: N, min: TFields[N], max: TFields[N]): SQLFragment<TFields>;
398
+ /**
399
+ * Generates a case-sensitive `LIKE` condition from a fragment.
400
+ *
401
+ * @param fragment - A SQLFragment or SQLChainableFragment to match
402
+ * @param pattern - The LIKE pattern (use `%` for wildcards, `_` for single character)
403
+ */
404
+ declare function likeHelper<TFragment extends SQLFragment<any>>(fragment: TFragment, pattern: string): SQLFragment<ExtractFragmentFields<TFragment>>;
405
+ /**
406
+ * Generates a case-sensitive `LIKE` condition from a field name.
407
+ *
408
+ * @param fieldName - The entity field name to match
409
+ * @param pattern - The LIKE pattern (use `%` for wildcards, `_` for single character)
410
+ */
411
+ declare function likeHelper<TFields extends Record<string, any>, N extends PickStringValueKeys<TFields>>(fieldName: N, pattern: string): SQLFragment<TFields>;
412
+ /**
413
+ * Generates a case-sensitive `NOT LIKE` condition from a fragment.
414
+ *
415
+ * @param fragment - A SQLFragment or SQLChainableFragment to match
416
+ * @param pattern - The LIKE pattern (use `%` for wildcards, `_` for single character)
417
+ */
418
+ declare function notLikeHelper<TFragment extends SQLFragment<any>>(fragment: TFragment, pattern: string): SQLFragment<ExtractFragmentFields<TFragment>>;
419
+ /**
420
+ * Generates a case-sensitive `NOT LIKE` condition from a field name.
421
+ *
422
+ * @param fieldName - The entity field name to match
423
+ * @param pattern - The LIKE pattern (use `%` for wildcards, `_` for single character)
424
+ */
425
+ declare function notLikeHelper<TFields extends Record<string, any>, N extends PickStringValueKeys<TFields>>(fieldName: N, pattern: string): SQLFragment<TFields>;
426
+ /**
427
+ * Generates a case-insensitive `ILIKE` condition from a fragment (PostgreSQL-specific).
428
+ *
429
+ * @param fragment - A SQLFragment or SQLChainableFragment to match
430
+ * @param pattern - The LIKE pattern (use `%` for wildcards, `_` for single character)
431
+ */
432
+ declare function ilikeHelper<TFragment extends SQLFragment<any>>(fragment: TFragment, pattern: string): SQLFragment<ExtractFragmentFields<TFragment>>;
433
+ /**
434
+ * Generates a case-insensitive `ILIKE` condition from a field name (PostgreSQL-specific).
435
+ *
436
+ * @param fieldName - The entity field name to match
437
+ * @param pattern - The LIKE pattern (use `%` for wildcards, `_` for single character)
438
+ */
439
+ declare function ilikeHelper<TFields extends Record<string, any>, N extends PickStringValueKeys<TFields>>(fieldName: N, pattern: string): SQLFragment<TFields>;
440
+ /**
441
+ * Generates a case-insensitive `NOT ILIKE` condition from a fragment (PostgreSQL-specific).
442
+ *
443
+ * @param fragment - A SQLFragment or SQLChainableFragment to match
444
+ * @param pattern - The LIKE pattern (use `%` for wildcards, `_` for single character)
445
+ */
446
+ declare function notIlikeHelper<TFragment extends SQLFragment<any>>(fragment: TFragment, pattern: string): SQLFragment<ExtractFragmentFields<TFragment>>;
447
+ /**
448
+ * Generates a case-insensitive `NOT ILIKE` condition from a field name (PostgreSQL-specific).
449
+ *
450
+ * @param fieldName - The entity field name to match
451
+ * @param pattern - The LIKE pattern (use `%` for wildcards, `_` for single character)
452
+ */
453
+ declare function notIlikeHelper<TFields extends Record<string, any>, N extends PickStringValueKeys<TFields>>(fieldName: N, pattern: string): SQLFragment<TFields>;
454
+ /**
455
+ * Generates an `IS NULL` condition from a fragment.
456
+ *
457
+ * @param fragment - A SQLFragment or SQLChainableFragment to check
458
+ */
459
+ declare function isNullHelper<TFragment extends SQLFragment<any>>(fragment: TFragment): SQLFragment<ExtractFragmentFields<TFragment>>;
460
+ /**
461
+ * Generates an `IS NULL` condition from a field name.
462
+ *
463
+ * @param fieldName - The entity field name to check
464
+ */
465
+ declare function isNullHelper<TFields extends Record<string, any>, N extends keyof TFields>(fieldName: N): SQLFragment<TFields>;
466
+ /**
467
+ * Generates an `IS NOT NULL` condition from a fragment.
468
+ *
469
+ * @param fragment - A SQLFragment or SQLChainableFragment to check
470
+ */
471
+ declare function isNotNullHelper<TFragment extends SQLFragment<any>>(fragment: TFragment): SQLFragment<ExtractFragmentFields<TFragment>>;
472
+ /**
473
+ * Generates an `IS NOT NULL` condition from a field name.
474
+ *
475
+ * @param fieldName - The entity field name to check
476
+ */
477
+ declare function isNotNullHelper<TFields extends Record<string, any>, N extends keyof TFields>(fieldName: N): SQLFragment<TFields>;
478
+ /**
479
+ * Generates an equality condition (`= value`) from a fragment.
480
+ * Automatically converts `null`/`undefined` to `IS NULL`.
481
+ *
482
+ * @param fragment - A SQLFragment or SQLChainableFragment to compare
483
+ * @param value - The value to compare against
484
+ */
485
+ declare function eqHelper<TFragment extends SQLFragment<any>>(fragment: TFragment, value: FragmentValueNullable<TFragment>): SQLFragment<ExtractFragmentFields<TFragment>>;
486
+ /**
487
+ * Generates an equality condition (`= value`) from a field name.
488
+ * Automatically converts `null`/`undefined` to `IS NULL`.
489
+ *
490
+ * @param fieldName - The entity field name to compare
491
+ * @param value - The value to compare against
492
+ */
493
+ declare function eqHelper<TFields extends Record<string, any>, N extends PickSupportedSQLValueKeys<TFields>>(fieldName: N, value: TFields[N]): SQLFragment<TFields>;
494
+ /**
495
+ * Generates an inequality condition (`!= value`) from a fragment.
496
+ * Automatically converts `null`/`undefined` to `IS NOT NULL`.
497
+ *
498
+ * @param fragment - A SQLFragment or SQLChainableFragment to compare
499
+ * @param value - The value to compare against
500
+ */
501
+ declare function neqHelper<TFragment extends SQLFragment<any>>(fragment: TFragment, value: FragmentValueNullable<TFragment>): SQLFragment<ExtractFragmentFields<TFragment>>;
502
+ /**
503
+ * Generates an inequality condition (`!= value`) from a field name.
504
+ * Automatically converts `null`/`undefined` to `IS NOT NULL`.
505
+ *
506
+ * @param fieldName - The entity field name to compare
507
+ * @param value - The value to compare against
508
+ */
509
+ declare function neqHelper<TFields extends Record<string, any>, N extends PickSupportedSQLValueKeys<TFields>>(fieldName: N, value: TFields[N]): SQLFragment<TFields>;
510
+ /**
511
+ * Generates a greater-than condition (`> value`) from a fragment.
512
+ *
513
+ * @param fragment - A SQLFragment or SQLChainableFragment to compare
514
+ * @param value - The value to compare against
515
+ */
516
+ declare function gtHelper<TFragment extends SQLFragment<any>>(fragment: TFragment, value: FragmentValue<TFragment>): SQLFragment<ExtractFragmentFields<TFragment>>;
517
+ /**
518
+ * Generates a greater-than condition (`> value`) from a field name.
519
+ *
520
+ * @param fieldName - The entity field name to compare
521
+ * @param value - The value to compare against
522
+ */
523
+ declare function gtHelper<TFields extends Record<string, any>, N extends PickSupportedSQLValueKeys<TFields>>(fieldName: N, value: TFields[N]): SQLFragment<TFields>;
524
+ /**
525
+ * Generates a greater-than-or-equal-to condition (`>= value`) from a fragment.
526
+ *
527
+ * @param fragment - A SQLFragment or SQLChainableFragment to compare
528
+ * @param value - The value to compare against
529
+ */
530
+ declare function gteHelper<TFragment extends SQLFragment<any>>(fragment: TFragment, value: FragmentValue<TFragment>): SQLFragment<ExtractFragmentFields<TFragment>>;
531
+ /**
532
+ * Generates a greater-than-or-equal-to condition (`>= value`) from a field name.
533
+ *
534
+ * @param fieldName - The entity field name to compare
535
+ * @param value - The value to compare against
536
+ */
537
+ declare function gteHelper<TFields extends Record<string, any>, N extends PickSupportedSQLValueKeys<TFields>>(fieldName: N, value: TFields[N]): SQLFragment<TFields>;
538
+ /**
539
+ * Generates a less-than condition (`< value`) from a fragment.
540
+ *
541
+ * @param fragment - A SQLFragment or SQLChainableFragment to compare
542
+ * @param value - The value to compare against
543
+ */
544
+ declare function ltHelper<TFragment extends SQLFragment<any>>(fragment: TFragment, value: FragmentValue<TFragment>): SQLFragment<ExtractFragmentFields<TFragment>>;
545
+ /**
546
+ * Generates a less-than condition (`< value`) from a field name.
547
+ *
548
+ * @param fieldName - The entity field name to compare
549
+ * @param value - The value to compare against
550
+ */
551
+ declare function ltHelper<TFields extends Record<string, any>, N extends PickSupportedSQLValueKeys<TFields>>(fieldName: N, value: TFields[N]): SQLFragment<TFields>;
552
+ /**
553
+ * Generates a less-than-or-equal-to condition (`<= value`) from a fragment.
554
+ *
555
+ * @param fragment - A SQLFragment or SQLChainableFragment to compare
556
+ * @param value - The value to compare against
557
+ */
558
+ declare function lteHelper<TFragment extends SQLFragment<any>>(fragment: TFragment, value: FragmentValue<TFragment>): SQLFragment<ExtractFragmentFields<TFragment>>;
559
+ /**
560
+ * Generates a less-than-or-equal-to condition (`<= value`) from a field name.
561
+ *
562
+ * @param fieldName - The entity field name to compare
563
+ * @param value - The value to compare against
564
+ */
565
+ declare function lteHelper<TFields extends Record<string, any>, N extends PickSupportedSQLValueKeys<TFields>>(fieldName: N, value: TFields[N]): SQLFragment<TFields>;
566
+ /**
567
+ * Generates a JSON contains condition (`@>`) from a fragment.
568
+ * Tests whether the JSON value contains the given value.
569
+ *
570
+ * @param fragment - A SQLFragment or SQLChainableFragment to check
571
+ * @param value - The JSON value to check containment of
572
+ */
573
+ declare function jsonContainsHelper<TFragment extends SQLFragment<any>>(fragment: TFragment, value: JsonSerializable): SQLFragment<ExtractFragmentFields<TFragment>>;
574
+ /**
575
+ * Generates a JSON contains condition (`@>`) from a field name.
576
+ * Tests whether the JSON value contains the given value.
577
+ *
578
+ * @param fieldName - The entity field name to check
579
+ * @param value - The JSON value to check containment of
580
+ */
581
+ declare function jsonContainsHelper<TFields extends Record<string, any>, N extends keyof TFields>(fieldName: N, value: JsonSerializable): SQLFragment<TFields>;
582
+ /**
583
+ * Generates a JSON contained-by condition (`<@`) from a fragment.
584
+ * Tests whether the JSON value is contained by the given value.
585
+ *
586
+ * @param fragment - A SQLFragment or SQLChainableFragment to check
587
+ * @param value - The JSON value to check containment against
588
+ */
589
+ declare function jsonContainedByHelper<TFragment extends SQLFragment<any>>(fragment: TFragment, value: JsonSerializable): SQLFragment<ExtractFragmentFields<TFragment>>;
590
+ /**
591
+ * Generates a JSON contained-by condition (`<@`) from a field name.
592
+ * Tests whether the JSON value is contained by the given value.
593
+ *
594
+ * @param fieldName - The entity field name to check
595
+ * @param value - The JSON value to check containment against
596
+ */
597
+ declare function jsonContainedByHelper<TFields extends Record<string, any>, N extends keyof TFields>(fieldName: N, value: JsonSerializable): SQLFragment<TFields>;
598
+ /**
599
+ * JSON path extraction (`->`) from a fragment. Returns JSON.
600
+ * Returns an SQLChainableFragment for fluent chaining.
601
+ *
602
+ * @param fragment - A SQLFragment or SQLChainableFragment to extract from
603
+ * @param path - The JSON key to extract
604
+ */
605
+ declare function jsonPathHelper<TFragment extends SQLFragment<any>>(fragment: TFragment, path: string): SQLChainableFragment<ExtractFragmentFields<TFragment>, SupportedSQLValue>;
606
+ /**
607
+ * JSON path extraction (`->`) from a field name. Returns JSON.
608
+ * Returns an SQLChainableFragment for fluent chaining.
609
+ *
610
+ * @param fieldName - The entity field name to extract from
611
+ * @param path - The JSON key to extract
612
+ */
613
+ declare function jsonPathHelper<TFields extends Record<string, any>, N extends keyof TFields>(fieldName: N, path: string): SQLChainableFragment<TFields, SupportedSQLValue>;
614
+ /**
615
+ * JSON path text extraction (`->>`) from a fragment. Returns text.
616
+ * Returns an SQLChainableFragment for fluent chaining.
617
+ *
618
+ * @param fragment - A SQLFragment or SQLChainableFragment to extract from
619
+ * @param path - The JSON key to extract as text
620
+ */
621
+ declare function jsonPathTextHelper<TFragment extends SQLFragment<any>>(fragment: TFragment, path: string): SQLChainableFragment<ExtractFragmentFields<TFragment>, SupportedSQLValue>;
622
+ /**
623
+ * JSON path text extraction (`->>`) from a field name. Returns text.
624
+ * Returns an SQLChainableFragment for fluent chaining.
625
+ *
626
+ * @param fieldName - The entity field name to extract from
627
+ * @param path - The JSON key to extract as text
628
+ */
629
+ declare function jsonPathTextHelper<TFields extends Record<string, any>, N extends keyof TFields>(fieldName: N, path: string): SQLChainableFragment<TFields, SupportedSQLValue>;
630
+ /**
631
+ * JSON deep path extraction (`#>`) from a fragment. Returns JSON at the specified key path.
632
+ * Returns an SQLChainableFragment for fluent chaining.
633
+ *
634
+ * @param fragment - A SQLFragment or SQLChainableFragment to extract from
635
+ * @param path - Array of keys forming the path (e.g., ['user', 'address', 'city'])
636
+ */
637
+ declare function jsonDeepPathHelper<TFragment extends SQLFragment<any>>(fragment: TFragment, path: readonly string[]): SQLChainableFragment<ExtractFragmentFields<TFragment>, SupportedSQLValue>;
638
+ /**
639
+ * JSON deep path extraction (`#>`) from a field name. Returns JSON at the specified key path.
640
+ * Returns an SQLChainableFragment for fluent chaining.
641
+ *
642
+ * @param fieldName - The entity field name to extract from
643
+ * @param path - Array of keys forming the path (e.g., ['user', 'address', 'city'])
644
+ */
645
+ declare function jsonDeepPathHelper<TFields extends Record<string, any>, N extends keyof TFields>(fieldName: N, path: readonly string[]): SQLChainableFragment<TFields, SupportedSQLValue>;
646
+ /**
647
+ * JSON deep path text extraction (`#>>`) from a fragment. Returns text at the specified key path.
648
+ * Returns an SQLChainableFragment for fluent chaining.
649
+ *
650
+ * @param fragment - A SQLFragment or SQLChainableFragment to extract from
651
+ * @param path - Array of keys forming the path (e.g., ['user', 'address', 'city'])
652
+ */
653
+ declare function jsonDeepPathTextHelper<TFragment extends SQLFragment<any>>(fragment: TFragment, path: readonly string[]): SQLChainableFragment<ExtractFragmentFields<TFragment>, SupportedSQLValue>;
654
+ /**
655
+ * JSON deep path text extraction (`#>>`) from a field name. Returns text at the specified key path.
656
+ * Returns an SQLChainableFragment for fluent chaining.
657
+ *
658
+ * @param fieldName - The entity field name to extract from
659
+ * @param path - Array of keys forming the path (e.g., ['user', 'address', 'city'])
660
+ */
661
+ declare function jsonDeepPathTextHelper<TFields extends Record<string, any>, N extends keyof TFields>(fieldName: N, path: readonly string[]): SQLChainableFragment<TFields, SupportedSQLValue>;
662
+ /**
663
+ * SQL type cast (`::type`) from a fragment.
664
+ * Returns an SQLChainableFragment for fluent chaining.
665
+ *
666
+ * @param fragment - A SQLFragment or SQLChainableFragment to cast
667
+ * @param typeName - The PostgreSQL type name (e.g., 'int', 'text', 'timestamptz')
668
+ */
669
+ declare function castHelper<TFragment extends SQLFragment<any>>(fragment: TFragment, typeName: PostgresCastType): SQLChainableFragment<ExtractFragmentFields<TFragment>, SupportedSQLValue>;
670
+ /**
671
+ * SQL type cast (`::type`) from a field name.
672
+ * Returns an SQLChainableFragment for fluent chaining.
673
+ *
674
+ * @param fieldName - The entity field name to cast
675
+ * @param typeName - The PostgreSQL type name (e.g., 'int', 'text', 'timestamptz')
676
+ */
677
+ declare function castHelper<TFields extends Record<string, any>, N extends keyof TFields>(fieldName: N, typeName: PostgresCastType): SQLChainableFragment<TFields, SupportedSQLValue>;
678
+ /**
679
+ * Wraps a fragment in `LOWER()` to convert to lowercase.
680
+ * Returns an SQLChainableFragment for fluent chaining.
681
+ *
682
+ * @param fragment - A SQLFragment or SQLChainableFragment to convert
683
+ */
684
+ declare function lowerHelper<TFragment extends SQLFragment<any>>(fragment: TFragment): SQLChainableFragment<ExtractFragmentFields<TFragment>, SupportedSQLValue>;
685
+ /**
686
+ * Wraps a field in `LOWER()` to convert to lowercase.
687
+ * Returns an SQLChainableFragment for fluent chaining.
688
+ *
689
+ * @param fieldName - The entity field name to convert
690
+ */
691
+ declare function lowerHelper<TFields extends Record<string, any>, N extends PickStringValueKeys<TFields>>(fieldName: N): SQLChainableFragment<TFields, TFields[N]>;
692
+ /**
693
+ * Wraps a fragment in `UPPER()` to convert to uppercase.
694
+ * Returns an SQLChainableFragment for fluent chaining.
695
+ *
696
+ * @param fragment - A SQLFragment or SQLChainableFragment to convert
697
+ */
698
+ declare function upperHelper<TFragment extends SQLFragment<any>>(fragment: TFragment): SQLChainableFragment<ExtractFragmentFields<TFragment>, SupportedSQLValue>;
699
+ /**
700
+ * Wraps a field in `UPPER()` to convert to uppercase.
701
+ * Returns an SQLChainableFragment for fluent chaining.
702
+ *
703
+ * @param fieldName - The entity field name to convert
704
+ */
705
+ declare function upperHelper<TFields extends Record<string, any>, N extends PickStringValueKeys<TFields>>(fieldName: N): SQLChainableFragment<TFields, TFields[N]>;
706
+ /**
707
+ * Wraps a fragment in `TRIM()` to remove leading and trailing whitespace.
708
+ * Returns an SQLChainableFragment for fluent chaining.
709
+ *
710
+ * @param fragment - A SQLFragment or SQLChainableFragment to trim
711
+ */
712
+ declare function trimHelper<TFragment extends SQLFragment<any>>(fragment: TFragment): SQLChainableFragment<ExtractFragmentFields<TFragment>, SupportedSQLValue>;
713
+ /**
714
+ * Wraps a field in `TRIM()` to remove leading and trailing whitespace.
715
+ * Returns an SQLChainableFragment for fluent chaining.
716
+ *
717
+ * @param fieldName - The entity field name to trim
718
+ */
719
+ declare function trimHelper<TFields extends Record<string, any>, N extends PickStringValueKeys<TFields>>(fieldName: N): SQLChainableFragment<TFields, TFields[N]>;
720
+ /**
721
+ * Common SQL helper functions for building queries.
722
+ *
723
+ * All methods accept either a field name (string) or a SQLFragment/SQLChainableFragment as the
724
+ * first argument. When a SQLChainableFragment with a known TValue is passed (e.g. from trim, lower),
725
+ * value parameters are type-checked against that TValue.
726
+ *
727
+ * @example
728
+ * ```ts
729
+ * // Field name usage
730
+ * SQLExpression.eq('status', 'active')
731
+ *
732
+ * // SQLFragment/SQLChainableFragment usage
733
+ * SQLExpression.eq(sql`${entityField('status')}`, 'active')
734
+ * SQLExpression.eq(SQLExpression.trim('name'), 'hello') // value constrained to string
735
+ * ```
217
736
  */
218
- export declare const SQLFragmentHelpers: {
737
+ export declare const SQLExpression: {
219
738
  /**
220
- * IN clause helper
739
+ * IN clause helper.
221
740
  *
222
741
  * @example
223
742
  * ```ts
224
- * const query = SQLFragmentHelpers.inArray<MyFields, 'id'>('status', ['active', 'pending']);
225
- * // Generates: ?? IN (?, ?) with entityField binding for 'status' and value bindings
743
+ * SQLExpression.inArray('status', ['active', 'pending'])
744
+ * SQLExpression.inArray(SQLExpression.lower('status'), ['active', 'pending'])
226
745
  * ```
227
746
  */
228
- inArray<TFields extends Record<string, any>, N extends PickSupportedSQLValueKeys<TFields>>(fieldName: N, values: readonly TFields[N][]): SQLFragment<TFields>;
747
+ inArray: typeof inArrayHelper;
229
748
  /**
230
749
  * = ANY() clause helper. Binds the array as a single parameter instead of expanding it.
231
750
  * Semantically equivalent to IN for most cases, but retains a consistent query shape for
@@ -233,152 +752,150 @@ export declare const SQLFragmentHelpers: {
233
752
  *
234
753
  * @example
235
754
  * ```ts
236
- * const query = SQLFragmentHelpers.anyArray('status', ['active', 'pending']);
237
- * // Generates: ?? = ANY(?) with entityField binding for 'status' and a single array value binding
755
+ * SQLExpression.anyArray('status', ['active', 'pending'])
238
756
  * ```
239
757
  */
240
- anyArray<TFields extends Record<string, any>, N extends PickSupportedSQLValueKeys<TFields>>(fieldName: N, values: readonly TFields[N][]): SQLFragment<TFields>;
758
+ anyArray: typeof anyArrayHelper;
241
759
  /**
242
- * NOT IN clause helper
760
+ * NOT IN clause helper.
243
761
  */
244
- notInArray<TFields extends Record<string, any>, N extends PickSupportedSQLValueKeys<TFields>>(fieldName: N, values: readonly TFields[N][]): SQLFragment<TFields>;
762
+ notInArray: typeof notInArrayHelper;
245
763
  /**
246
- * BETWEEN helper
764
+ * BETWEEN helper.
247
765
  *
248
766
  * @example
249
767
  * ```ts
250
- * const query = SQLFragmentHelpers.between<MyFields, 'id'>('age', 18, 65);
251
- * // Generates: ?? BETWEEN ? AND ? with entityField binding for 'age' and value bindings
768
+ * SQLExpression.between('age', 18, 65)
769
+ * SQLExpression.between(SQLExpression.cast('age', 'int'), 18, 65)
252
770
  * ```
253
771
  */
254
- between<TFields extends Record<string, any>, N extends PickSupportedSQLValueKeys<TFields>>(fieldName: N, min: TFields[N], max: TFields[N]): SQLFragment<TFields>;
772
+ between: typeof betweenHelper;
255
773
  /**
256
- * NOT BETWEEN helper
774
+ * NOT BETWEEN helper.
257
775
  */
258
- notBetween<TFields extends Record<string, any>, N extends PickSupportedSQLValueKeys<TFields>>(fieldName: N, min: TFields[N], max: TFields[N]): SQLFragment<TFields>;
776
+ notBetween: typeof notBetweenHelper;
259
777
  /**
260
- * LIKE helper with automatic escaping
778
+ * LIKE helper for case-sensitive pattern matching.
261
779
  *
262
780
  * @example
263
781
  * ```ts
264
- * const query = SQLFragmentHelpers.like<MyFields, 'id'>('name', '%John%');
265
- * // Generates: ?? LIKE ? with entityField binding for 'name' and value binding
782
+ * SQLExpression.like('name', '%John%')
266
783
  * ```
267
784
  */
268
- like<TFields extends Record<string, any>>(fieldName: PickStringValueKeys<TFields>, pattern: string): SQLFragment<TFields>;
785
+ like: typeof likeHelper;
269
786
  /**
270
- * NOT LIKE helper
787
+ * NOT LIKE helper.
271
788
  */
272
- notLike<TFields extends Record<string, any>>(fieldName: PickStringValueKeys<TFields>, pattern: string): SQLFragment<TFields>;
789
+ notLike: typeof notLikeHelper;
273
790
  /**
274
- * ILIKE helper for case-insensitive matching
791
+ * ILIKE helper for case-insensitive matching (PostgreSQL-specific).
275
792
  */
276
- ilike<TFields extends Record<string, any>>(fieldName: PickStringValueKeys<TFields>, pattern: string): SQLFragment<TFields>;
793
+ ilike: typeof ilikeHelper;
277
794
  /**
278
- * NOT ILIKE helper for case-insensitive non-matching
795
+ * NOT ILIKE helper for case-insensitive non-matching (PostgreSQL-specific).
279
796
  */
280
- notIlike<TFields extends Record<string, any>>(fieldName: PickStringValueKeys<TFields>, pattern: string): SQLFragment<TFields>;
797
+ notIlike: typeof notIlikeHelper;
281
798
  /**
282
- * NULL check helper
799
+ * IS NULL check helper.
283
800
  */
284
- isNull<TFields extends Record<string, any>>(fieldName: keyof TFields): SQLFragment<TFields>;
801
+ isNull: typeof isNullHelper;
285
802
  /**
286
- * NOT NULL check helper
803
+ * IS NOT NULL check helper.
287
804
  */
288
- isNotNull<TFields extends Record<string, any>>(fieldName: keyof TFields): SQLFragment<TFields>;
805
+ isNotNull: typeof isNotNullHelper;
289
806
  /**
290
- * Single-equals-equality operator
807
+ * Equality operator. Automatically converts null/undefined to IS NULL.
291
808
  */
292
- eq<TFields extends Record<string, any>, N extends PickSupportedSQLValueKeys<TFields>>(fieldName: N, value: TFields[N]): SQLFragment<TFields>;
809
+ eq: typeof eqHelper;
293
810
  /**
294
- * Single-equals-inequality operator
811
+ * Inequality operator. Automatically converts null/undefined to IS NOT NULL.
295
812
  */
296
- neq<TFields extends Record<string, any>, N extends PickSupportedSQLValueKeys<TFields>>(fieldName: N, value: TFields[N]): SQLFragment<TFields>;
813
+ neq: typeof neqHelper;
297
814
  /**
298
- * Greater-than comparison operator
815
+ * Greater-than comparison operator.
299
816
  */
300
- gt<TFields extends Record<string, any>, N extends PickSupportedSQLValueKeys<TFields>>(fieldName: N, value: TFields[N]): SQLFragment<TFields>;
817
+ gt: typeof gtHelper;
301
818
  /**
302
- * Greater-than-or-equal-to comparison operator
819
+ * Greater-than-or-equal-to comparison operator.
303
820
  */
304
- gte<TFields extends Record<string, any>, N extends PickSupportedSQLValueKeys<TFields>>(fieldName: N, value: TFields[N]): SQLFragment<TFields>;
821
+ gte: typeof gteHelper;
305
822
  /**
306
- * Less-than comparison operator
823
+ * Less-than comparison operator.
307
824
  */
308
- lt<TFields extends Record<string, any>, N extends PickSupportedSQLValueKeys<TFields>>(fieldName: N, value: TFields[N]): SQLFragment<TFields>;
825
+ lt: typeof ltHelper;
309
826
  /**
310
- * Less-than-or-equal-to comparison operator
827
+ * Less-than-or-equal-to comparison operator.
311
828
  */
312
- lte<TFields extends Record<string, any>, N extends PickSupportedSQLValueKeys<TFields>>(fieldName: N, value: TFields[N]): SQLFragment<TFields>;
829
+ lte: typeof lteHelper;
313
830
  /**
314
- * JSON contains operator (\@\>)
831
+ * JSON contains operator (\@\>).
315
832
  */
316
- jsonContains<TFields extends Record<string, any>>(fieldName: keyof TFields, value: JsonSerializable): SQLFragment<TFields>;
833
+ jsonContains: typeof jsonContainsHelper;
317
834
  /**
318
- * JSON contained by operator (\<\@\)
835
+ * JSON contained by operator (\<\@\).
319
836
  */
320
- jsonContainedBy<TFields extends Record<string, any>>(fieldName: keyof TFields, value: JsonSerializable): SQLFragment<TFields>;
837
+ jsonContainedBy: typeof jsonContainedByHelper;
321
838
  /**
322
- * JSON path extraction helper (-\>)
323
- * Returns an SQLExpression so that fluent comparison methods can be chained.
839
+ * JSON path extraction helper (-\>).
840
+ * Returns an SQLChainableFragment so that fluent comparison methods can be chained.
324
841
  */
325
- jsonPath<TFields extends Record<string, any>>(fieldName: keyof TFields, path: string): SQLExpression<TFields>;
842
+ jsonPath: typeof jsonPathHelper;
326
843
  /**
327
- * JSON path text extraction helper (-\>\>)
328
- * Returns an SQLExpression so that fluent comparison methods can be chained.
844
+ * JSON path text extraction helper (-\>\>).
845
+ * Returns an SQLChainableFragment so that fluent comparison methods can be chained.
329
846
  */
330
- jsonPathText<TFields extends Record<string, any>>(fieldName: keyof TFields, path: string): SQLExpression<TFields>;
847
+ jsonPathText: typeof jsonPathTextHelper;
331
848
  /**
332
- * JSON deep path extraction helper (#\>)
849
+ * JSON deep path extraction helper (#\>).
333
850
  * Extracts a JSON sub-object at the specified key path, returning jsonb.
334
- * Returns an SQLExpression so that fluent comparison methods can be chained.
851
+ * Returns an SQLChainableFragment so that fluent comparison methods can be chained.
335
852
  *
336
- * @param fieldName - The entity field containing JSON/JSONB data
853
+ * @param expressionOrFieldName - A SQLFragment/SQLChainableFragment or entity field name
337
854
  * @param path - Array of keys forming the path (e.g., ['user', 'address', 'city'])
338
855
  */
339
- jsonDeepPath<TFields extends Record<string, any>>(fieldName: keyof TFields, path: readonly string[]): SQLExpression<TFields>;
856
+ jsonDeepPath: typeof jsonDeepPathHelper;
340
857
  /**
341
- * JSON deep path text extraction helper (#\>\>)
858
+ * JSON deep path text extraction helper (#\>\>).
342
859
  * Extracts a JSON sub-object at the specified key path as text.
343
- * Returns an SQLExpression so that fluent comparison methods can be chained.
860
+ * Returns an SQLChainableFragment so that fluent comparison methods can be chained.
344
861
  *
345
- * @param fieldName - The entity field containing JSON/JSONB data
862
+ * @param expressionOrFieldName - A SQLFragment/SQLChainableFragment or entity field name
346
863
  * @param path - Array of keys forming the path (e.g., ['user', 'address', 'city'])
347
864
  */
348
- jsonDeepPathText<TFields extends Record<string, any>>(fieldName: keyof TFields, path: readonly string[]): SQLExpression<TFields>;
865
+ jsonDeepPathText: typeof jsonDeepPathTextHelper;
349
866
  /**
350
- * SQL type cast helper (::type)
351
- * Casts an expression to a PostgreSQL type.
352
- * Returns an SQLExpression so that fluent comparison methods can be chained.
867
+ * SQL type cast helper (::type).
868
+ * Casts an expression or field to a PostgreSQL type.
869
+ * Returns an SQLChainableFragment so that fluent comparison methods can be chained.
353
870
  *
354
- * @param fragment - An SQLFragment or SQLExpression to cast
871
+ * @param expressionOrFieldName - A SQLFragment/SQLChainableFragment or entity field name to cast
355
872
  * @param typeName - The PostgreSQL type name (e.g., 'int', 'text', 'timestamptz')
356
873
  */
357
- cast<TFields extends Record<string, any>>(fragmentOrExpression: SQLFragment<TFields>, typeName: PostgresCastType): SQLExpression<TFields>;
874
+ cast: typeof castHelper;
358
875
  /**
359
- * COALESCE helper
876
+ * COALESCE helper.
360
877
  * Returns the first non-null value from the given expressions/values.
361
- * Returns an SQLExpression so that fluent comparison methods can be chained.
878
+ * Returns an SQLChainableFragment so that fluent comparison methods can be chained.
362
879
  */
363
- coalesce<TFields extends Record<string, any>>(...args: readonly (SQLFragment<TFields> | SupportedSQLValue)[]): SQLExpression<TFields>;
880
+ coalesce<TFields extends Record<string, any>>(...args: readonly (SQLFragment<TFields> | SupportedSQLValue)[]): SQLChainableFragment<TFields, SupportedSQLValue>;
364
881
  /**
365
882
  * LOWER helper
366
883
  * Converts a string expression to lowercase.
367
- * Returns an SQLExpression so that fluent comparison methods can be chained.
884
+ * Returns an SQLChainableFragment so that fluent comparison methods can be chained.
368
885
  */
369
- lower<TFields extends Record<string, any>>(expressionOrFieldName: SQLFragment<TFields> | keyof TFields): SQLExpression<TFields>;
886
+ lower: typeof lowerHelper;
370
887
  /**
371
888
  * UPPER helper
372
889
  * Converts a string expression to uppercase.
373
- * Returns an SQLExpression so that fluent comparison methods can be chained.
890
+ * Returns an SQLChainableFragment so that fluent comparison methods can be chained.
374
891
  */
375
- upper<TFields extends Record<string, any>>(expressionOrFieldName: SQLFragment<TFields> | keyof TFields): SQLExpression<TFields>;
892
+ upper: typeof upperHelper;
376
893
  /**
377
894
  * TRIM helper
378
895
  * Removes leading and trailing whitespace from a string expression.
379
- * Returns an SQLExpression so that fluent comparison methods can be chained.
896
+ * Returns an SQLChainableFragment so that fluent comparison methods can be chained.
380
897
  */
381
- trim<TFields extends Record<string, any>>(expressionOrFieldName: SQLFragment<TFields> | keyof TFields): SQLExpression<TFields>;
898
+ trim: typeof trimHelper;
382
899
  /**
383
900
  * Logical AND of multiple fragments
384
901
  */