uql-orm 0.107.3 → 0.108.1

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 (89) hide show
  1. package/dist/browser/uql-browser.min.js +2 -2
  2. package/dist/browser/uql-browser.min.js.map +5 -5
  3. package/dist/cockroachdb/cockroachDialect.d.ts +1 -4
  4. package/dist/cockroachdb/cockroachDialect.js +1 -5
  5. package/dist/dialect/abstractSqlDialect.d.ts +84 -43
  6. package/dist/dialect/abstractSqlDialect.js +270 -192
  7. package/dist/dialect/aliases.d.ts +2 -0
  8. package/dist/dialect/aliases.js +2 -0
  9. package/dist/dialect/jsonSql.d.ts +9 -7
  10. package/dist/dialect/jsonSql.js +16 -10
  11. package/dist/dialect/mergeSqlDialect.d.ts +5 -7
  12. package/dist/dialect/mergeSqlDialect.js +20 -19
  13. package/dist/dialect/mysqlLikeSqlDialect.d.ts +12 -6
  14. package/dist/dialect/mysqlLikeSqlDialect.js +34 -12
  15. package/dist/dialect/operators.d.ts +7 -1
  16. package/dist/dialect/operators.js +37 -2
  17. package/dist/dialect/pgLikeSqlDialect.d.ts +4 -4
  18. package/dist/dialect/pgLikeSqlDialect.js +8 -7
  19. package/dist/entity/index.d.ts +1 -1
  20. package/dist/entity/index.js +1 -1
  21. package/dist/entity/metadata/definedFixture/author.d.ts +4 -4
  22. package/dist/entity/metadata/definedFixture/book.d.ts +5 -5
  23. package/dist/entity/metadata/definition.d.ts +2 -0
  24. package/dist/entity/metadata/definition.js +19 -11
  25. package/dist/index.d.ts +1 -1
  26. package/dist/index.js +1 -1
  27. package/dist/mariadb/mariaDialect.d.ts +2 -2
  28. package/dist/mariadb/mariaDialect.js +3 -2
  29. package/dist/migrate/codegen/fieldOptionsSource.js +28 -7
  30. package/dist/migrate/ddl/defaultSql.d.ts +3 -2
  31. package/dist/migrate/ddl/defaultSql.js +8 -12
  32. package/dist/migrate/ddl/mysqlTableDdl.js +1 -1
  33. package/dist/migrate/ddl/tableDdl.d.ts +1 -1
  34. package/dist/migrate/drift/driftDetector.js +10 -3
  35. package/dist/migrate/introspection/abstractSqlSchemaIntrospector.d.ts +2 -2
  36. package/dist/migrate/introspection/mssqlIntrospector.d.ts +2 -2
  37. package/dist/migrate/introspection/mysqlIntrospector.d.ts +2 -2
  38. package/dist/migrate/introspection/postgresIntrospector.d.ts +2 -2
  39. package/dist/migrate/introspection/sqliteIntrospector.d.ts +2 -2
  40. package/dist/migrate/migrator.js +2 -1
  41. package/dist/migrate/schemaChange.d.ts +0 -2
  42. package/dist/migrate/schemaChange.js +1 -4
  43. package/dist/migrate/schemaGenerator.d.ts +2 -2
  44. package/dist/migrate/triggerSql.js +11 -15
  45. package/dist/mongodb/mongoDialect.d.ts +6 -1
  46. package/dist/mongodb/mongoDialect.js +90 -46
  47. package/dist/mongodb/mongoSchemaGenerator.js +2 -2
  48. package/dist/mongodb/mongodbQuerier.d.ts +7 -9
  49. package/dist/mongodb/mongodbQuerier.js +54 -47
  50. package/dist/mssql/mssqlDialect.d.ts +9 -9
  51. package/dist/mssql/mssqlDialect.js +51 -28
  52. package/dist/mssql/mssqlWireTypes.d.ts +1 -4
  53. package/dist/mssql/mssqlWireTypes.js +19 -10
  54. package/dist/querier/abstractQuerier.d.ts +53 -29
  55. package/dist/querier/abstractQuerier.js +154 -102
  56. package/dist/querier/abstractSqlQuerier.d.ts +41 -10
  57. package/dist/querier/abstractSqlQuerier.js +145 -79
  58. package/dist/schema/declaredColumn.js +2 -2
  59. package/dist/schema/schemaASTDiffer.d.ts +3 -3
  60. package/dist/schema/sqlExpression.d.ts +7 -5
  61. package/dist/schema/sqlExpression.js +20 -16
  62. package/dist/schema/types.d.ts +8 -2
  63. package/dist/sqlite/sqliteDialect.js +1 -2
  64. package/dist/type/definedEntity.d.ts +5 -5
  65. package/dist/type/dialect.d.ts +26 -15
  66. package/dist/type/entity.d.ts +14 -8
  67. package/dist/type/query.d.ts +7 -2
  68. package/dist/type/queryAggregate.d.ts +4 -4
  69. package/dist/type/querySql.d.ts +4 -1
  70. package/dist/type/querySql.js +5 -1
  71. package/dist/type/queryWhere.d.ts +16 -11
  72. package/dist/type/universalQuerier.d.ts +7 -7
  73. package/dist/util/ddlExpression.util.d.ts +5 -0
  74. package/dist/util/ddlExpression.util.js +9 -2
  75. package/dist/util/dialect.util.d.ts +14 -6
  76. package/dist/util/dialect.util.js +17 -13
  77. package/dist/util/field.util.d.ts +12 -0
  78. package/dist/util/field.util.js +17 -1
  79. package/dist/util/fieldOption.util.js +5 -1
  80. package/dist/util/object.util.d.ts +4 -0
  81. package/dist/util/object.util.js +13 -0
  82. package/dist/util/query.util.d.ts +5 -3
  83. package/dist/util/query.util.js +7 -2
  84. package/dist/util/sql.d.ts +25 -7
  85. package/dist/util/sql.js +58 -18
  86. package/dist/util/triggerWrite.d.ts +7 -4
  87. package/dist/util/triggerWrite.js +5 -4
  88. package/package.json +1 -1
  89. package/skills/uql-orm/SKILL.md +27 -19
