uql-orm 0.91.1 → 0.93.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 (165) hide show
  1. package/dist/browser/http/bus.js +3 -4
  2. package/dist/browser/http/http.d.ts +1 -2
  3. package/dist/browser/http/http.js +8 -7
  4. package/dist/browser/index.d.ts +0 -1
  5. package/dist/browser/index.js +0 -1
  6. package/dist/browser/querier/httpQuerier.d.ts +18 -20
  7. package/dist/browser/querier/httpQuerier.js +20 -56
  8. package/dist/browser/type/index.d.ts +0 -1
  9. package/dist/browser/type/index.js +0 -1
  10. package/dist/browser/uql-browser.min.js +2 -2
  11. package/dist/browser/uql-browser.min.js.map +11 -12
  12. package/dist/cockroachdb/cockroachDialect.d.ts +4 -1
  13. package/dist/cockroachdb/cockroachDialect.js +6 -2
  14. package/dist/dialect/abstractDialect.d.ts +1 -1
  15. package/dist/dialect/abstractDialect.js +4 -1
  16. package/dist/dialect/abstractSqlDialect.d.ts +68 -37
  17. package/dist/dialect/abstractSqlDialect.js +185 -107
  18. package/dist/dialect/aliases.d.ts +4 -1
  19. package/dist/dialect/aliases.js +5 -2
  20. package/dist/dialect/hydrateColumn.js +3 -10
  21. package/dist/dialect/jsonSql.d.ts +4 -1
  22. package/dist/dialect/jsonSql.js +4 -1
  23. package/dist/dialect/mergeSqlDialect.d.ts +14 -4
  24. package/dist/dialect/mergeSqlDialect.js +32 -15
  25. package/dist/dialect/mysqlLikeSqlDialect.d.ts +16 -24
  26. package/dist/dialect/mysqlLikeSqlDialect.js +38 -52
  27. package/dist/dialect/pgLikeSqlDialect.d.ts +8 -8
  28. package/dist/dialect/pgLikeSqlDialect.js +19 -22
  29. package/dist/http/contract.d.ts +4 -0
  30. package/dist/http/contract.js +1 -0
  31. package/dist/http/handler.d.ts +2 -2
  32. package/dist/http/handler.js +17 -19
  33. package/dist/http/query.d.ts +5 -3
  34. package/dist/http/query.js +42 -42
  35. package/dist/index.d.ts +2 -2
  36. package/dist/index.js +2 -2
  37. package/dist/maria/mariaDialect.d.ts +4 -3
  38. package/dist/maria/mariaDialect.js +4 -6
  39. package/dist/migrate/builder/columnBuilder.d.ts +5 -15
  40. package/dist/migrate/builder/columnBuilder.js +50 -86
  41. package/dist/migrate/builder/index.d.ts +0 -1
  42. package/dist/migrate/builder/index.js +0 -1
  43. package/dist/migrate/builder/migrationBuilder.d.ts +3 -11
  44. package/dist/migrate/builder/migrationBuilder.js +41 -81
  45. package/dist/migrate/builder/tableBuilder.d.ts +0 -7
  46. package/dist/migrate/builder/tableBuilder.js +19 -30
  47. package/dist/migrate/builder/types.d.ts +2 -2
  48. package/dist/migrate/codegen/entityCodeGenerator.js +3 -3
  49. package/dist/migrate/codegen/entityTypes.js +2 -2
  50. package/dist/migrate/codegen/fieldOptionsSource.d.ts +2 -2
  51. package/dist/migrate/codegen/fieldOptionsSource.js +22 -14
  52. package/dist/migrate/codegen/indexDecoratorSource.js +64 -41
  53. package/dist/migrate/ddl/defaultSql.d.ts +31 -0
  54. package/dist/migrate/ddl/defaultSql.js +109 -0
  55. package/dist/migrate/ddl/index.d.ts +2 -4
  56. package/dist/migrate/ddl/index.js +14 -5
  57. package/dist/migrate/ddl/mssqlTableDdl.d.ts +1 -0
  58. package/dist/migrate/ddl/mssqlTableDdl.js +4 -1
  59. package/dist/migrate/ddl/mysqlTableDdl.d.ts +17 -0
  60. package/dist/migrate/ddl/mysqlTableDdl.js +33 -0
  61. package/dist/migrate/ddl/pgTableDdl.d.ts +7 -0
  62. package/dist/migrate/ddl/pgTableDdl.js +17 -0
  63. package/dist/migrate/ddl/tableDdl.d.ts +15 -10
  64. package/dist/migrate/ddl/tableDdl.js +31 -32
  65. package/dist/migrate/drift/driftDetector.js +46 -59
  66. package/dist/migrate/generator/definitionToNode.d.ts +11 -7
  67. package/dist/migrate/generator/definitionToNode.js +27 -34
  68. package/dist/migrate/generator/indexNodeToSchema.d.ts +3 -3
  69. package/dist/migrate/generator/indexNodeToSchema.js +5 -4
  70. package/dist/migrate/index.js +1 -1
  71. package/dist/migrate/introspection/abstractSqlSchemaIntrospector.d.ts +10 -5
  72. package/dist/migrate/introspection/abstractSqlSchemaIntrospector.js +9 -0
  73. package/dist/migrate/introspection/baseSqlIntrospector.d.ts +0 -1
  74. package/dist/migrate/introspection/baseSqlIntrospector.js +6 -8
  75. package/dist/migrate/introspection/mssqlIntrospector.js +3 -8
  76. package/dist/migrate/introspection/mysqlIntrospector.d.ts +11 -4
  77. package/dist/migrate/introspection/mysqlIntrospector.js +27 -11
  78. package/dist/migrate/introspection/postgresIntrospector.d.ts +2 -2
  79. package/dist/migrate/introspection/postgresIntrospector.js +3 -3
  80. package/dist/migrate/introspection/sqliteIntrospector.d.ts +1 -1
  81. package/dist/migrate/introspection/sqliteIntrospector.js +7 -10
  82. package/dist/migrate/migrationTarget.js +3 -3
  83. package/dist/migrate/schemaGenerator.d.ts +8 -12
  84. package/dist/migrate/schemaGenerator.js +36 -62
  85. package/dist/migrate/storage/databaseStorage.js +2 -2
  86. package/dist/migrate/triggerSql.d.ts +1 -1
  87. package/dist/migrate/triggerSql.js +17 -8
  88. package/dist/mongo/mongoDialect.d.ts +4 -3
  89. package/dist/mongo/mongoDialect.js +52 -38
  90. package/dist/mongo/mongoIntrospector.js +1 -1
  91. package/dist/mongo/mongoSchemaGenerator.d.ts +7 -4
  92. package/dist/mongo/mongoSchemaGenerator.js +18 -21
  93. package/dist/mongo/mongodbQuerier.d.ts +15 -8
  94. package/dist/mongo/mongodbQuerier.js +48 -33
  95. package/dist/mssql/mssqlDialect.d.ts +9 -5
  96. package/dist/mssql/mssqlDialect.js +23 -8
  97. package/dist/postgres/postgresDialect.d.ts +5 -2
  98. package/dist/postgres/postgresDialect.js +6 -6
  99. package/dist/querier/abstractQuerier.d.ts +20 -15
  100. package/dist/querier/abstractQuerier.js +93 -41
  101. package/dist/querier/abstractQuerierPool.d.ts +26 -24
  102. package/dist/querier/abstractQuerierPool.js +26 -64
  103. package/dist/querier/abstractSqlQuerier.d.ts +5 -6
  104. package/dist/querier/abstractSqlQuerier.js +15 -33
  105. package/dist/querier/cursor.d.ts +10 -0
  106. package/dist/querier/cursor.js +81 -0
  107. package/dist/querier/keyset.d.ts +19 -0
  108. package/dist/querier/keyset.js +198 -0
  109. package/dist/schema/canonicalType.d.ts +3 -3
  110. package/dist/schema/canonicalType.js +13 -12
  111. package/dist/schema/indexDifferences.d.ts +14 -7
  112. package/dist/schema/indexDifferences.js +7 -5
  113. package/dist/schema/schemaAST.d.ts +0 -1
  114. package/dist/schema/schemaAST.js +0 -2
  115. package/dist/schema/schemaASTBuilder.js +14 -20
  116. package/dist/schema/schemaASTDiffer.d.ts +7 -9
  117. package/dist/schema/schemaASTDiffer.js +54 -107
  118. package/dist/schema/sqlExpression.d.ts +28 -0
  119. package/dist/schema/sqlExpression.js +42 -0
  120. package/dist/schema/types.d.ts +48 -105
  121. package/dist/sqlite/sqliteDialect.d.ts +10 -13
  122. package/dist/sqlite/sqliteDialect.js +19 -30
  123. package/dist/type/dialect.d.ts +46 -11
  124. package/dist/type/dialect.js +2 -0
  125. package/dist/type/entity.d.ts +18 -3
  126. package/dist/type/migration.d.ts +7 -7
  127. package/dist/type/querier.d.ts +19 -26
  128. package/dist/type/query.d.ts +116 -25
  129. package/dist/type/query.js +21 -28
  130. package/dist/type/universalQuerier.d.ts +33 -7
  131. package/dist/type/utility.d.ts +10 -0
  132. package/dist/util/bytes.d.ts +7 -0
  133. package/dist/util/bytes.js +22 -0
  134. package/dist/util/date.d.ts +5 -0
  135. package/dist/util/date.js +5 -0
  136. package/dist/util/dialect.util.d.ts +1 -25
  137. package/dist/util/dialect.util.js +4 -50
  138. package/dist/util/field.util.d.ts +9 -0
  139. package/dist/util/field.util.js +15 -0
  140. package/dist/util/fieldOption.util.js +2 -2
  141. package/dist/util/index.d.ts +2 -1
  142. package/dist/util/index.js +2 -1
  143. package/dist/util/object.util.d.ts +0 -2
  144. package/dist/util/object.util.js +0 -7
  145. package/dist/util/query.util.d.ts +40 -0
  146. package/dist/util/query.util.js +76 -0
  147. package/dist/util/raw.d.ts +16 -1
  148. package/dist/util/raw.js +31 -0
  149. package/dist/util/relationQuery.util.js +18 -16
  150. package/dist/util/rowKey.util.js +2 -3
  151. package/dist/util/sql.util.d.ts +8 -2
  152. package/dist/util/sql.util.js +16 -17
  153. package/dist/util/sqlLiteral.js +2 -12
  154. package/dist/util/string.util.d.ts +5 -0
  155. package/dist/util/string.util.js +12 -0
  156. package/dist/util/triggerWrite.d.ts +11 -1
  157. package/dist/util/triggerWrite.js +14 -0
  158. package/package.json +1 -1
  159. package/skills/uql-orm/SKILL.md +22 -10
  160. package/dist/browser/options.d.ts +0 -4
  161. package/dist/browser/options.js +0 -13
  162. package/dist/browser/type/clientQuerierPool.d.ts +0 -4
  163. package/dist/browser/type/clientQuerierPool.js +0 -1
  164. package/dist/migrate/builder/expressions.d.ts +0 -69
  165. package/dist/migrate/builder/expressions.js +0 -145
