uql-orm 0.37.1 → 0.39.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.
- package/dist/browser/uql-browser.min.js +2 -2
- package/dist/browser/uql-browser.min.js.map +5 -5
- package/dist/cockroachdb/cockroachDialect.d.ts +5 -24
- package/dist/cockroachdb/cockroachDialect.js +3 -29
- package/dist/dialect/abstractSqlDialect.d.ts +42 -12
- package/dist/dialect/abstractSqlDialect.js +117 -48
- package/dist/dialect/aliases.d.ts +6 -0
- package/dist/dialect/aliases.js +6 -0
- package/dist/dialect/index.d.ts +0 -5
- package/dist/dialect/index.js +2 -5
- package/dist/dialect/jsonSql.d.ts +17 -2
- package/dist/dialect/jsonSql.js +15 -0
- package/dist/dialect/mysqlLikeSqlDialect.d.ts +13 -14
- package/dist/dialect/mysqlLikeSqlDialect.js +16 -20
- package/dist/dialect/pgLikeSqlDialect.d.ts +17 -20
- package/dist/dialect/pgLikeSqlDialect.js +30 -62
- package/dist/dialect/vectorCast.d.ts +0 -9
- package/dist/dialect/vectorCast.js +0 -8
- package/dist/dialect/vectorSqlDialect.d.ts +47 -17
- package/dist/dialect/vectorSqlDialect.js +78 -30
- package/dist/entity/decorator/entity.d.ts +1 -1
- package/dist/entity/metadata/definition.d.ts +1 -1
- package/dist/entity/metadata/definition.js +4 -3
- package/dist/http/query.js +3 -2
- package/dist/libsql/libsqlDialect.d.ts +2 -2
- package/dist/libsql/libsqlDialect.js +3 -3
- package/dist/maria/mariaDialect.d.ts +12 -17
- package/dist/maria/mariaDialect.js +21 -36
- package/dist/maria/mariaVectorMetrics.d.ts +8 -0
- package/dist/maria/mariaVectorMetrics.js +10 -0
- package/dist/maria/mariadbQuerier.d.ts +5 -0
- package/dist/maria/mariadbQuerier.js +5 -0
- package/dist/migrate/builder/migrationBuilder.d.ts +8 -17
- package/dist/migrate/builder/migrationBuilder.js +48 -136
- package/dist/migrate/builder/types.d.ts +0 -2
- package/dist/migrate/ddl/index.d.ts +11 -0
- package/dist/migrate/ddl/index.js +34 -0
- package/dist/{dialect/indexSqlDialect.d.ts → migrate/ddl/indexDdl.d.ts} +23 -19
- package/dist/migrate/ddl/indexDdl.js +126 -0
- package/dist/migrate/ddl/mysqlIndexDdl.d.ts +52 -0
- package/dist/migrate/ddl/mysqlIndexDdl.js +125 -0
- package/dist/migrate/ddl/pgIndexDdl.d.ts +36 -0
- package/dist/migrate/ddl/pgIndexDdl.js +87 -0
- package/dist/migrate/drift/driftDetector.js +6 -1
- package/dist/migrate/generator/mongoSchemaGenerator.js +1 -1
- package/dist/migrate/index.d.ts +1 -0
- package/dist/migrate/index.js +2 -0
- package/dist/migrate/introspection/mysqlIntrospector.d.ts +9 -3
- package/dist/migrate/introspection/mysqlIntrospector.js +27 -5
- package/dist/migrate/migrator.js +3 -2
- package/dist/migrate/schemaGenerator.d.ts +6 -6
- package/dist/migrate/schemaGenerator.js +13 -22
- package/dist/mongo/mongoDialect.d.ts +1 -2
- package/dist/mongo/mongoDialect.js +29 -22
- package/dist/mongo/mongodbQuerier.js +1 -1
- package/dist/mysql/mysqlDialect.d.ts +3 -6
- package/dist/mysql/mysqlDialect.js +4 -11
- package/dist/postgres/postgresDialect.d.ts +2 -0
- package/dist/postgres/postgresDialect.js +2 -0
- package/dist/querier/abstractSqlQuerier.d.ts +11 -0
- package/dist/querier/abstractSqlQuerier.js +35 -0
- package/dist/schema/canonicalType.js +35 -36
- package/dist/schema/indexDifferences.d.ts +2 -1
- package/dist/schema/indexDifferences.js +3 -2
- package/dist/sqlite/sqliteDialect.d.ts +2 -2
- package/dist/sqlite/sqliteDialect.js +5 -5
- package/dist/turso/tursoDialect.d.ts +2 -2
- package/dist/turso/tursoDialect.js +4 -4
- package/dist/type/dialect.d.ts +21 -7
- package/dist/type/dialect.js +17 -0
- package/dist/type/entity.d.ts +117 -8
- package/dist/type/entity.js +7 -0
- package/dist/type/query.d.ts +18 -0
- package/dist/type/query.js +6 -0
- package/dist/type/queryWhere.d.ts +46 -2
- package/dist/type/vector.d.ts +45 -7
- package/dist/type/vector.js +16 -1
- package/dist/util/dialect.util.d.ts +20 -1
- package/dist/util/dialect.util.js +49 -4
- package/dist/util/object.util.d.ts +7 -1
- package/dist/util/object.util.js +8 -0
- package/dist/util/relationQuery.util.d.ts +3 -1
- package/dist/util/relationQuery.util.js +8 -3
- package/package.json +1 -1
- package/dist/dialect/indexSqlDialect.js +0 -103
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { INDEX_FEATURE_LABELS } from '../type/index.js';
|
|
2
|
-
import { VectorSqlDialect } from './vectorSqlDialect.js';
|
|
3
|
-
/**
|
|
4
|
-
* `CREATE INDEX` for SQL dialects: the statement and the fragments each engine spells differently.
|
|
5
|
-
*
|
|
6
|
-
* A layer of its own for the same reason as {@link VectorSqlDialect} below it - it needs only
|
|
7
|
-
* `escapeId` and `features.indexIfNotExists` from the SQL dialect above, so keeping it here spares
|
|
8
|
-
* that 2000-line class thirteen more members. What each engine can express at all is data
|
|
9
|
-
* ({@link indexFeatures}), validated once, rather than a throw per feature per dialect.
|
|
10
|
-
*/
|
|
11
|
-
export class IndexSqlDialect extends VectorSqlDialect {
|
|
12
|
-
/**
|
|
13
|
-
* The `CREATE INDEX` statement for this dialect. The form here is the portable one, which SQLite
|
|
14
|
-
* (and so libSQL, Turso and D1) takes verbatim: no access-method clause, no operator classes, no
|
|
15
|
-
* tuning parameters. Dialects that have those override the fragments below rather than this.
|
|
16
|
-
*/
|
|
17
|
-
getCreateIndexStatement(tableName, index, opts = {}) {
|
|
18
|
-
this.assertIndexFeatures(index);
|
|
19
|
-
const unique = index.unique ? 'UNIQUE ' : '';
|
|
20
|
-
const ifNotExists = (opts.ifNotExists ?? this.features.indexIfNotExists) ? 'IF NOT EXISTS ' : '';
|
|
21
|
-
const columns = index.entries.map((entry) => this.indexColumn(entry, index)).join(', ');
|
|
22
|
-
return (`CREATE ${unique}${this.indexKeyword(index)} ${ifNotExists}${this.escapeId(index.name)} ` +
|
|
23
|
-
`ON ${this.escapeId(tableName)}${this.indexAccessMethod(index)} (${columns})` +
|
|
24
|
-
`${this.indexInclude(index)}${this.indexTuning(index)}${this.indexPredicate(index)};`);
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Index features this dialect can express. Everything here is supported by at least one engine and
|
|
28
|
-
* refused by at least one other, so an index asking for a missing one is rejected rather than
|
|
29
|
-
* emitted: each of them is a hard error at the server, not a slower plan.
|
|
30
|
-
*/
|
|
31
|
-
indexFeatures = new Set(['expression', 'partial']);
|
|
32
|
-
assertIndexFeatures(index) {
|
|
33
|
-
const requested = [
|
|
34
|
-
['expression', index.entries.some((entry) => entry.expression)],
|
|
35
|
-
['partial', index.where !== undefined],
|
|
36
|
-
['prefixLength', index.entries.some((entry) => entry.length !== undefined)],
|
|
37
|
-
['nullsOrder', index.entries.some((entry) => entry.nulls !== undefined)],
|
|
38
|
-
['opsClass', index.entries.some((entry) => entry.opsClass !== undefined)],
|
|
39
|
-
['include', Boolean(index.include?.length)],
|
|
40
|
-
];
|
|
41
|
-
for (const [feature, needed] of requested) {
|
|
42
|
-
if (needed && !this.indexFeatures.has(feature)) {
|
|
43
|
-
throw new TypeError(`${this.dialectName} does not support ${INDEX_FEATURE_LABELS[feature]} (index "${index.name}")`);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* The column-level declaration for a vector index that lives inside `CREATE TABLE` rather than in
|
|
49
|
-
* its own statement, which the `inlineVectorIndex` feature flags. Only MariaDB has one.
|
|
50
|
-
*/
|
|
51
|
-
getInlineVectorIndexDeclaration(index) {
|
|
52
|
-
throw new TypeError(`${this.dialectName} has no inline vector index (index "${index.name}")`);
|
|
53
|
-
}
|
|
54
|
-
/** Only CockroachDB's native vector index replaces the `INDEX` keyword. */
|
|
55
|
-
indexKeyword(_index) {
|
|
56
|
-
return 'INDEX';
|
|
57
|
-
}
|
|
58
|
-
/** One index entry: what is indexed, its operator class if any, then its stored order. */
|
|
59
|
-
indexColumn(entry, index) {
|
|
60
|
-
return `${this.indexColumnTarget(entry)}${this.indexColumnOpsClass(entry, index)}${this.indexColumnOrder(entry)}`;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* A quoted column, optionally prefix-limited, or an expression in its own parentheses - the form
|
|
64
|
-
* `((lower("email")))` that MySQL requires and Postgres, CockroachDB and SQLite all accept, so one
|
|
65
|
-
* rendering serves every engine that has expression indexes.
|
|
66
|
-
*/
|
|
67
|
-
indexColumnTarget(entry) {
|
|
68
|
-
if (entry.expression) {
|
|
69
|
-
return `(${entry.column})`;
|
|
70
|
-
}
|
|
71
|
-
const column = this.escapeId(entry.column);
|
|
72
|
-
return entry.length === undefined ? column : `${column}(${entry.length})`;
|
|
73
|
-
}
|
|
74
|
-
/** Postgres-wire dialects put a vector or user-declared operator class here. */
|
|
75
|
-
indexColumnOpsClass(_entry, _index) {
|
|
76
|
-
return '';
|
|
77
|
-
}
|
|
78
|
-
/** `ASC` is every engine's default, so only `DESC` is worth emitting. */
|
|
79
|
-
indexColumnOrder(entry) {
|
|
80
|
-
const order = entry.order === 'desc' ? ' DESC' : '';
|
|
81
|
-
return entry.nulls ? `${order} NULLS ${entry.nulls.toUpperCase()}` : order;
|
|
82
|
-
}
|
|
83
|
-
/** ` INCLUDE (...)`: non-key columns stored for index-only scans. Postgres-wire only. */
|
|
84
|
-
indexInclude(_index) {
|
|
85
|
-
return '';
|
|
86
|
-
}
|
|
87
|
-
/** ` USING <method>`, which SQLite's grammar has no place for at all. */
|
|
88
|
-
indexAccessMethod(_index) {
|
|
89
|
-
return '';
|
|
90
|
-
}
|
|
91
|
-
/** pgvector's ` WITH (m = ..., ef_construction = ..., lists = ...)`. */
|
|
92
|
-
indexTuning(_index) {
|
|
93
|
-
return '';
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* The partial-index predicate. Engines without one reject the index in {@link assertIndexFeatures}
|
|
97
|
-
* rather than reaching here: silently widening a partial unique index changes which rows the
|
|
98
|
-
* database accepts.
|
|
99
|
-
*/
|
|
100
|
-
indexPredicate(index) {
|
|
101
|
-
return index.where ? ` WHERE ${index.where}` : '';
|
|
102
|
-
}
|
|
103
|
-
}
|