@@ -1,4 +1,4 @@
1
- import { type ColumnFamily, type SavepointCommand, type DdlRenderOptions, type EntityData, type EntityMeta, type EntityWhereMeta, type FieldKey, type FieldOptions, type IsolationLevel, type TransactionOptions, type JsonColumnType, type JsonArrayUpdateOp, type JsonUpdateOp, type Query, type QueryAggregate, type QueryBuildFn, type QueryComparisonOptions, type QueryConflictPaths, type QueryContext, type QueryContextOptions, type QueryGroupOp, type QueryHavingMap, type QueryRenderOptions, type QueryPage, type QueryPager, QuerySql, type QuerySqlFnOptions, type QuerySearch, type QuerySelectValue, type QuerySizeComparisonOps, type QueryTextSearchOptions, type QueryWhere, type QueryWhereArray, type QueryWhereFieldOp, type QueryWhereOptions, type RelationAggregateSpec, type RelationMeta, type SqlDialectName, type SqlQueryDialect, type SqlValues, type TriggerRows, type TriggerWrite, type AbstractType, type UpdatePayload } from '../type/index.js';
1
+ import { type ColumnFamily, type SavepointCommand, type DdlRenderOptions, type EntityData, type EntityMeta, type EntityWhereMeta, type FieldKey, type FieldOptions, type IsolationLevel, type TransactionOptions, type JsonColumnType, type Query, type QueryAggregate, type QueryBuildFn, type QueryComparisonOptions, type QueryConflictKeys, type QueryUpsert, type QueryContext, type QueryContextOptions, type QueryGroupOp, type QueryHavingMap, type QueryRenderOptions, type QueryPage, type QueryPager, QuerySql, type QuerySqlFnOptions, type QuerySearch, type QuerySelectValue, type QuerySizeComparisonOps, type QueryTextSearchOptions, type QueryWhere, type QueryWhereArray, type QueryWhereFieldOp, type QueryWhereOptions, type RelationAggregateSpec, type RelationMeta, type SqlDialectName, type SqlQueryDialect, type SqlValues, type TriggerRows, type TriggerWrite, type AbstractType, type UpdatePayload, type ReportedWrite } from '../type/index.js';
2
2
  import { type SortDirection } from '../util/index.js';