@@ -1,4 +1,4 @@
1
- import type { QueryConflictPaths, QueryContext, QueryPager, Type } from '../type/index.js';
1
+ import type { EntityMeta, QueryConflictPaths, QueryContext, QueryPager, TriggerRows, Type, UpsertOptions } from '../type/index.js';
2
2
  import { AbstractSqlDialect } from './abstractSqlDialect.js';
3
3
  /** What SQL Server and Oracle share: paging and upsert spelled as the standard does. */
4
4
  export declare abstract class MergeSqlDialect extends AbstractSqlDialect {
@@ -8,10 +8,20 @@ export declare abstract class MergeSqlDialect extends AbstractSqlDialect {
8
8
  $distinct?: boolean;
9
9
  }, sorted?: boolean): void;
10
10
  /**
11
- * `MERGE`, its rows a `VALUES` source built by {@link AbstractSqlDialect.insertShape}. Every value binds
12
- * before the assignments, so `?` placeholders read in order.
11
+ * `MERGE` with its rows as a `VALUES` source built by {@link AbstractSqlDialect.insertShape}. The update
12
+ * assignments bind their values before the rows, though they follow them in the SQL; this works only because
13
+ * SQL Server numbers each placeholder (`@p1`).
13
14
  */
14
- upsert<E>(ctx: QueryContext, entity: Type<E>, conflictPaths: QueryConflictPaths<E>, payload: E | E[], extraReturning?: string): void;
15
+ upsert<E>(ctx: QueryContext, entity: Type<E>, conflictPaths: QueryConflictPaths<E>, payload: E | E[], { update }?: UpsertOptions<E>): void;
16
+ /** A trigger's upsert as a `MERGE` of the rows it was handed, `SELECT`ed off them as its source. */
17
+ protected appendTriggerUpsert<E>(ctx: QueryContext, meta: EntityMeta<E>, conflictPaths: QueryConflictPaths<E>, entries: readonly [string, unknown][], assignments: string, rows?: TriggerRows): void;
18
+ /**
19
+ * The rest of a `MERGE` once its source is written: the source named, matched on the conflict keys, updated
20
+ * by `assignments` where it matched, if any, and inserted where it did not.
21
+ */
22
+ private mergeMatch;
23
+ /** The source row through the alias `MERGE` gives it. */
24
+ protected upsertIncoming(column: string): string;
15
25
  /** `<target>.<col> = <source>.<col>` for every conflict key, which is what makes a row "the same". */
