uql-orm 0.101.5 → 0.101.6

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.
@@ -50,7 +50,7 @@ class AlterTableOperations {
50
50
  this.operations.push({
51
51
  type: 'createIndex',
52
52
  tableName: this.tableName,
53
- index: indexDefinition(this.tableName, columns, options),
53
+ index: indexDefinition(columns, options),
54
54
  });
55
55
  return this;
56
56
  }
@@ -4,6 +4,7 @@
4
4
  * Fluent API for defining tables in migrations.
5
5
  */
6
6
  import { DATE_PRECISION } from '../../util/date.js';
7
+ import { declaredIndexName } from '../../util/ddlExpression.util.js';
7
8
  import { currentTimestamp } from '../../util/sql.js';
8
9
  import { columnForeignKey, columnIndex, indexDefinition } from '../generator/definitionToNode.js';
9
10
  import { ColumnDefinitionBuilder } from './columnBuilder.js';
@@ -158,11 +159,11 @@ export class TableDefinitionBuilder {
158
159
  return this;
159
160
  }
160
161
  unique(columns, options) {
161
- this._indexes.push(indexDefinition(this._name, columns, { ...namedOptions(options), unique: true }, true));
162
+ this._indexes.push(indexDefinition(columns, { ...namedOptions(options), unique: true }, true));
162
163
  return this;
163
164
  }
164
165
  index(columns, options) {
165
- this._indexes.push(indexDefinition(this._name, columns, namedOptions(options)));
166
+ this._indexes.push(indexDefinition(columns, namedOptions(options)));
166
167
  return this;
167
168
  }