3
3
  import type { HydrateKind } from './hydrateColumn.js';
4
4
  import { type JsonAccessMode, type JsonContainer, type JsonKeyWrite, type JsonSlot } from './jsonSql.js';
@@ -23,6 +23,11 @@ type SortOrder = Partial<SortDirection>;
23
23
  export type SortRef = SortOrder & {
24
24
  readonly ref: string;
25
25
  };
26
+ /** What a row an upsert finds takes: its `SET` list, empty for none, and the condition it takes it under, or empty. */
27
+ export type ConflictUpdate = {
28
+ readonly assignments: string;
29
+ readonly condition: string;
30
+ };
26
31
  /**
27
32
  * One column of a read's projection: the key its row answers under, none for a raw expression written
28
33
  * without an alias, and whether `sql` already answers under it, being a column of that very name. The rest
@@ -144,13 +149,14 @@ export declare abstract class AbstractSqlDialect extends VectorSqlDialect implem
144
149
  */
145
150
  protected buildFragment(ctx: QueryContext, build: QueryBuildFn): string;
146
151
  /** A `sql()` rendered in place, an operand or a projected term: bound, the driver would get the object. */
147
- protected rawFragment(ctx: QueryContext, value: QuerySql, prefix?: string, entity?: AbstractType<unknown>): string;
152
+ protected rawFragment(ctx: QueryContext, value: QuerySql, scope?: QuerySqlFnOptions): string;
148
153
  /**
149
154
  * Each operand rendered on its own, keeping those that emitted SQL: an empty one leaves no dangling
150
155
  * separator, and the count of what emitted decides the parentheses.
151
156
  */
152
157
  protected renderOperands<T>(ctx: QueryContext, operands: readonly T[], render: (ctx: QueryContext, operand: T) => void): string[];
153
- addValue(ctx: QueryContext, value: unknown): string;
158
+ /** `value` bound, or SQL rendered where it stands, in `scope` where a field is compared with it, so a ref names its column as the field is named. */
159
+ addValue(ctx: QueryContext, value: unknown, scope?: QuerySqlFnOptions): string;
154
160
  /** When set, a `Date` binds as UTC text with this zone suffix (`''` for none). Unset, the driver gets the `Date`. */
155
161
  protected readonly dateZone?: string;
156
162
  /**
@@ -163,13 +169,20 @@ export declare abstract class AbstractSqlDialect extends VectorSqlDialect implem
163
169
  /** `RETURNING <id column>` as {@link RETURNED_ID}, or nothing on a composite key, whose every column the payload already names. */
164
170
  returningId<E>(meta: EntityMeta<E>): string;
165
171
  /**
166
- * ` RETURNING` the fields `keys` names, after an `UPDATE` or `DELETE` this context holds, projected and read as
167
- * a read's are: the terms its rows answer under. Only where `features.writeReturning`.
172
+ * Whether a `write` of `meta`'s rows reports them as written: where the engine's `write` reports rows, and no trigger
173
+ * or stamp can change the row after it, on an engine whose trigger cannot assign to its row.
174
+ */
175
+ reportsWrite<E>(meta: EntityMeta<E>, write: ReportedWrite): boolean;
176
+ /**
177
+ * The `write` `render` appends, reporting the fields `returning` names of each row it writes, projected and read
178
+ * as a read's are: the terms its rows answer under, none where it names none. `render` takes what goes between the
179
+ * target and its rows; here nothing, as a ` RETURNING` follows the write. Refused where the engine's `write`
180
+ * reports no rows, which `features.reportsWrites` says.
168
181
  */