16
26
  private mergeOn;
17
27
  /**
@@ -1,6 +1,6 @@
1
1
  import { getMeta } from '../entity/index.js';
2
2
  import { assertNonNegativeInteger, getKeys } from '../util/index.js';
3
- import { AbstractSqlDialect } from './abstractSqlDialect.js';
3
+ import { AbstractSqlDialect, fromRows } from './abstractSqlDialect.js';
4
4
  import { UPSERT_SOURCE_ALIAS } from './aliases.js';
5
5
  /** What SQL Server and Oracle share: paging and upsert spelled as the standard does. */
6
6
  export class MergeSqlDialect extends AbstractSqlDialect {
@@ -21,32 +21,49 @@ export class MergeSqlDialect extends AbstractSqlDialect {
21
21
  }
22
22
  }
23
23
  /**
24
- * `MERGE`, its rows a `VALUES` source built by {@link AbstractSqlDialect.insertShape}. Every value binds
25
- * before the assignments, so `?` placeholders read in order.
24
+ * `MERGE` with its rows as a `VALUES` source built by {@link AbstractSqlDialect.insertShape}. The update
25
+ * assignments bind their values before the rows, though they follow them in the SQL; this works only because
26
+ * SQL Server numbers each placeholder (`@p1`).
26
27
  */