168
169
  foreignKey(columns) {
@@ -180,11 +181,15 @@ export class TableDefinitionBuilder {
180
181
  build() {
181
182
  // Build all columns from builders
182
183
  const columns = this._columnBuilders.map((cb) => cb.build());
183
- // Collect column-level indexes, skipping any a table-level one already names.
184
+ // Collect column-level indexes, skipping one a table-level index already names.
185
+ const taken = new Set(this._indexes
186
+ .filter((idx) => idx.where === undefined)
187
+ .map((idx) => declaredIndexName(idx.name, this._name, idx.entries, { unique: idx.uniqueName })));
184
188
  for (const col of columns) {
185
189
  const index = columnIndex(this._name, col);
186
- if (index && !this._indexes.some((idx) => idx.name === index.name)) {
190
+ if (index && !taken.has(index.name)) {
187
191
  this._indexes.push(index);
192
+ taken.add(index.name);
188
193
  }
189
194
  }
190
195
  // Build foreign keys
@@ -90,9 +90,13 @@ export interface FullColumnDefinition extends ColumnDefinition {
90
90
  * An index as the builder records it, with the entries and options `@Index` takes: its SQL kept as `raw`
91
91
  * until a generator renders it for the engine the migration runs on.
92
92
  */
93
- export type IndexDefinition = Except<IndexSchema, 'entries' | 'where'> & {
93
+ export type IndexDefinition = Except<IndexSchema, 'name' | 'entries' | 'where'> & {
94
+ /** As declared; an unnamed index is named when it is rendered, from its predicate as written. */
95
+ readonly name?: string;
94
96
  readonly entries: readonly EntityIndexColumn[];
95
97
  readonly where?: QuerySql;
98
+ /** Whether an unnamed index takes the `_uk` kind. Only `table.unique` sets it: earlier migrations installed `_uk` there, so `index` keeps `_idx`. */
99
+ readonly uniqueName?: boolean;
96
100
  };
97
101
  /**
98
102
  * Complete table definition.
@@ -21,10 +21,13 @@ export declare function columnIndex(tableName: string, col: FullColumnDefinition
21
21
  /**
22
22
  * The index that `table.index`, `table.unique` and `createIndex` record. Its entries are normalized, since
23
23
  * an entry left as written reaches the generator as a column named `[object Object]`. An unnamed index is
24
- * named after its entries, with `_uk` only for `table.unique`, so names earlier migrations installed stay.
24
+ * named when rendered, with `_uk` only for `table.unique`, so names earlier migrations installed stay.
25
25
  */
26
- export declare function indexDefinition(tableName: string, columns: readonly IndexColumnInput[], { name, unique, ...options }?: IndexOptions, uniqueName?: boolean): IndexDefinition;
27
- /** An index the builder recorded, its SQL rendered by `render` into the text the schema holds. */
28
- export declare function renderIndexDefinition(index: IndexDefinition, render: (sql: QuerySql) => string): IndexSchema;
26
+ export declare function indexDefinition(columns: readonly IndexColumnInput[], { name, unique, ...options }?: IndexOptions, uniqueName?: boolean): IndexDefinition;
27
+ /**
28
+ * An index the builder recorded, its SQL rendered by `render` into the text the schema holds, and named
29
+ * from that text the way an entity's is.
30
+ */
31
+ export declare function renderIndexDefinition(table: string, { uniqueName, ...index }: IndexDefinition, render: (sql: QuerySql) => string): IndexSchema;
29
32
  /** The foreign key a column-level `references` declares, or nothing. Shared for the same reason. */
30
33
  export declare function columnForeignKey(col: FullColumnDefinition): ForeignKeySchema | undefined;
@@ -24,7 +24,7 @@ export function tableDefinitionToNode(def, render) {
24
24
  ? { columns: def.primaryKey.filter((name) => columns.has(name)) }
25
25
  : keyOfColumns(columns.values());
26
26
  for (const idxDef of def.indexes) {
27
- table.indexes.push({ ...renderIndexDefinition(idxDef, render), table });
27
+ table.indexes.push({ ...renderIndexDefinition(name, idxDef, render), table });
28
28
  }
29
29
  return table;
30
30
  }
@@ -51,23 +51,22 @@ export function columnIndex(tableName, col) {
51
51
  /**
52
52
  * The index that `table.index`, `table.unique` and `createIndex` record. Its entries are normalized, since
53
53
  * an entry left as written reaches the generator as a column named `[object Object]`. An unnamed index is
54
- * named after its entries, with `_uk` only for `table.unique`, so names earlier migrations installed stay.
54
+ * named when rendered, with `_uk` only for `table.unique`, so names earlier migrations installed stay.
55
55
  */
56
- export function indexDefinition(tableName, columns, { name, unique = false, ...options } = {}, uniqueName = false) {
57
- const entries = columns.map(normalizeIndexColumn);
58
- return {
59
- ...options,
60
- name: declaredIndexName(name, tableName, entries, uniqueName),
61
- entries,
62
- unique,
63
- };
56
+ export function indexDefinition(columns, { name, unique = false, ...options } = {}, uniqueName = false) {
57
+ return { ...options, name, entries: columns.map(normalizeIndexColumn), unique, uniqueName };
64
58
  }
65
- /** An index the builder recorded, its SQL rendered by `render` into the text the schema holds. */
66
- export function renderIndexDefinition(index, render) {
59
+ /**
60
+ * An index the builder recorded, its SQL rendered by `render` into the text the schema holds, and named
61
+ * from that text the way an entity's is.
62
+ */
63
+ export function renderIndexDefinition(table, { uniqueName, ...index }, render) {
64
+ const where = index.where && render(index.where);
67
65
  return {
68
66
  ...index,
67
+ name: declaredIndexName(index.name, table, index.entries, { unique: uniqueName, where }),
68
+ where,
69
69
  entries: index.entries.map((entry) => renderIndexColumn(entry, render)),
70
- where: index.where && render(index.where),
71
70
  };
72
71
  }
73
72
  /** The foreign key a column-level `references` declares, or nothing. Shared for the same reason. */
@@ -397,7 +397,7 @@ export class SqlSchemaGenerator {
397
397
  return this.tableDdl.alterColumns(operation.tableName, [{ to: this.definitionColumn(operation.changes) }]);
398
398
  case 'createIndex':
399
399
  return this.addIndexStatements(operation.tableName, [
400
- renderIndexDefinition(operation.index, (sql) => this.dialect.compileDdl(sql)),
400
+ renderIndexDefinition(operation.tableName, operation.index, (sql) => this.dialect.compileDdl(sql)),
401
401
  ]);
402
402
  case 'dropIndex':
403
403
  return [this.tableDdl.dropIndex(operation.tableName, operation.indexName)];
@@ -41,9 +41,10 @@ export class MongoSchemaIntrospector {
41
41
  columns: [],
42
42
  ...(validator && { checks: [validatorCheck(tableName, validator)] }),
43
43
  indexes: [
44
- ...indexes.map(({ name, key, unique, weights, default_language }) => ({
44
+ ...indexes.map(({ name, key, unique, weights, default_language, partialFilterExpression }) => ({
45
45
  name,
46
46
  unique: !!unique,
47
+ ...(partialFilterExpression && { where: JSON.stringify(partialFilterExpression) }),
47
48
  ...(weights
48
49
  ? {
49
50
  entries: Object.entries(weights).map(textIndexEntry),
@@ -99,7 +100,7 @@ async function hasCollection(db, name) {
99
100
  const collections = await db.listCollections({ name, type: 'collection' }, { nameOnly: true }).toArray();
100
101
  return collections.length > 0;
101
102
  }
102
- /** `listIndexes` reports keys, uniqueness and text weights; a `partialFilterExpression` is no SQL predicate. */
103
+ /** `listIndexes` keeps a text index's fields in no declared order, so they are compared as a set. */
103
104
  const INDEX_FACETS = new Set(['textIndex']);
104
105
  /**
105
106
  * Mongo has no columns to read, so a table's are the fields its indexes name, one node per field. Its
@@ -64,15 +64,15 @@ export class MongoSchemaGenerator extends MongoDialect {
64
64
  .map((entry) => ({ ...entry, column: this.columnOf(meta, entry.column) }));
65
65
  const [first] = columns;
66
66
  const vector = options.type === 'vectorSearch' && typeof first?.column === 'string' ? meta.fields[first.column] : undefined;
67
- const name = vector
68
- ? this.vectorSearchIndexName(options.name, entries[0].column)
69
- : declaredIndexName(options.name, collectionName, entries);
67
+ const predicate = where && this.indexFilter(where, meta.entity, declaredIndexName(options.name, collectionName, entries));
70
68
  return {
71
69
  ...options,
72
- name,
70
+ name: vector
71
+ ? this.vectorSearchIndexName(options.name, entries[0].column)
72
+ : declaredIndexName(options.name, collectionName, entries, { where: predicate }),
73
73
  entries,
74
74
  unique: options.unique ?? false,
75
- where: where && this.indexFilter(where, meta.entity, name),
75
+ where: predicate,
76
76
  distance: options.distance ?? vector?.distance,
77
77
  dimensions: vector?.dimensions,
78
78
  };
@@ -192,21 +192,21 @@ export class MongoSchemaGenerator extends MongoDialect {
192
192
  }
193
193
  /** A collection and its indexes, which is all a document store has: a column, a constraint or SQL throws. */
194
194
  generateOperation(operation) {
195
- const render = (index) => renderIndexDefinition(index, refuseSql);
195
+ const render = (table, index) => renderIndexDefinition(table, index, refuseSql);
196
196
  switch (operation.type) {
197
197
  case 'createTable': {
198
198
  const { name, columns, indexes } = operation.table;
199
199
  if (columns.length) {
200
200
  throw new UqlUsageError(`mongodb does not support columns in a migration (collection "${name}")`);
201
201
  }
202
- return this.createCollection(name, indexes.map(render));
202
+ return this.createCollection(name, indexes.map((index) => render(name, index)));
203
203
  }
204
204
  case 'dropTable':
205
205
  return [serializeMongoCommand({ action: 'dropCollection', name: operation.tableName })];
206
206
  case 'renameTable':
207
207
  return [serializeMongoCommand({ action: 'renameCollection', from: operation.oldName, to: operation.newName })];
208
208
  case 'createIndex':
209
- return [this.generateCreateIndex(operation.tableName, render(operation.index))];
209
+ return [this.generateCreateIndex(operation.tableName, render(operation.tableName, operation.index))];
210
210
  case 'dropIndex':
211
211
  return [dropIndex(operation.tableName, operation.indexName)];
212
212
  default:
@@ -7,7 +7,7 @@ import type { IndexNode } from './types.js';
7
7
  * `textIndex` is a text index's weights and language, kept by an engine that lists its fields in no declared order.
8
8
  */
9
9
  export type IndexFacet = 'order' | 'nulls' | 'opsClass' | 'accessMethod' | 'include' | 'vector' | 'distance' | 'textIndex';
10
- type ComparableIndex = Pick<IndexNode, 'name' | 'entries' | 'unique'>;
10
+ type ComparableIndex = Pick<IndexNode, 'name' | 'entries' | 'unique' | 'where'>;
11
11
  /**
12
12
  * Whether the table has this index already, by shape rather than name, uniqueness included. An index
13
13
  * over an expression, whose text the engine reprints, falls back to its name.
@@ -20,7 +20,7 @@ export declare function indexSignature(index: ComparableIndex): string;
20
20
  export declare function indexNameStem(name: string): string;
21
21
  /**
22
22
  * Pairs by name, then what is left by shape: an index the database has under another name is still
23
- * the one asked for. What stays unpaired is created or dropped.
23
+ * the one asked for. A partial index pairs by name alone, since its predicate is in its name.
24
24
  */
25
25
  export declare function pairIndexes<S extends ComparableIndex, T extends ComparableIndex>(source: readonly S[], target: readonly T[]): {
26
26
  created: S[];
@@ -49,8 +49,9 @@ export declare function indexChanges<I extends IndexSchema>(table: string, decla
49
49
  kept: IndexNode[];
50
50
  };
51
51
  /**
52
- * What two indexes differ by, comparing only what both sides state structurally: an expression, a JSON
53
- * path or a predicate is reprinted by the engine, so never compared.
52
+ * What two indexes differ by, comparing only what both sides state structurally. An expression or a JSON
53
+ * path is reprinted by the engine, so never compared; a predicate only by whether there is one, its text
54
+ * being in an unnamed index's name.
54
55
  */
55
56
  export declare function describeIndexDifferences(source: IndexSchema, target: IndexSchema, facets: ReadonlySet<IndexFacet>): string[];
56
57
  export {};
@@ -1,6 +1,6 @@
1
1
  import { indexDistance, isVectorIndexType } from '../type/vector.js';
2
2
  import { fulltextConfig } from '../util/dialect.util.js';
3
- import { derivedIndexName } from '../util/sql.util.js';
3
+ import { isDerivedIndexName } from '../util/sql.util.js';
4
4
  import { isColumnEntry } from './indexColumns.js';
5
5
  import { matchByKey } from './matchByKey.js';
6
6
  /**
@@ -25,12 +25,24 @@ export function indexNameStem(name) {
25
25
  }
26
26
  /**
27
27
  * Pairs by name, then what is left by shape: an index the database has under another name is still
28
- * the one asked for. What stays unpaired is created or dropped.
28
+ * the one asked for. A partial index pairs by name alone, since its predicate is in its name.
29
29
  */
30
30
  export function pairIndexes(source, target) {
31
31
  const byName = matchByKey(source, target, (index) => indexNameStem(index.name));
32
- const byShape = matchByKey(byName.created, byName.dropped, indexSignature);
33
- return { created: byShape.created, dropped: byShape.dropped, matched: [...byName.matched, ...byShape.matched] };
32
+ const created = splitPartial(byName.created);
33
+ const dropped = splitPartial(byName.dropped);
34
+ const byShape = matchByKey(created.plain, dropped.plain, indexSignature);
35
+ return {
36
+ created: [...created.partial, ...byShape.created],
37
+ dropped: [...dropped.partial, ...byShape.dropped],
38
+ matched: [...byName.matched, ...byShape.matched],
39
+ };
40
+ }
41
+ function splitPartial(indexes) {
42
+ return {
43
+ plain: indexes.filter((index) => index.where === undefined),
44
+ partial: indexes.filter((index) => index.where !== undefined),
45
+ };
34
46
  }
35
47
  /**
36
48
  * The indexes a table lacks, the ones it no longer needs, and the ones to rebuild, differing in what
@@ -56,12 +68,7 @@ export function indexChanges(table, declared, current, facets) {
56
68
  */
57
69
  function hasDerivedName(table, index) {
58
70
  const parts = index.entries.map((entry, at) => (isColumnEntry(entry) ? entry.column : `expr${at}`));
59
- const derived = [
60
- derivedIndexName(table, parts),
61
- derivedIndexName(table, parts, true),
62
- `idx_${table}_${parts.join('_')}`,
63
- ];
64
- return derived.includes(index.name);
71
+ return isDerivedIndexName(table, parts, index.name);
65
72
  }
66
73
  /** What this version emits. */
67
74
  const KIND_SUFFIX = /_(?:idx|fk|ck|pk|uk|uq)$/i;
@@ -72,8 +79,9 @@ const KIND_SUFFIX = /_(?:idx|fk|ck|pk|uk|uq)$/i;
72
79
  */
73
80
  const KIND_PREFIX = /^(?:idx|fk|ck|pk|uk|uq)_/i;
74
81
  /**
75
- * What two indexes differ by, comparing only what both sides state structurally: an expression, a JSON
76
- * path or a predicate is reprinted by the engine, so never compared.
82
+ * What two indexes differ by, comparing only what both sides state structurally. An expression or a JSON
83
+ * path is reprinted by the engine, so never compared; a predicate only by whether there is one, its text
84
+ * being in an unnamed index's name.
77
85
  */
78
86
  export function describeIndexDifferences(source, target, facets) {
79
87
  const differences = [];
@@ -90,6 +98,9 @@ export function describeIndexDifferences(source, target, facets) {
90
98
  differences.push(`config: ${actual} -> ${expected}`);
91
99
  }
92
100
  }
101
+ if ((source.where === undefined) !== (target.where === undefined)) {
102
+ differences.push(`predicate: ${target.where ?? 'none'} -> ${source.where ?? 'none'}`);
103
+ }
93
104
  if (source.unique !== target.unique) {
94
105
  differences.push(`unique: ${target.unique} -> ${source.unique}`);
95
106
  }
@@ -184,16 +184,16 @@ function addCompositeIndex(ctx, table, meta, { columns, include, where, ...optio
184
184
  });
185
185
  if (!resolved.length)
186
186
  return;
187
- const name = declaredIndexName(options.name, table.name, resolved);
187
+ const predicate = where && ctx.compileIndexPredicate(where, meta.entity, declaredIndexName(options.name, table.name, resolved));
188
188
  ctx.ast.addIndex({
189
189
  ...options,
190
- name,
190
+ name: declaredIndexName(options.name, table.name, resolved, { where: predicate }),
191
191
  table,
192
192
  entries: resolved.map((entry) => renderIndexColumn(entry, (sql) => ctx.compileDdl(sql, meta.entity))),
193
193
  // An `include` column is named like any other, so a custom naming has to reach it too.
194
194
  include: include?.map((column) => fieldColumn(ctx, meta, column) ?? column),
195
195
  unique: options.unique ?? false,
196
- where: where && ctx.compileIndexPredicate(where, meta.entity, name),
196
+ where: predicate,
197
197
  });
198
198
  if (ctx.textScoreIndexes) {
199
199
  addTextScoreIndexes(ctx, table, options.type, resolved);
@@ -15,8 +15,14 @@ export declare function declaredIndexes<E>(meta: EntityMeta<E>): EntityIndexMeta
15
15
  export declare function renderIndexColumn(entry: EntityIndexColumn, render: (statement: QuerySql) => string): IndexColumnSchema;
16
16
  /** What an unnamed index's name is built from: each entry's column, or `expr<n>` for an expression, which has none. */
17
17
  export declare function indexNameParts(entries: readonly EntityIndexColumn[]): string[];
18
- /** The name an index is created and read by: its own, else one derived from its table, entries' columns and uniqueness. */
19
- export declare function declaredIndexName(name: string | undefined, table: string, entries: readonly EntityIndexColumn[], unique?: boolean): string;
18
+ /**
19
+ * The name an index is created and read by: its own, else one derived from its table, entries, uniqueness and
20
+ * rendered predicate. A caller renders the predicate first, since an unnamed partial index's name carries its hash.
21
+ */
22
+ export declare function declaredIndexName(name: string | undefined, table: string, entries: readonly EntityIndexColumn[], { unique, where }?: {
23
+ readonly unique?: boolean;
24
+ readonly where?: string;
25
+ }): string;
20
26
  /**
21
27
  * A check as uql installs it: named for its table and `label`, the author's name or `ck`, then a hash
22
28
  * of `expression`, so an edited check is a new name and reordering the checks renames none.
@@ -36,9 +36,12 @@ export function renderIndexColumn(entry, render) {
36
36
  export function indexNameParts(entries) {
37
37
  return entries.map((entry, at) => (typeof entry.column === 'string' ? entry.column : `expr${at}`));
38
38
  }
39
- /** The name an index is created and read by: its own, else one derived from its table, entries' columns and uniqueness. */
40
- export function declaredIndexName(name, table, entries, unique = false) {
41
- return name ?? derivedIndexName(table, indexNameParts(entries), unique);
39
+ /**
40
+ * The name an index is created and read by: its own, else one derived from its table, entries, uniqueness and
41
+ * rendered predicate. A caller renders the predicate first, since an unnamed partial index's name carries its hash.
42
+ */
43
+ export function declaredIndexName(name, table, entries, { unique = false, where } = {}) {
44
+ return name ?? derivedIndexName(table, indexNameParts(entries), unique, where);
42
45
  }
43
46
  /**
44
47
  * A check as uql installs it: named for its table and `label`, the author's name or `ck`, then a hash
@@ -26,9 +26,14 @@ export declare function isOwnedName(name: string): boolean;
26
26
  export declare function ownedName(table: string, label: string, content: string): string;
27
27
  /**
28
28
  * The name a derived index gets when nothing named it: `Order__total_idx`, or `Order__total_uk` for a
29
- * unique one - which the builder has always spelled apart, and which reads as what it enforces.
29
+ * unique one. A partial index also carries a hash of its `where`, so an edited predicate is a new name.
30
30
  */
31
- export declare function derivedIndexName(table: string, columns: readonly string[], unique?: boolean): string;
31
+ export declare function derivedIndexName(table: string, columns: readonly string[], unique?: boolean, where?: string): string;
32
+ /**
33
+ * Whether uql named the index `name` itself from `columns`: `derivedIndexName`'s forms, with a predicate's hash or
34
+ * without, and the `idx_<table>_<columns>` spelling an older uql gave one.
35
+ */
36
+ export declare function isDerivedIndexName(table: string, columns: readonly string[], name: string): boolean;
32
37
  /**
33
38
  * The constraint name a primary key gets when we name one: `Enrolment__studentId_courseId_pk`.
34
39
  *
@@ -68,10 +68,23 @@ function hashIdentifier(value) {
68
68
  }
69
69
  /**
70
70
  * The name a derived index gets when nothing named it: `Order__total_idx`, or `Order__total_uk` for a
71
- * unique one - which the builder has always spelled apart, and which reads as what it enforces.
71
+ * unique one. A partial index also carries a hash of its `where`, so an edited predicate is a new name.
72
72
  */
73
- export function derivedIndexName(table, columns, unique = false) {
74
- return derivedConstraintName(table, columns, unique ? 'uk' : 'idx');
73
+ export function derivedIndexName(table, columns, unique = false, where) {
74
+ const parts = where === undefined ? columns : [...columns, hashIdentifier(where)];
75
+ return derivedConstraintName(table, parts, unique ? 'uk' : 'idx');
76
+ }
77
+ /** The hash a partial index's derived name carries before its kind. */
78
+ const PREDICATE_HASH = new RegExp(`_[0-9a-f]{${NAME_HASH_LENGTH}}(?=_(?:idx|uk)$)`);
79
+ /**
80
+ * Whether uql named the index `name` itself from `columns`: `derivedIndexName`'s forms, with a predicate's hash or
81
+ * without, and the `idx_<table>_<columns>` spelling an older uql gave one.
82
+ */
83
+ export function isDerivedIndexName(table, columns, name) {
84
+ const plain = [derivedIndexName(table, columns), derivedIndexName(table, columns, true)];
85
+ return (plain.includes(name) ||
86
+ plain.includes(name.replace(PREDICATE_HASH, '')) ||
87
+ name === `idx_${table}_${columns.join('_')}`);
75
88
  }
76
89
  /**
77
90
  * The constraint name a primary key gets when we name one: `Enrolment__studentId_courseId_pk`.
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "homepage": "https://uql-orm.dev",
4
4
  "description": "JSON-native TypeScript ORM for Bun, Browsers, Edge, Node, Workers. Supports PostgreSQL, PGlite, MySQL, MariaDB, SQLite, CockroachDB, SQL Server, Turso, Neon, Cloudflare D1 and MongoDB. Queries are plain JSON, typed to the leaf.",
5
5
  "license": "MIT",
6
- "version": "0.101.5",
6
+ "version": "0.101.6",
7
7
  "type": "module",
8
8
  "engines": {
9
9
  "node": ">=22.18"
@@ -146,7 +146,7 @@ A `findManyStream` holds its querier until the loop ends, which refuses any othe
146
146
  - `generate:entities` writes the diff as a migration file to review. It renames a column a naming strategy spells otherwise (`firstName` to `first_name`); any other renamed column is a drop and an add it warns about, with the `renameColumn(table, from, to)` to write instead. It refuses a required column with no default on a table holding rows.
147
147
  - `up` and `down` apply and revert migrations, each in its own transaction, holding a lock so concurrent instances run each migration once. From code, `await new Migrator(pool, { migrationsPath }).up()` before the app starts: it rejects with the first failing migration's error, the ones before it applied. `down()` reverts the last one; `down({ step: Infinity })` every one.
148
148
  - `generate:from-db` writes entity classes from an existing database.
149
- - `drift:check` fails when the database no longer matches.
149
+ - `drift:check` fails when the database no longer matches. An unnamed partial index carries a hash of its `where` in its name, so editing the predicate replaces it; a named one's predicate is compared only by whether it is there. An index expression and a stored computed column's expression are not compared, so changing one is written by hand in the migration.
150
150
  - `sync --dry-run` prints only SQL on stdout, to append to a migration file another tool applies: on Cloudflare D1, wrangler's (https://uql-orm.dev/cloudflare-d1.md).
151
151
 
152
152
  Checks, an enum's included, and triggers are part of the diff: uql owns the `_uql_`-prefixed ones and never touches another. On MongoDB, checks and enums are the collection's validator, which uql owns whole, and a check fails a document lacking the field it compares.