169
- returning<E>(ctx: QueryContext, entity: AbstractType<E>, keys: readonly FieldKey<E>[]): readonly SelectTerm[];
182
+ protected reportedWrite<E>(ctx: QueryContext, entity: AbstractType<E>, returning: readonly FieldKey<E>[] | undefined, write: ReportedWrite, render: (afterTarget: string) => void): readonly SelectTerm[];
170
183
  /** What the returned row is read off, for an engine that names it: SQL Server's `INSERTED.`. */
171
184
  protected readonly returnedRowPrefix: string;
172
- /** `<id column> AS` {@link RETURNED_ID} on its own, for a statement composing a `RETURNING` list of several items. */
185
+ /** `<id column> AS` {@link RETURNED_ID}, as a clause reporting an insert's id lists it. */
173
186
  protected returningIdExpression<E>(meta: EntityMeta<E>): string;
174
187
  search<E>(ctx: QueryContext, entity: AbstractType<E>, q?: Query<E>, opts?: ReadOptions, joins?: QueryJoins, order?: readonly SortRef[]): void;
175
188
  /**
@@ -227,7 +240,7 @@ export declare abstract class AbstractSqlDialect extends VectorSqlDialect implem
227
240
  */
228
241
  protected projection<E>(ctx: QueryContext, entity: AbstractType<E>, q: Query<E>, opts: SelectOptions, joins: QueryJoins): SelectTerm[];
229
242
  /** A projection's list of terms. */
230
- private termsSql;
243
+ protected termsSql(terms: readonly SelectTerm[]): string;
231
244
  /** A term as a projection writes it, aliased unless its SQL already answers under its key. */
232
245
  private termSql;
233
246
  /** What a `$sort` projects, each under the name it asked for: a vector's distance, the `$text` relevance. */
@@ -248,7 +261,7 @@ export declare abstract class AbstractSqlDialect extends VectorSqlDialect implem
248
261
  * in front of the name, or the read takes an alias of its own. See {@link resolveTableAlias} for why
249
262
  * the prefix cannot be the qualified path.
250
263
  */