27
- upsert(ctx, entity, conflictPaths, payload, extraReturning = '') {
28
+ upsert(ctx, entity, conflictPaths, payload, { update } = {}) {
28
29
  const meta = getMeta(entity);
29
- const table = this.escapedTableName(meta);
30
- const source = this.escapeId(UPSERT_SOURCE_ALIAS, true);
31
30
  // Before the row source, which is what fills the payload's `onInsert` fields: a column that
32
31
  // exists only there - the generated key, `createdAt` - must not join the update set, or a row
33
32
  // that already existed has both rewritten.
34
- const update = this.getUpsertUpdateAssignments(ctx, meta, conflictPaths, payload, (col) => `${source}.${col}`);
33
+ const assignments = this.getUpsertUpdateAssignments(ctx, meta, conflictPaths, payload, update);
35
34
  const shape = this.insertShape(entity, payload);
36
- const columns = shape.columns.join(', ');
37
- ctx.append(`MERGE INTO ${table}${this.mergeTargetHint} USING (VALUES `);
35
+ ctx.append(`MERGE INTO ${this.escapedTableName(meta)}${this.mergeTargetHint} USING (VALUES `);
38
36
  this.appendValueRows(ctx, shape);
39
- ctx.append(`) AS ${source} (${columns}) ON ${this.mergeOn(meta, conflictPaths, table, source)}`);
40
- if (update) {
41
- ctx.append(` WHEN MATCHED THEN UPDATE SET ${update}`);
42
- }
43
- ctx.append(` WHEN NOT MATCHED THEN INSERT (${columns}) VALUES (${shape.columns.map((col) => `${source}.${col}`).join(', ')})`);
44
- const returning = [this.returningIdExpression(meta), extraReturning].filter(Boolean).join(', ');
37
+ ctx.append(`)${this.mergeMatch(meta, conflictPaths, shape.columns, assignments)}`);
38
+ const returning = this.returningIdExpression(meta);
45
39
  if (returning) {
46
40
  ctx.append(` ${this.mergeReturning(returning)}`);
47
41
  }
48
42
  ctx.append(this.statementTerminator);
49
43
  }
44
+ /** A trigger's upsert as a `MERGE` of the rows it was handed, `SELECT`ed off them as its source. */
45
+ appendTriggerUpsert(ctx, meta, conflictPaths, entries, assignments, rows) {
46
+ ctx.append(`MERGE INTO ${this.escapedTableName(meta)}${this.mergeTargetHint} USING (SELECT `);
47
+ this.appendTriggerValues(ctx, meta, entries);
48
+ const columns = entries.map(([key]) => this.escapedColumnName(meta, key));
49
+ ctx.append(`${rows ? fromRows(rows) : ''})${this.mergeMatch(meta, conflictPaths, columns, assignments)};`);
50
+ }
51
+ /**
52
+ * The rest of a `MERGE` once its source is written: the source named, matched on the conflict keys, updated
53
+ * by `assignments` where it matched, if any, and inserted where it did not.
54
+ */
55
+ mergeMatch(meta, conflictPaths, columns, assignments) {
56
+ const table = this.escapedTableName(meta);
57
+ const source = this.escapeId(UPSERT_SOURCE_ALIAS, true);
58
+ const matched = assignments ? ` WHEN MATCHED THEN UPDATE SET ${assignments}` : '';
59
+ const values = columns.map((col) => `${source}.${col}`).join(', ');
60
+ return (` AS ${source} (${columns.join(', ')}) ON ${this.mergeOn(meta, conflictPaths, table, source)}${matched}` +
61
+ ` WHEN NOT MATCHED THEN INSERT (${columns.join(', ')}) VALUES (${values})`);
62
+ }
63
+ /** The source row through the alias `MERGE` gives it. */
64
+ upsertIncoming(column) {
65
+ return `${this.escapeId(UPSERT_SOURCE_ALIAS, true)}.${column}`;
66
+ }
50
67
  /** `<target>.<col> = <source>.<col>` for every conflict key, which is what makes a row "the same". */
51
68
  mergeOn(meta, conflictPaths, table, source) {
52
69
  return getKeys(conflictPaths)
@@ -1,10 +1,12 @@
1
- import type { EntityMeta, FieldOptions, InsertIdSource, Query, QueryConflictPaths, QueryContext, QueryOptions, QueryPager, QueryTextSearchOptions, RowLockFeatures, SqlDialectFeatures, SqlDialectName, Type } from '../type/index.js';
1
+ import type { EntityMeta, InsertIdSource, Query, QueryConflictPaths, QueryContext, QueryOptions, QueryTextSearchOptions, RowLockFeatures, SqlDialectFeatures, SqlDialectName, SqlValues, Type, UpsertOptions } from '../type/index.js';
2
2
  import { AbstractSqlDialect, type DerivedRelation, type RelationRows } from './abstractSqlDialect.js';
3
3
  import { type JsonSlot } from './jsonSql.js';
4
- /** What the MySQL-family engines have. */
5
4
  /** Declared apart so MariaDB, which has no `FOR UPDATE OF`, can restate that one part of it. */
6
5
  export declare const MYSQL_ROW_LOCKS: RowLockFeatures;
6
+ /** The features of MySQL, which MariaDB starts from. */
7
7
  export declare const MYSQL_FEATURES: SqlDialectFeatures;
8
+ /** `(3)` keeps milliseconds, where a bare `CURRENT_TIMESTAMP` has whole seconds; `UUID()` is a version 1. */
9
+ export declare const MYSQL_SQL_VALUES: SqlValues;
8
10
  /** What MySQL and MariaDB share, their JSON functions above all: `JSON_LENGTH`, `JSON_CONTAINS`, `JSON_TABLE`, `JSON_SET`. */
9
11
  export declare abstract class MysqlLikeSqlDialect extends AbstractSqlDialect {
10
12
  /** Every member of this family runs the same SQL, so a body written once serves them all. */
@@ -16,29 +18,25 @@ export declare abstract class MysqlLikeSqlDialect extends AbstractSqlDialect {
16
18
  * from the connection's own database rather than a same-named table in another one.
17
19
  */
18
20
  estimatedCount<E>(ctx: QueryContext, entity: Type<E>): void;
19
- /** `OFFSET` is only legal after a `LIMIT` here, so a bare `$skip` needs one. */
20
- pager(ctx: QueryContext, opts: QueryPager): void;
21
+ protected readonly unboundedLimit: string;
21
22
  /** A signed key, so a foreign key taking its type from it matches, as MySQL refuses an `UNSIGNED` mismatch. */
22
23
  readonly autoIncrementSuffix = "AUTO_INCREMENT";
23
24
  readonly escapeIdChar = "`";
24
- readonly tableOptions = "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4";
25
25
  readonly beginTransactionCommand = "START TRANSACTION";
26
- readonly commitTransactionCommand = "COMMIT";
27
- readonly rollbackTransactionCommand = "ROLLBACK";
28
26
  readonly isolationLevelStrategy = "set-before";
29
- readonly dropForeignKeySyntax = "DROP FOREIGN KEY";
30
- readonly dropPrimaryKeySyntax = "DROP PRIMARY KEY";
31
- readonly dropIndexSyntax = "on-table";
32
- readonly alterColumnSyntax = "MODIFY COLUMN";
33
27
  readonly booleanLiteral = "integer";
28
+ readonly sqlValues: SqlValues;
34
29
  readonly insertIdSource: InsertIdSource;
30
+ /** `INSERT ... ON DUPLICATE KEY UPDATE`, the assignments bound after the insert, where a `?` reads them. */
31
+ upsert<E>(ctx: QueryContext, entity: Type<E>, conflictPaths: QueryConflictPaths<E>, payload: E | E[], { update }?: UpsertOptions<E>): void;
32
+ protected appendTriggerUpsert<E>(ctx: QueryContext, meta: EntityMeta<E>, _conflictPaths: QueryConflictPaths<E>, entries: readonly [string, unknown][], assignments: string): void;
35
33
  /**
36
- * `INSERT ... ON DUPLICATE KEY UPDATE`, or `INSERT IGNORE` where there is nothing to assign. The
37
- * assignments bind after the insert, where a `?` reads them.
34
+ * `insert` on a duplicate key: `ON DUPLICATE KEY UPDATE` with the new row named, or `INSERT IGNORE` where there
35
+ * is nothing to assign. MySQL matches on any unique key, not just the conflict paths, which it cannot name.
38
36
  */
39
- upsert<E>(ctx: QueryContext, entity: Type<E>, conflictPaths: QueryConflictPaths<E>, payload: E | E[]): void;
40
- /** Appended to both branches above: empty on MySQL, which has no `INSERT ... RETURNING`. */
41
- protected upsertReturning<E>(_meta: EntityMeta<E>): string;
37
+ private onDuplicateKey;
38
+ /** The new row through the alias it is given, or `VALUE(col)` where the dialect has no such syntax. */
39
+ protected upsertIncoming(column: string): string;
42
40
  /**
43
41
  * The alias the inserted row is given after the values list, and read back by the assignments.
44
42
  * Undefined where the dialect has no such syntax - MariaDB, which reads that row through
@@ -73,13 +71,13 @@ export declare abstract class MysqlLikeSqlDialect extends AbstractSqlDialect {
73
71
  protected readonly carriedFields: {
74
72
  numeric: (expr: string) => string;
75
73
  blob: (expr: string) => string;
76
- vector: (expr: string, field: FieldOptions) => string;
74
+ vector: (expr: string, field: import("../type/entity.js").FieldOptions) => string;
77
75
  };
78
76
  /** Bytes as the hex text `decodeColumn` reads back, whole. */
79
77
  protected bytesAsText(expr: string): string;
80
78
  escape(value: unknown): string;
81
79
  /** A date as UTC text, which a `DATETIME` stores as is, where a driver would convert it to its own zone. */
82
- normalizeValue(value: unknown): unknown;
80
+ protected readonly dateZone = "";
83
81
  /**
84
82
  * `MATCH(cols) AGAINST(?)`, which needs a `FULLTEXT` index over exactly those columns: without one
85
83
  * the server answers "Can't find FULLTEXT index matching the column list". Declare it with
@@ -94,11 +92,6 @@ export declare abstract class MysqlLikeSqlDialect extends AbstractSqlDialect {
94
92
  /** `DOUBLE`, never a bare `DECIMAL`, which is `DECIMAL(10,0)` and rounds `1.4` to `1`. */
95
93
  protected numericCast(expr: string): string;
96
94
  neExpr(field: string, ph: string): string;
97
- /**
98
- * Omitting the `COALESCE` on a NOT NULL column keeps MySQL's partial in-place JSON update
99
- * applicable: it requires the target column as the direct `JSON_SET` input.
100
- */
101
- protected jsonSet(ctx: QueryContext, expr: string, set: Record<string, unknown>, field?: FieldOptions): string;
102
95
  /**
103
96
  * `JSON_MERGE_PRESERVE` concatenates arrays and creates absent keys, so every pushed key is
104
97
  * handled in one call that references `expr` once - unlike `JSON_ARRAY_APPEND`, which needs a
@@ -112,7 +105,6 @@ export declare abstract class MysqlLikeSqlDialect extends AbstractSqlDialect {
112
105
  protected jsonPathReading(escapedColumn: string, path: string, mode: 'json' | 'text'): string;
113
106
  /** `JSON_CONTAINS` of the array as the path reads it, which is what a multi-valued index is matched by. */
114
107
  protected jsonContains(ctx: QueryContext, slot: JsonSlot, values: readonly unknown[]): string;
115
- protected jsonUnset(_ctx: QueryContext, expr: string, unset: readonly string[]): string;
116
108
  /** Only an array's, where `JSON_LENGTH` counts a scalar as 1 and an object by its keys. */
117
109
  protected jsonLength(slot: JsonSlot): string;
118
110
  protected jsonIsArray(slot: JsonSlot): string;
@@ -1,20 +1,19 @@
1
1
  import { getMeta } from '../entity/index.js';
2
- import { utcTimestamp } from '../util/date.js';
3
2
  import { textSearchFields } from '../util/index.js';
4
3
  import { escapeMysqlSqlLiteral, escapeSingleQuotes } from '../util/sqlLiteral.js';
5
- import { AbstractSqlDialect, } from './abstractSqlDialect.js';
4
+ import { ANSI_SQL_VALUES, AbstractSqlDialect, } from './abstractSqlDialect.js';
6
5
  import { AGGREGATE_VALUE_ALIAS } from './aliases.js';
7
6
  import { BYTES_PREFIX } from './hydrateColumn.js';
8
- import { jsonSetCall, jsonPath, jsonRemoveCall, jsonSetTarget } from './jsonSql.js';
7
+ import { jsonPath } from './jsonSql.js';
9
8
  import { aggregatesRelations } from './queryJoins.js';
10
9
  /**
11
10
  * The largest `BIGINT UNSIGNED`: the row count MySQL's manual gives for "all rows from the offset on",
12
11
  * and the largest `group_concat_max_len` either engine takes.
13
12
  */
14
13
  const MAX_LIMIT = BigInt.asUintN(64, -1n);
15
- /** What the MySQL-family engines have. */
16
14
  /** Declared apart so MariaDB, which has no `FOR UPDATE OF`, can restate that one part of it. */
17
15
  export const MYSQL_ROW_LOCKS = { of: true, withWindow: true, placement: 'suffix' };
16
+ /** The features of MySQL, which MariaDB starts from. */
18
17
  export const MYSQL_FEATURES = {
19
18
  indexIfNotExists: false,
20
19
  schemas: true,
@@ -30,6 +29,7 @@ export const MYSQL_FEATURES = {
30
29
  serverSideCursors: false,
31
30
  correlatedWrites: true,
32
31
  rowLocks: MYSQL_ROW_LOCKS,
32
+ nullsSortLowest: true,
33
33
  nullsOrdering: 'expression',
34
34
  textScoreIndexes: true,
35
35
  orderedUpsertReturning: true,
@@ -38,17 +38,23 @@ export const MYSQL_FEATURES = {
38
38
  vectorTuningNeedsTransaction: false,
39
39
  serialDeclaresPrimaryKey: false,
40
40
  triggers: {
41
- preamble: '',
42
41
  assignsRow: true,
43
42
  body: 'inline',
44
43
  fires: 'eachRowIf',
45
44
  layout: 'timingFirst',
46
45
  scope: 'schema',
47
46
  before: true,
47
+ deferrable: false,
48
48
  },
49
49
  };
50
50
  /** The one `JSON_TABLE` column an exploded array reads each element through, as a JSON document. */
51
51
  const ELEM_COLUMN = 'v';
52
+ /** `(3)` keeps milliseconds, where a bare `CURRENT_TIMESTAMP` has whole seconds; `UUID()` is a version 1. */
53
+ export const MYSQL_SQL_VALUES = {
54
+ ...ANSI_SQL_VALUES,
55
+ currentTimestamp: 'CURRENT_TIMESTAMP(3)',
56
+ uuid: 'UUID()',
57
+ };
52
58
  /** What MySQL and MariaDB share, their JSON functions above all: `JSON_LENGTH`, `JSON_CONTAINS`, `JSON_TABLE`, `JSON_SET`. */
53
59
  export class MysqlLikeSqlDialect extends AbstractSqlDialect {
54
60
  /** Every member of this family runs the same SQL, so a body written once serves them all. */
@@ -74,54 +80,46 @@ export class MysqlLikeSqlDialect extends AbstractSqlDialect {
74
80
  ctx.append(' AND TABLE_NAME = ');
75
81
  ctx.addValue(this.resolveTableAlias(meta));
76
82
  }
77
- /** `OFFSET` is only legal after a `LIMIT` here, so a bare `$skip` needs one. */
78
- pager(ctx, opts) {
79
- if (opts.$limit === undefined && opts.$skip !== undefined) {
80
- ctx.append(` LIMIT ${MAX_LIMIT}`);
81
- }
82
- super.pager(ctx, opts);
83
- }
83
+ unboundedLimit = String(MAX_LIMIT);
84
84
  /** A signed key, so a foreign key taking its type from it matches, as MySQL refuses an `UNSIGNED` mismatch. */
85
85
  autoIncrementSuffix = 'AUTO_INCREMENT';
86
86
  escapeIdChar = '`';
87
- tableOptions = 'ENGINE=InnoDB DEFAULT CHARSET=utf8mb4';
88
87
  beginTransactionCommand = 'START TRANSACTION';
89
- commitTransactionCommand = 'COMMIT';
90
- rollbackTransactionCommand = 'ROLLBACK';
91
88
  isolationLevelStrategy = 'set-before';
92
- dropForeignKeySyntax = 'DROP FOREIGN KEY';
93
- dropPrimaryKeySyntax = 'DROP PRIMARY KEY';
94
- dropIndexSyntax = 'on-table';
95
- alterColumnSyntax = 'MODIFY COLUMN';
96
89
  booleanLiteral = 'integer';
90
+ sqlValues = MYSQL_SQL_VALUES;
97
91
  // No `RETURNING` support, so multi-row insert IDs are inferred from the header - see the
98
92
  // `innodb_autoinc_lock_mode` caveat on `buildUpdateResult` in `util/sql.util.ts`.
99
93
  insertIdSource = 'firstId';
100
- /**
101
- * `INSERT ... ON DUPLICATE KEY UPDATE`, or `INSERT IGNORE` where there is nothing to assign. The
102
- * assignments bind after the insert, where a `?` reads them.
103
- */
104
- upsert(ctx, entity, conflictPaths, payload) {
94
+ /** `INSERT ... ON DUPLICATE KEY UPDATE`, the assignments bound after the insert, where a `?` reads them. */
95
+ upsert(ctx, entity, conflictPaths, payload, { update } = {}) {
105
96
  const meta = getMeta(entity);
106
- const alias = this.upsertNewRowAlias && this.escapeId(this.upsertNewRowAlias, true);
107
97
  const updateCtx = this.createContext();
108
- const update = this.getUpsertUpdateAssignments(updateCtx, meta, conflictPaths, payload, (name) => alias ? `${alias}.${name}` : `VALUE(${name})`);
109
- const returning = this.upsertReturning(meta);
110
- if (update) {
111
- this.appendInsertValues(ctx, entity, payload);
112
- ctx.append(`${alias ? ` AS ${alias}` : ''} ON DUPLICATE KEY UPDATE ${update}${returning}`);
113
- ctx.pushValue(...updateCtx.values);
114
- return;
115
- }
98
+ const assignments = this.getUpsertUpdateAssignments(updateCtx, meta, conflictPaths, payload, update);
116
99
  const insertCtx = this.createContext();
117
100
  this.appendInsertValues(insertCtx, entity, payload);
118
- ctx.append(insertCtx.sql.replace(/^INSERT/, 'INSERT IGNORE'));
119
- ctx.append(returning);
120
- ctx.pushValue(...insertCtx.values);
101
+ const idReturning = this.insertedIdReturning(meta);
102
+ ctx.append(`${this.onDuplicateKey(insertCtx.sql, assignments)}${idReturning && ` ${idReturning}`}`);
103
+ ctx.pushValue(...insertCtx.values, ...updateCtx.values);
121
104
  }
122
- /** Appended to both branches above: empty on MySQL, which has no `INSERT ... RETURNING`. */
123
- upsertReturning(_meta) {
124
- return '';
105
+ appendTriggerUpsert(ctx, meta, _conflictPaths, entries, assignments) {
106
+ const insert = this.buildFragment(ctx, (fragmentCtx) => this.appendTriggerInsert(fragmentCtx, meta, entries));
107
+ ctx.append(`${this.onDuplicateKey(insert, assignments)};`);
108
+ }
109
+ /**
110
+ * `insert` on a duplicate key: `ON DUPLICATE KEY UPDATE` with the new row named, or `INSERT IGNORE` where there
111
+ * is nothing to assign. MySQL matches on any unique key, not just the conflict paths, which it cannot name.
112
+ */
113
+ onDuplicateKey(insert, assignments) {
114
+ if (!assignments) {
115
+ return insert.replace(/^INSERT/, 'INSERT IGNORE');
116
+ }
117
+ const alias = this.upsertNewRowAlias && ` AS ${this.escapeId(this.upsertNewRowAlias, true)}`;
118
+ return `${insert}${alias ?? ''} ON DUPLICATE KEY UPDATE ${assignments}`;
119
+ }
120
+ /** The new row through the alias it is given, or `VALUE(col)` where the dialect has no such syntax. */
121
+ upsertIncoming(column) {
122
+ return this.upsertNewRowAlias ? `${this.escapeId(this.upsertNewRowAlias, true)}.${column}` : `VALUE(${column})`;
125
123
  }
126
124
  /**
127
125
  * The alias the inserted row is given after the values list, and read back by the assignments.
@@ -186,9 +184,7 @@ export class MysqlLikeSqlDialect extends AbstractSqlDialect {
186
184
  return escapeMysqlSqlLiteral(value);
187
185
  }
188
186
  /** A date as UTC text, which a `DATETIME` stores as is, where a driver would convert it to its own zone. */
189
- normalizeValue(value) {
190
- return value instanceof Date ? utcTimestamp(value) : super.normalizeValue(value);
191
- }
187
+ dateZone = '';
192
188
  /**
193
189
  * `MATCH(cols) AGAINST(?)`, which needs a `FULLTEXT` index over exactly those columns: without one
194
190
  * the server answers "Can't find FULLTEXT index matching the column list". Declare it with
@@ -214,13 +210,6 @@ export class MysqlLikeSqlDialect extends AbstractSqlDialect {
214
210
  // MySQL/MariaDB null-safe inequality: true when values differ or one side is NULL.
215
211
  return `NOT (${field} <=> ${ph})`;
216
212
  }
217
- /**
218
- * Omitting the `COALESCE` on a NOT NULL column keeps MySQL's partial in-place JSON update
219
- * applicable: it requires the target column as the direct `JSON_SET` input.
220
- */
221
- jsonSet(ctx, expr, set, field) {
222
- return jsonSetCall((value) => this.jsonScalarParam(ctx, value), jsonSetTarget(expr, field, `'{}'`), set, this.maxFunctionArgs);
223
- }
224
213
  /**
225
214
  * `JSON_MERGE_PRESERVE` concatenates arrays and creates absent keys, so every pushed key is
226
215
  * handled in one call that references `expr` once - unlike `JSON_ARRAY_APPEND`, which needs a
@@ -241,9 +230,6 @@ export class MysqlLikeSqlDialect extends AbstractSqlDialect {
241
230
  jsonContains(ctx, slot, values) {
242
231
  return `JSON_CONTAINS(${this.jsonValue(slot)}, ${this.addValue(ctx, JSON.stringify(values))})`;
243
232
  }
244
- jsonUnset(_ctx, expr, unset) {
245
- return jsonRemoveCall(expr, unset, this.maxFunctionArgs);
246
- }
247
233
  /** Only an array's, where `JSON_LENGTH` counts a scalar as 1 and an object by its keys. */
248
234
  jsonLength(slot) {
249
235
  return `CASE WHEN ${this.jsonIsArray(slot)} THEN JSON_LENGTH(${this.jsonValue(slot)}) END`;
@@ -1,5 +1,5 @@
1
1
  import type { IndexType } from '../schema/types.js';
2
- import type { SqlDialectName } from '../type/index.js';
2
+ import type { SqlDialectName, SqlValues } from '../type/index.js';
3
3
  import { type DriverCapabilities, type EntityMeta, type FieldOptions, type JsonColumnType, type Query, type QueryContext, type QueryTextSearchOptions, type SqlDialectFeatures, type VectorDistance, type VectorMetric } from '../type/index.js';
4
4
  import type { DialectOptions } from './abstractDialect.js';
5
5
  import { AbstractSqlDialect, type RelationRows } from './abstractSqlDialect.js';
@@ -12,6 +12,7 @@ export type PgLikeDialectOptions = DialectOptions & {
12
12
  export declare const PG_VECTOR_METRICS: ReadonlyMap<VectorDistance, VectorMetric>;
13
13
  /** What the Postgres-wire engines have. */
14
14
  export declare const PG_FEATURES: SqlDialectFeatures;
15
+ export declare const PG_SQL_VALUES: SqlValues;
15
16
  /** What Postgres and CockroachDB share: JSONB, full-text search, pgvector's operators, and the upsert. */
16
17
  export declare abstract class PgLikeSqlDialect extends AbstractSqlDialect {
17
18
  /** Every member of this family runs the same SQL, so a body written once serves them all. */
@@ -20,13 +21,11 @@ export declare abstract class PgLikeSqlDialect extends AbstractSqlDialect {
20
21
  readonly driverCapabilities: DriverCapabilities;
21
22
  constructor(options?: PgLikeDialectOptions);
22
23
  readonly features: SqlDialectFeatures;
24
+ readonly sqlValues: SqlValues;
25
+ /** `USING MESSAGE`, so the text is taken as it is rather than as a format reading each `%`. */
26
+ protected refusal(message: string): string;
23
27
  readonly escapeIdChar = "\"";
24
28
  readonly autoIncrementSuffix: string;
25
- readonly tableOptions = "";
26
- readonly beginTransactionCommand = "BEGIN";
27
- readonly commitTransactionCommand = "COMMIT";
28
- readonly rollbackTransactionCommand = "ROLLBACK";
29
- readonly alterColumnStrategy = "separate-clauses";
30
29
  /**
31
30
  * `JSON_AGG` of each row whole, read through a LATERAL projection of the columns it answers under:
32
31
  * the sort terms carried out beside them order it without joining the object, and no function call
@@ -45,7 +44,6 @@ export declare abstract class PgLikeSqlDialect extends AbstractSqlDialect {
45
44
  };
46
45
  /** `$N` placeholders carry their own index, so the upsert's assignments need no scratch context. */
47
46
  protected readonly upsertUpdateBindsInPlace = true;
48
- readonly insertIdSource = "returning";
49
47
  readonly maxBindValues: number;
50
48
  readonly vectorMetrics: ReadonlyMap<VectorDistance, VectorMetric>;
51
49
  /**
@@ -59,6 +57,8 @@ export declare abstract class PgLikeSqlDialect extends AbstractSqlDialect {
59
57
  * by distance, which would otherwise drop rows the candidate list missed.
60
58
  */
61
59
  vectorTuningStatements<E>(meta: EntityMeta<E>, q: Query<E>): readonly string[];
60
+ /** Binds a date as UTC text, which a zoneless `TIMESTAMP` stores as is, instead of each driver picking a zone. */
61
+ protected readonly dateZone = "+00";
62
62
  normalizeValue(value: unknown): unknown;
63
63
  placeholder(index: number): string;
64
64
  /**
@@ -97,7 +97,7 @@ export declare abstract class PgLikeSqlDialect extends AbstractSqlDialect {
97
97
  protected jsonPathReading(escapedColumn: string, path: string, mode: 'json' | 'text'): string;
98
98
  /** A number only where the value is one: the cast throws on any other text, failing the whole read. */
99
99
  jsonPathExpr(escapedColumn: string, path: string, mode: JsonAccessMode): string;
100
- protected get regexpOp(): string;
100
+ protected regexCondition(operand: string, placeholder: string): string;
101
101
  protected readonly caseInsensitiveMatch = "ilike";
102
102
  neExpr(field: string, ph: string): string;
103
103
  /**
@@ -1,8 +1,8 @@
1
1
  import { QueryRaw, } from '../type/index.js';
2
- import { utcTimestamp } from '../util/date.js';
2
+ import { bytesToHex } from '../util/bytes.js';
3
3
  import { fulltextConfig, fulltextIndexOver, hasVectorNear, textSearchFields } from '../util/dialect.util.js';
4
4
  import { escapePgSqlLiteral, escapeSingleQuotes, PG_UTC } from '../util/sqlLiteral.js';
5
- import { AbstractSqlDialect } from './abstractSqlDialect.js';
5
+ import { ANSI_SQL_VALUES, AbstractSqlDialect } from './abstractSqlDialect.js';
6
6
  import { JSON_PULL_ALIAS, RELATION_ROW_ALIAS } from './aliases.js';
7
7
  import { BYTES_PREFIX } from './hydrateColumn.js';
8
8
  import { jsonSetTarget } from './jsonSql.js';
@@ -32,6 +32,7 @@ export const PG_FEATURES = {
32
32
  serverSideCursors: true,
33
33
  correlatedWrites: true,
34
34
  rowLocks: { of: true, withWindow: false, placement: 'suffix' },
35
+ nullsSortLowest: false,
35
36
  nullsOrdering: 'clause',
36
37
  textScoreIndexes: false,
37
38
  orderedUpsertReturning: true,
@@ -40,15 +41,16 @@ export const PG_FEATURES = {
40
41
  vectorTuningNeedsTransaction: true,
41
42
  serialDeclaresPrimaryKey: false,
42
43
  triggers: {
43
- preamble: '',
44
44
  assignsRow: true,
45
45
  body: 'function',
46
46
  fires: 'eachRowWhen',
47
47
  layout: 'timingFirst',
48
48
  scope: 'table',
49
49
  before: true,
50
+ deferrable: true,
50
51
  },
51
52
  };
53
+ export const PG_SQL_VALUES = { ...ANSI_SQL_VALUES, uuid: 'gen_random_uuid()' };
52
54
  /** What Postgres and CockroachDB share: JSONB, full-text search, pgvector's operators, and the upsert. */
53
55
  export class PgLikeSqlDialect extends AbstractSqlDialect {
54
56
  /** Every member of this family runs the same SQL, so a body written once serves them all. */
@@ -62,17 +64,17 @@ export class PgLikeSqlDialect extends AbstractSqlDialect {
62
64
  this.driverCapabilities = { nativeArrays: true, explicitJsonCast: false, ...options.driverCapabilities };
63
65
  }
64
66
  features = PG_FEATURES;
67
+ sqlValues = PG_SQL_VALUES;
68
+ /** `USING MESSAGE`, so the text is taken as it is rather than as a format reading each `%`. */
69
+ refusal(message) {
70
+ return `RAISE EXCEPTION USING MESSAGE = ${message};`;
71
+ }
65
72
  escapeIdChar = '"';
66
73
  // Shared default for both dialects. CockroachDB docs flag sequential PKs as a hotspotting risk
67
74
  // under heavy concurrent insert load (writes concentrate on one range); this default still beats
68
75
  // `SERIAL` (CockroachDB's `unique_rowid()`, a ~64-bit value that overflows JS's safe-integer
69
76
  // range). High-throughput CockroachDB users should override this per-entity with a UUID PK.
70
77
  autoIncrementSuffix = 'GENERATED BY DEFAULT AS IDENTITY';
71
- tableOptions = '';
72
- beginTransactionCommand = 'BEGIN';
73
- commitTransactionCommand = 'COMMIT';
74
- rollbackTransactionCommand = 'ROLLBACK';
75
- alterColumnStrategy = 'separate-clauses';
76
78
  /**
77
79
  * `JSON_AGG` of each row whole, read through a LATERAL projection of the columns it answers under:
78
80
  * the sort terms carried out beside them order it without joining the object, and no function call
@@ -97,7 +99,6 @@ export class PgLikeSqlDialect extends AbstractSqlDialect {
97
99
  };
98
100
  /** `$N` placeholders carry their own index, so the upsert's assignments need no scratch context. */
99
101
  upsertUpdateBindsInPlace = true;
100
- insertIdSource = 'returning';
101
102
  maxBindValues = 65535;
102
103
  vectorMetrics = PG_VECTOR_METRICS;
103
104
  /**
@@ -125,12 +126,14 @@ export class PgLikeSqlDialect extends AbstractSqlDialect {
125
126
  }
126
127
  return statements;
127
128
  }
129
+ /** Binds a date as UTC text, which a zoneless `TIMESTAMP` stores as is, instead of each driver picking a zone. */
130
+ dateZone = PG_UTC;
128
131
  normalizeValue(value) {
129
132
  if (Array.isArray(value)) {
130
- const values = value.map(utcDate);
133
+ const values = value.map((item) => super.normalizeValue(item));
131
134
  return this.driverCapabilities.nativeArrays ? values : toPgArray(values);
132
135
  }
133
- return super.normalizeValue(utcDate(value));
136
+ return super.normalizeValue(value);
134
137
  }
135
138
  placeholder(index) {
136
139
  return `$${index}`;
@@ -221,8 +224,8 @@ export class PgLikeSqlDialect extends AbstractSqlDialect {
221
224
  }
222
225
  return `CASE WHEN JSONB_TYPEOF(${this.jsonValue({ base: escapedColumn, path })}) = 'number' THEN ${read} END`;
223
226
  }
224
- get regexpOp() {
225
- return '~';
227
+ regexCondition(operand, placeholder) {
228
+ return `${operand} ~ ${placeholder}`;
226
229
  }
227
230
  caseInsensitiveMatch = 'ilike';
228
231
  neExpr(field, ph) {
@@ -308,10 +311,6 @@ export class PgLikeSqlDialect extends AbstractSqlDialect {
308
311
  return this.driverCapabilities.explicitJsonCast ? `(${ph}::text)::${type}` : `${ph}::${type}`;
309
312
  }
310
313
  }
311
- /** A date as UTC text, which a zoneless `TIMESTAMP` stores as is, where each driver would pick its own zone. */
312
- function utcDate(value) {
313
- return value instanceof Date ? utcTimestamp(value, PG_UTC) : value;
314
- }
315
314
  /**
316
315
  * Converts a JS array to a Postgres array literal string: `{"val1","val2"}`.
317
316
  * Safely handles nesting and escaping of special characters.
@@ -324,11 +323,9 @@ function toPgArray(arr) {
324
323
  return toPgArray(val);
325
324
  if (typeof val === 'boolean')
326
325
  return val ? 'true' : 'false';
327
- if (val instanceof Uint8Array || (typeof Buffer !== 'undefined' && Buffer.isBuffer(val))) {
328
- const hex = Array.from(val)
329
- .map((b) => b.toString(16).padStart(2, '0'))
330
- .join('');
331
- return `"\\\\x${hex}"`;
326
+ // A Node `Buffer` is a `Uint8Array` too.
327
+ if (val instanceof Uint8Array) {
328
+ return `"\\\\x${bytesToHex(val)}"`;
332
329
  }
333
330
  const str = String(val);
334
331
  const escaped = str.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
@@ -9,6 +9,10 @@ export declare const CRUD_ROUTES: {
9
9
  readonly method: 'GET';
10
10
  readonly path: '';
11
11
  };
12
+ readonly findManyPage: {
13
+ readonly method: 'GET';
14
+ readonly path: '/page';
15
+ };
12
16
  readonly findOne: {
13
17
  readonly method: 'GET';
14
18
  readonly path: '/one';
@@ -9,6 +9,7 @@ import { kebabCase } from '../util/string.util.js';
9
9
  */
10
10
  export const CRUD_ROUTES = {
11
11
  findMany: { method: 'GET', path: '' },
12
+ findManyPage: { method: 'GET', path: '/page' },
12
13
  findOne: { method: 'GET', path: '/one' },
13
14
  count: { method: 'GET', path: '/count' },
14
15
  findOneById: { method: 'GET', path: '/:id' },
@@ -1,6 +1,6 @@
1
1
  import type { EntityMeta, QuerierPool, Query, RequestSuccessResponse, Type, UqlContext } from '../type/index.js';
2
2
  import { type CrudOperation, type HttpMethod } from './contract.js';
3
- import { type WireFlags } from './query.js';
3
+ import { type WireCursors, type WireFlags } from './query.js';
4
4
  /**
5
5
  * Framework-normalized request: adapters (express, fetch, ...) reduce their native
6
6
  * request to this shape and get back a status + JSON body.
@@ -31,7 +31,7 @@ export type HookContext<E extends object, Ctx = unknown> = {
31
31
  readonly op: CrudOperation;
32
32
  readonly method: HttpMethod;
33
33
  /** The parsed query, to reshape in place. Scope rows with a `security` filter instead, which a client cannot override. */
34
- query: Query<E> & WireFlags;
34
+ query: Query<E> & WireFlags & WireCursors;
35
35
  /**
36
36
  * request payload - reassignable for sanitization or field injection.
37
37
  */