251
- protected tableRef<E>(meta: EntityMeta<E>, alias?: string): {
264
+ tableRef<E>(meta: EntityMeta<E>, alias?: string): {
252
265
  alias: string;
253
266
  ref: string;
254
267
  };
@@ -278,6 +291,8 @@ export declare abstract class AbstractSqlDialect extends VectorSqlDialect implem
278
291
  * compared against.
279
292
  */
280
293
  protected likeCondition(ctx: QueryContext, operand: string, op: QueryWhereFieldOp, val: unknown): string | undefined;
294
+ /** What a column is read off: the qualifier already escaped, else the alias in scope escaped with its dot. */
295
+ private qualifierOf;
281
296
  /** Builds `prefix.column` from an already-resolved field, through the same memo writes use. */
282
297
  private columnWithPrefix;
283
298
  /**
@@ -312,8 +327,13 @@ export declare abstract class AbstractSqlDialect extends VectorSqlDialect implem
312
327
  /** Every operator `target` is compared with, `AND`-joined. */
313
328
  private jsonConditions;
314
329
  private jsonCondition;
315
- /** A bound operand of a JSON comparison, read the way `mode` reads the value it is compared with. */
330
+ /**
331
+ * An operand of a JSON comparison, read the way `mode` reads the path it is compared with. SQL in `json` mode
332
+ * is a boolean column's ref, which no engine casts to JSON alike, so its value picks the JSON literal.
333
+ */
316
334
  private jsonOperand;
335
+ /** A column compared with a JSON path's text, as it compares: as it is, where the engine converts it. */
336
+ protected textOperand(column: string): string;
317
337
  /** The JSON value at `slot`, as an array operator reads it. */
318
338
  protected jsonValue(slot: JsonSlot): string;
319
339
  /**
@@ -355,7 +375,7 @@ export declare abstract class AbstractSqlDialect extends VectorSqlDialect implem
355
375
  * itself. An element equal to one value, or to one of several, is containment whatever the operator
356
376
  * says, which compares by JSON type and is what an array index serves.
357
377
  */
358
- protected jsonElemMatch(ctx: QueryContext, slot: JsonSlot, match: Record<string, unknown>): string;
378
+ protected jsonElemMatch(ctx: QueryContext, slot: JsonSlot, match: Record<string, unknown>, scope: QuerySqlFnOptions): string;
359
379
  /** The optimizer hint a `$elemMatch` subquery opens with, where the engine plans one wrong without it. */
360
380
  protected readonly jsonElemHint: string;
361
381
  /**
@@ -363,8 +383,6 @@ export declare abstract class AbstractSqlDialect extends VectorSqlDialect implem
363
383
  * dialects use this - PostgreSQL binds JSON through {@link PgLikeSqlDialect.jsonScalarParam} instead.
364
384
  */
365
385
  protected jsonScalarParam(ctx: QueryContext, value: unknown): string;
366
- /** {@link resolveOperandField}, appended. */
367
- getComparisonKey<E>(ctx: QueryContext, entity: AbstractType<E>, key: FieldKey<E>, opts?: QueryRenderOptions): void;
368
386
  /** Appends the `ORDER BY`, reporting whether there was one - which {@link pager} needs on the
369
387
  * engines that refuse to page an unordered statement. */
370
388
  sort<E>(ctx: QueryContext, entity: AbstractType<E>, q: Query<E>, opts?: QuerySortOptions): boolean;
@@ -475,11 +493,15 @@ export declare abstract class AbstractSqlDialect extends VectorSqlDialect implem
475
493
  */
476
494
  private readOptions;
477
495
  /**
478
- * The clause that returns the written ids, shared by every insert and upsert. It is `''` on an engine whose
496
+ * The clause that returns an insert's ids. It is `''` on an engine whose
479
497
  * statement cannot return them, and on a composite key, which has no id to ask for.
480
498
  */
481
499
  protected insertedIdReturning<E>(meta: EntityMeta<E>): string;
482
- insert<E>(ctx: QueryContext, entity: AbstractType<E>, payload: E | E[], opts?: QueryRenderOptions): void;
500
+ /**
501
+ * An insert of `payload` reporting each row's id, or the fields `returning` names, as its write reports
502
+ * them: the terms it answers under, none for the id alone.
503
+ */
504
+ insert<E>(ctx: QueryContext, entity: AbstractType<E>, payload: E | E[], returning?: readonly FieldKey<E>[]): readonly SelectTerm[];
483
505
  /**
484
506
  * What a text search matches and a fulltext index covers, which have to agree for the index to serve the
485
507
  * search: the columns themselves, where the engine indexes them as they are (MySQL's `MATCH (a, b)`).
@@ -506,8 +528,8 @@ export declare abstract class AbstractSqlDialect extends VectorSqlDialect implem
506
528
  * it does not support the `DEFAULT` keyword inside `VALUES`.
507
529
  */
508
530
  protected appendDefaultInsertValue(ctx: QueryContext, _field: FieldOptions | undefined): void;
509
- update<E>(ctx: QueryContext, entity: AbstractType<E>, q: QuerySearch<E>, payload: UpdatePayload<E>, opts?: QueryRenderOptions): void;
510
- /** What an update assigns: the payload's fields, `onUpdate` fills included. */
531
+ update<E>(ctx: QueryContext, entity: AbstractType<E>, q: QuerySearch<E>, payload: UpdatePayload<E>, opts?: QueryRenderOptions, returning?: readonly FieldKey<E>[]): readonly SelectTerm[];
532
+ /** What an update assigns: the payload's fields, the `onUpdate` fills `scope` can write included. */
511
533
  private updateEntries;
512
534
  /**
513
535
  * A `SET` list, each assignment reading its column as `qualifier` names it, which an upsert sets: `MERGE`'s
@@ -516,9 +538,12 @@ export declare abstract class AbstractSqlDialect extends VectorSqlDialect implem
516
538
  private appendAssignments;
517
539
  /**
518
540
  * `col = value`, a JSON operator or a `$inc`/`$mul` spelled as the engine's. What reads the table, the operators
519
- * and the refs in SQL alike, reads it through `qualifier`.
541
+ * and the refs in SQL alike, reads it through `qualifier`. With a `guard`, the column takes the value only where
542
+ * that condition holds, and keeps its own elsewhere.
520
543
  */
521
544
  private appendAssignment;
545
+ /** What {@link appendAssignment} sets its column to. */
546
+ private appendAssignedValue;
522
547
  /**
523
548
  * A write in a trigger's body. Only the columns it names, none filled in JavaScript - that would bake
524
549
  * one value into the trigger - no id read back, and no entity filter, which a request resolves and a
@@ -531,51 +556,67 @@ export declare abstract class AbstractSqlDialect extends VectorSqlDialect implem
531
556
  protected appendTriggerInsert<E>(ctx: QueryContext, meta: EntityMeta<E>, entries: readonly [string, unknown][], rows?: TriggerRows): void;
532
557
  /** The values a trigger writes, a literal or SQL each, the rows' refs most often. */
533
558
  protected appendTriggerValues<E>(ctx: QueryContext, meta: EntityMeta<E>, entries: readonly [string, unknown][]): void;
534
- /** A trigger's upsert: its insert, then what a conflicting row takes, `assignments`, or nothing where empty. */
535
- protected appendTriggerUpsert<E>(ctx: QueryContext, meta: EntityMeta<E>, conflictPaths: QueryConflictPaths<E>, entries: readonly [string, unknown][], assignments: string, rows?: TriggerRows): void;
536
- /** ` ON CONFLICT (keys) DO UPDATE SET ...`, or `DO NOTHING` with nothing to assign. */
559
+ /** A trigger's upsert: its insert, then what a conflicting row takes, `found`, or nothing where it assigns none. */
560
+ protected appendTriggerUpsert<E>(ctx: QueryContext, meta: EntityMeta<E>, conflictKeys: QueryConflictKeys<E>, entries: readonly [string, unknown][], found: ConflictUpdate, rows?: TriggerRows): void;
561
+ /** ` ON CONFLICT (keys) DO UPDATE SET ... WHERE ...`, or `DO NOTHING` with nothing to assign. */
537
562
  private onConflict;
538
563
  /**
539
564
  * The statement failing a trigger's write with `message`, a quoted literal: SQL/PSM's `SIGNAL`, which the
540
565
  * MySQL family speaks. `rows` are what a set-based engine's body reads, where it fails only if there are any.
541
566
  */
542
567
  protected refusal(message: string, _rows?: TriggerRows): string;
568
+ /** What a trigger's update assigns: the values it names, and the `onUpdate` fills a trigger can write, a value or SQL. */
569
+ private triggerUpdateEntries;
543
570
  /** The values a write names, refusing one the entity has no column for. */
544
571
  private writtenEntries;
545
572
  /**
546
- * `INSERT ... ON CONFLICT ... DO UPDATE/NOTHING RETURNING`. The assignments are built before the insert
547
- * fills `onInsert` columns, which must stay out of them, and their values bound after it, where a `?` reads them.
573
+ * `INSERT ... ON CONFLICT ... DO UPDATE/NOTHING RETURNING`, the id, or the fields `returning` names as
574
+ * {@link insert} reports them. What a found row takes is read before the insert fills `onInsert` columns, which must
575
+ * stay out of it, and written after the rows, in the order the statement reads its values.
548
576
  */
549
- upsert<E>(ctx: QueryContext, entity: AbstractType<E>, conflictPaths: QueryConflictPaths<E>, payload: E | E[], update?: UpdatePayload<E>): void;
577
+ upsert<E>(ctx: QueryContext, entity: AbstractType<E>, q: QueryUpsert<E>, payload: E | E[], update?: UpdatePayload<E>, returning?: readonly FieldKey<E>[]): readonly SelectTerm[];
550
578
  /**
551
579
  * What an upsert of rows shaped as `row` assigns a row it finds: the values its assignments bind once per
552
580
  * statement beside its rows, and whether there are any, where none is `DO NOTHING`, which skips that row.
553
581
  */
554
- upsertAssignments<E>(entity: AbstractType<E>, conflictPaths: QueryConflictPaths<E>, row: E, update?: UpdatePayload<E>): {
582
+ upsertAssignments<E>(entity: AbstractType<E>, q: QueryUpsert<E>, row: E, update?: UpdatePayload<E>): {
555
583
  readonly binds: number;
556
584
  readonly assigns: boolean;
557
585
  };
558
586
  /**
559
- * Whether an upsert of `rows` rows that assigns a found row something reports each row's sole key in order, so
560
- * nothing reads them back: `RETURNING`, in order on an engine answering so, and for one row on any; the header,
561
- * for one row's generated key, a found row's too, since the upsert assigns it through `LAST_INSERT_ID`.
587
+ * What a row an upsert finds takes: `update` where given, else the incoming row less the conflict keys, and what
588
+ * `onUpdate` fills, under `q.$where`. An empty `update` leaves the row as it is, its fills included.
589
+ */
590
+ protected conflictUpdate<E>(ctx: QueryContext, entity: AbstractType<E>, q: QueryUpsert<E>, payload: E | E[], update?: UpdatePayload<E>): ConflictUpdate;
591
+ /** The columns a row an upsert finds takes, read off the payload before the insert fills it. */
592
+ protected conflictEntries<E>(entity: AbstractType<E>, q: QueryUpsert<E>, payload: E | E[], update?: UpdatePayload<E>): [string, unknown][];
593
+ /**
594
+ * What a row an upsert of `row` finds takes, {@link foundRowAssigned}, with the `onUpdate` fills: by default, each
595
+ * payload column as the incoming row has it, and no fill of what it matched on. In a trigger, an update as written
596
+ * and the fills a trigger can write.
597
+ */
598
+ private foundRowEntries;
599
+ /**
600
+ * `entries` as a row an upsert finds takes them: its `SET` list, empty for none, and the condition it takes it
601
+ * under, `where` read off that row through the table's name, empty where it always does.
602
+ */
603
+ protected foundRowUpdate<E>(ctx: QueryContext, entity: AbstractType<E>, entries: readonly [string, unknown][], where: QueryWhere<E> | undefined): ConflictUpdate;
604
+ /** `entries` as the `SET` list of a row an upsert finds, each read through the table's name, under `guard` if any. */
605
+ protected foundRowAssignments<E>(ctx: QueryContext, entity: AbstractType<E>, entries: readonly [string, unknown][], guard?: QueryBuildFn): string;
606
+ /** `where` as the row an upsert found holds it, its columns read through the table's name. */
607
+ protected foundRowCondition<E>(ctx: QueryContext, entity: AbstractType<E>, where: QueryWhere<E>): void;
608
+ /**
609
+ * Whether an upsert of `rows` rows that assigns a found row something names its row's generated key in the header,
610
+ * a found row's too, since the upsert assigns it through `LAST_INSERT_ID`: one row's only. An engine with
611
+ * `RETURNING` reports its keys there instead.
562
612
  */
563
613
  upsertReportsIds<E>(meta: EntityMeta<E>, rows: number): boolean;
564
- /** Whether the upsert's assignments bind straight into the statement, as numbered `$n` placeholders can. */
565
- protected readonly upsertUpdateBindsInPlace: boolean;
566
614
  /** How an upsert's assignment reads `column` of the row that was being inserted. */
567
615
  protected upsertIncoming(column: string): string;
568
616
  /** `key`'s column of the row being inserted, as SQL an assignment takes. */
569
617
  private incoming;
570
- /**
571
- * What a conflicting row takes: `update` where given, else the incoming row less the conflict paths, and what
572
- * `onUpdate` fills. An empty `update` leaves the row as it is, its fills included: nothing to assign.
573
- */
574
- protected getUpsertUpdateAssignments<E>(ctx: QueryContext, meta: EntityMeta<E>, conflictPaths: QueryConflictPaths<E>, payload: E | E[], update?: UpdatePayload<E>): string;
575
- /** What a found row takes by default: each payload column as the incoming row has it, and the `onUpdate` fills. */
576
- private conflictEntries;
577
- protected getUpsertConflictPathsStr<E>(meta: EntityMeta<E>, conflictPaths: QueryConflictPaths<E>): string;
578
- delete<E>(ctx: QueryContext, entity: AbstractType<E>, q: QuerySearch<E>, opts?: QueryRenderOptions): void;
618
+ protected conflictKeysSql<E>(meta: EntityMeta<E>, conflictKeys: QueryConflictKeys<E>): string;
619
+ delete<E>(ctx: QueryContext, entity: AbstractType<E>, q: QuerySearch<E>, opts?: QueryRenderOptions, returning?: readonly FieldKey<E>[]): readonly SelectTerm[];
579
620
  escapeId(val: string | undefined, forbidQualified?: boolean, addDot?: boolean): string;
580
621
  /**
581
622
  * A name behind its schema, each part escaped on its own rather than as one dotted string taken
@@ -625,10 +666,10 @@ export declare abstract class AbstractSqlDialect extends VectorSqlDialect implem
625
666
  */
626
667
  protected jsonCast(operand: string): string;
627
668
  /**
628
- * `"col" = <expr>` for a JSON update, folded to one write per path, on an empty document in place of a NULL
629
- * column where one writes a key. Each write reads `current`, the column as stored.
669
+ * A JSON update's expression, folded to one write per path, on an empty document in place of a NULL column
670
+ * where one writes a key. Each write reads `current`, the column as stored.
630
671
  */
631
- protected formatJsonUpdate(ctx: QueryContext, escapedCol: string, value: JsonUpdateOp | JsonArrayUpdateOp, field?: FieldOptions, current?: string): void;
672
+ private jsonUpdate;
632
673
  /**
633
674
  * The array at `slot` as `write` leaves it, or NULL where a value that is no array stays: its pulls, then each
634
675
  * append onto `[]` in place of a missing or null array, a `unique` one only where the stored array lacks its item.
@@ -679,7 +720,7 @@ export declare abstract class AbstractSqlDialect extends VectorSqlDialect implem
679
720
  value: QuerySql;
680
721
  }): void;
681
722
  /** A `column.path` key of `meta`'s JSON field as the path it names, shared by `where` and `sort`; else `undefined`. */
682
- protected resolveJsonDotPath<E>(meta: EntityMeta<E>, key: string, prefix?: string): JsonSlot | undefined;
723
+ protected resolveJsonDotPath<E>(meta: EntityMeta<E>, key: string, opts: Pick<QueryRenderOptions, 'prefix' | 'escapedPrefix'>): JsonSlot | undefined;
683
724
  /**
684
725
  * One JSON path, read the way `mode` asks for: the one place the three readings are chosen between,
685
726
  * so `$where`, `$sort` and every operator reach a path the same way. Public because a JSON index