uql-orm 0.101.1 → 0.101.2

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 (88) hide show
  1. package/README.md +1 -1
  2. package/dist/browser/uql-browser.min.js +2 -2
  3. package/dist/browser/uql-browser.min.js.map +6 -6
  4. package/dist/d1/d1SqliteDialect.d.ts +1 -1
  5. package/dist/d1/d1SqliteDialect.js +1 -1
  6. package/dist/dialect/abstractDialect.js +2 -2
  7. package/dist/dialect/abstractSqlDialect.d.ts +10 -10
  8. package/dist/dialect/abstractSqlDialect.js +24 -24
  9. package/dist/dialect/operators.js +2 -2
  10. package/dist/dialect/pgLikeSqlDialect.d.ts +1 -1
  11. package/dist/dialect/pgLikeSqlDialect.js +5 -5
  12. package/dist/dialect/queryContext.d.ts +1 -1
  13. package/dist/dialect/queryContext.js +1 -1
  14. package/dist/dialect/vectorSqlDialect.js +1 -1
  15. package/dist/entity/decorator/entity.d.ts +2 -2
  16. package/dist/entity/decorator/entity.js +2 -2
  17. package/dist/http/query.d.ts +1 -1
  18. package/dist/http/query.js +4 -4
  19. package/dist/index.d.ts +1 -1
  20. package/dist/index.js +1 -1
  21. package/dist/migrate/builder/tableBuilder.js +1 -1
  22. package/dist/migrate/builder/types.d.ts +2 -2
  23. package/dist/migrate/codegen/entityCodeGenerator.js +1 -1
  24. package/dist/migrate/codegen/fieldOptionsSource.js +5 -5
  25. package/dist/migrate/codegen/indexDecoratorSource.d.ts +2 -2
  26. package/dist/migrate/codegen/indexDecoratorSource.js +5 -5
  27. package/dist/migrate/codegen/sourceLiteral.d.ts +2 -2
  28. package/dist/migrate/codegen/sourceLiteral.js +3 -3
  29. package/dist/migrate/ddl/defaultSql.js +1 -1
  30. package/dist/migrate/generator/definitionToNode.d.ts +3 -3
  31. package/dist/migrate/indexPredicate.d.ts +1 -1
  32. package/dist/migrate/indexPredicate.js +5 -5
  33. package/dist/migrate/introspection/abstractSqlSchemaIntrospector.d.ts +8 -8
  34. package/dist/migrate/introspection/abstractSqlSchemaIntrospector.js +3 -3
  35. package/dist/migrate/introspection/mssqlIntrospector.d.ts +5 -5
  36. package/dist/migrate/introspection/mssqlIntrospector.js +10 -10
  37. package/dist/migrate/introspection/mysqlIntrospector.d.ts +5 -5
  38. package/dist/migrate/introspection/mysqlIntrospector.js +13 -13
  39. package/dist/migrate/introspection/postgresIntrospector.d.ts +13 -13
  40. package/dist/migrate/introspection/postgresIntrospector.js +21 -21
  41. package/dist/migrate/introspection/sqliteIntrospector.d.ts +4 -4
  42. package/dist/migrate/introspection/sqliteIntrospector.js +6 -6
  43. package/dist/migrate/migrationLock.d.ts +3 -3
  44. package/dist/migrate/migrationLock.js +7 -7
  45. package/dist/migrate/migrationTarget.js +2 -2
  46. package/dist/migrate/migrator.js +2 -2
  47. package/dist/migrate/schemaGenerator.d.ts +1 -1
  48. package/dist/migrate/schemaGenerator.js +1 -1
  49. package/dist/migrate/storage/databaseStorage.d.ts +3 -3
  50. package/dist/migrate/storage/databaseStorage.js +4 -4
  51. package/dist/migrate/triggerSql.js +7 -7
  52. package/dist/mongodb/mongoDialect.js +4 -4
  53. package/dist/mongodb/mongoSchemaGenerator.js +3 -3
  54. package/dist/mssql/mssqlDialect.js +3 -3
  55. package/dist/querier/abstractSqlQuerier.js +1 -1
  56. package/dist/schema/canonicalType.d.ts +1 -1
  57. package/dist/schema/canonicalType.js +6 -6
  58. package/dist/schema/sqlExpression.d.ts +4 -4
  59. package/dist/schema/sqlExpression.js +5 -5
  60. package/dist/sqlite/sqliteDialect.js +2 -2
  61. package/dist/type/dialect.d.ts +3 -3
  62. package/dist/type/entity.d.ts +39 -39
  63. package/dist/type/index.d.ts +1 -1
  64. package/dist/type/index.js +1 -1
  65. package/dist/type/migration.d.ts +1 -1
  66. package/dist/type/querier.d.ts +5 -5
  67. package/dist/type/query.d.ts +32 -32
  68. package/dist/type/queryAggregate.d.ts +2 -2
  69. package/dist/type/{queryRaw.d.ts → querySql.d.ts} +33 -33
  70. package/dist/type/{queryRaw.js → querySql.js} +17 -17
  71. package/dist/type/queryWhere.d.ts +22 -22
  72. package/dist/type/universalQuerier.d.ts +12 -12
  73. package/dist/type/wire.d.ts +4 -4
  74. package/dist/util/ddlExpression.util.d.ts +4 -4
  75. package/dist/util/ddlExpression.util.js +7 -7
  76. package/dist/util/dialect.util.d.ts +7 -7
  77. package/dist/util/dialect.util.js +4 -4
  78. package/dist/util/fieldOption.util.d.ts +3 -3
  79. package/dist/util/fieldOption.util.js +5 -5
  80. package/dist/util/index.d.ts +1 -1
  81. package/dist/util/index.js +1 -1
  82. package/dist/util/query.util.js +1 -1
  83. package/dist/util/{raw.d.ts → sql.d.ts} +22 -20
  84. package/dist/util/{raw.js → sql.js} +28 -26
  85. package/dist/util/triggerWrite.d.ts +7 -7
  86. package/dist/util/triggerWrite.js +2 -2
  87. package/package.json +1 -1
  88. package/skills/uql-orm/SKILL.md +7 -7
@@ -2,7 +2,7 @@ import { runMongoCommand } from '../mongodb/mongoCommand.js';
2
2
  import { MongoMigrationStorage } from '../mongodb/mongoMigrationStorage.js';
3
3
  import { isMongoQuerier, withMongoQuerierForMigrations } from '../mongodb/mongoQuerier.js';
4
4
  import { isSqlQuerier, } from '../type/index.js';
5
- import { raw } from '../util/raw.js';
5
+ import { sql } from '../util/sql.js';
6
6
  import { UqlUsageError } from '../util/uqlError.js';
7
7
  import { withSqlQuerierForMigrations } from './acquireQuerierForMigrations.js';
8
8
  import { MigrationOperationBuilder } from './builder/migrationBuilder.js';
@@ -12,7 +12,7 @@ import { SqlSchemaGenerator } from './schemaGenerator.js';
12
12
  import { DatabaseMigrationStorage, LOCK_RECORD } from './storage/databaseStorage.js';
13
13
  const sqlSession = (querier) => ({
14
14
  querier,
15
- run: (statement) => querier.run(raw.text(statement)),
15
+ run: (statement) => querier.run(sql.text(statement)),
16
16
  transaction: (work) => querier.dialect.features.rebuildsTables ? withForeignKeysOff(querier, work) : querier.transaction(work),
17
17
  });
18
18
  /**
@@ -5,7 +5,7 @@ import { getEntities, getMeta } from '../entity/index.js';
5
5
  import { SchemaAST } from '../schema/schemaAST.js';
6
6
  import { columnRenameCandidates, columnRenames, tableRenameCandidates, } from '../schema/schemaASTDiffer.js';
7
7
  import { definedEntries, isRecord, LoggerWrapper } from '../util/index.js';
8
- import { raw } from '../util/raw.js';
8
+ import { sql } from '../util/sql.js';
9
9
  import { isOwnedName, qualifyName } from '../util/sql.util.js';
10
10
  import { UqlUsageError } from '../util/uqlError.js';
11
11
  import { withSqlQuerierForMigrations } from './acquireQuerierForMigrations.js';
@@ -233,7 +233,7 @@ export class Migrator {
233
233
  const found = [];
234
234
  for (const { tableName, column, nullable } of counts) {
235
235
  const empty = nullable ? ` WHERE ${escapeId(column)} IS NULL` : '';
236
- const [{ rows }] = await querier.all(raw.text(`SELECT COUNT(*) AS ${escapeId('rows')} FROM ${escapeId(tableName)}${empty}`));
236
+ const [{ rows }] = await querier.all(sql.text(`SELECT COUNT(*) AS ${escapeId('rows')} FROM ${escapeId(tableName)}${empty}`));
237
237
  const count = Number(rows);
238
238
  if (count) {
239
239
  found.push(`"${tableName}"."${column}" is required with no default, and ${count} ${count === 1 ? 'row holds' : 'rows hold'} none`);
@@ -100,7 +100,7 @@ export declare class SqlSchemaGenerator implements SchemaGenerator {
100
100
  generateCreateTableFromDefinition(table: TableDefinition, options?: {
101
101
  ifNotExists?: boolean;
102
102
  }): string[];
103
- /** `raw` is split, being the one SQL no generator wrote. */
103
+ /** `sql` is split, being the one SQL no generator wrote. */
104
104
  generateOperation(operation: AnyMigrationOperation): string[];
105
105
  /** `ADD COLUMN`, plus the foreign key and index the column declares, as `CREATE TABLE` lifts them. */
106
106
  private addColumnSql;
@@ -377,7 +377,7 @@ export class SqlSchemaGenerator {
377
377
  const tableNode = tableDefinitionToNode(table, (sql) => this.dialect.compileDdl(sql));
378
378
  return this.generateCreateTableFromNode(tableNode, options);
379
379
  }
380
- /** `raw` is split, being the one SQL no generator wrote. */
380
+ /** `sql` is split, being the one SQL no generator wrote. */
381
381
  generateOperation(operation) {
382
382
  switch (operation.type) {
383
383
  case 'createTable':
@@ -1,4 +1,4 @@
1
- import type { Querier, QueryRaw, SqlQuerier } from '../../type/index.js';
1
+ import type { Querier, QuerySql, SqlQuerier } from '../../type/index.js';
2
2
  /** Where executed migrations are recorded when the config does not name a table. */
3
3
  export declare const DEFAULT_MIGRATIONS_TABLE = "uql_migrations";
4
4
  /**
@@ -34,6 +34,6 @@ export declare class DatabaseMigrationStorage implements MigrationStorage {
34
34
  }
35
35
  /** The journal `tableName` and its one column, escaped as `querier`'s engine spells them. */
36
36
  export declare function journalIds({ dialect }: SqlQuerier, tableName: string): {
37
- table: QueryRaw;
38
- name: QueryRaw;
37
+ table: QuerySql;
38
+ name: QuerySql;
39
39
  };
@@ -1,4 +1,4 @@
1
- import { currentTimestamp, raw } from '../../util/raw.js';
1
+ import { currentTimestamp, sql } from '../../util/sql.js';
2
2
  import { TableDefinitionBuilder } from '../builder/tableBuilder.js';
3
3
  import { SqlSchemaGenerator } from '../schemaGenerator.js';
4
4
  /** Where executed migrations are recorded when the config does not name a table. */
@@ -18,8 +18,8 @@ export async function createMigrationsTable(querier, tableName) {
18
18
  table.string('name', { length: 255, primaryKey: true });
19
19
  table.timestamptz('executed_at', { defaultValue: currentTimestamp });
20
20
  const generator = new SqlSchemaGenerator(querier.dialect);
21
- for (const sql of generator.generateCreateTableFromDefinition(table.build(), { ifNotExists: true })) {
22
- await querier.run(raw.text(sql));
21
+ for (const statement of generator.generateCreateTableFromDefinition(table.build(), { ifNotExists: true })) {
22
+ await querier.run(sql.text(statement));
23
23
  }
24
24
  }
25
25
  /** Records the migrations run in a table, on the querier each call is handed, which the lock created. */
@@ -47,5 +47,5 @@ export class DatabaseMigrationStorage {
47
47
  }
48
48
  /** The journal `tableName` and its one column, escaped as `querier`'s engine spells them. */
49
49
  export function journalIds({ dialect }, tableName) {
50
- return { table: raw.text(dialect.escapeId(tableName)), name: raw.text(dialect.escapeId('name')) };
50
+ return { table: sql.text(dialect.escapeId(tableName)), name: sql.text(dialect.escapeId('name')) };
51
51
  }
@@ -1,7 +1,7 @@
1
- import { TriggerWriteRaw } from '../type/index.js';
1
+ import { TriggerWriteSql } from '../type/index.js';
2
2
  import { stampEvents } from '../util/field.util.js';
3
3
  import { definedEntries } from '../util/object.util.js';
4
- import { raw, refs, rowRefs } from '../util/raw.js';
4
+ import { sql, refs, rowRefs } from '../util/sql.js';
5
5
  import { ownedName, splitQualifiedName } from '../util/sql.util.js';
6
6
  import { written } from '../util/triggerWrite.js';
7
7
  import { UqlUsageError } from '../util/uqlError.js';
@@ -58,7 +58,7 @@ function triggerStatements(dialect, meta, trigger, name) {
58
58
  const rows = [rowRefs(meta.entity, names.$new), rowRefs(meta.entity, names.$old)];
59
59
  const filter = triggerFilter(dialect, meta, trigger, rows, names);
60
60
  const body = triggerBody(dialect, meta, trigger, before)(...rows);
61
- if (perStatement && filter && !(body instanceof TriggerWriteRaw)) {
61
+ if (perStatement && filter && !(body instanceof TriggerWriteSql)) {
62
62
  throw new UqlUsageError(`${dialect.dialectName} fires a trigger once per statement, so 'of' and 'where' narrow only what ` +
63
63
  `insertInto, updateTable or deleteFrom reads, and '${meta.entity.name}' has one running its own SQL. ` +
64
64
  'Keep the body to those writes, or filter inserted and deleted in that SQL.');
@@ -199,17 +199,17 @@ function stampBody(dialect, meta, key, value, newRow) {
199
199
  const { entity } = meta;
200
200
  if (dialect.features.triggers.assignsRow) {
201
201
  const target = newRow[key];
202
- return dialect.features.triggers.body === 'function' ? raw `${target} := ${value};` : raw `SET ${target} = ${value};`;
202
+ return dialect.features.triggers.body === 'function' ? sql `${target} := ${value};` : sql `SET ${target} = ${value};`;
203
203
  }
204
204
  const table = refs(entity);
205
- const keyed = meta.ids.map((id) => raw `${table[id]} = ${newRow[id]}`);
205
+ const keyed = meta.ids.map((id) => sql `${table[id]} = ${newRow[id]}`);
206
206
  // Read through the write's own qualifier, as `keyed` is: `inserted` holds the same column name.
207
207
  const stamped = dialect.compileDdl(value, entity);
208
- const differs = raw(({ ctx, escapedPrefix }) => ctx.append(dialect.neExpr(`${escapedPrefix}${dialect.escapedColumnName(meta, key)}`, stamped)));
208
+ const differs = sql(({ ctx, escapedPrefix }) => ctx.append(dialect.neExpr(`${escapedPrefix}${dialect.escapedColumnName(meta, key)}`, stamped)));
209
209
  const where = { $and: [...keyed, differs] };
210
210
  const restated = written({ kind: 'update', entity, set: { [key]: value }, where });
211
211
  const { reentryGuard } = dialect.features.triggers;
212
- return reentryGuard ? raw `${raw(() => reentryGuard)}\n${restated}` : restated;
212
+ return reentryGuard ? sql `${sql(() => reentryGuard)}\n${restated}` : restated;
213
213
  }
214
214
  /** A dollar quote the body does not contain, so no `$$` in it - a literal, a comment - ends the function early. */
215
215
  function dollarQuote(body) {
@@ -5,7 +5,7 @@ import { betweenBounds, GROUP_OPS, groupClauses, isGroupOp, LIKE_OPS, likeRegex,
5
5
  import { aggregateColumnField, groupPathField, resolveGroupJoins, relationSortTerms, resolveQueryJoins, resolveSortableJoin, } from '../dialect/queryJoins.js';
6
6
  import { assertSoleId, fieldOf, getMeta, relationOf, soleIdOf } from '../entity/index.js';
7
7
  import { COUNT_RESULT_KEY } from '../type/query.js';
8
- import { QueryRaw } from '../type/queryRaw.js';
8
+ import { QuerySql } from '../type/querySql.js';
9
9
  import { aggregateOf, isSelectList, assertAggregateColumns, assertNoUndefined, assertNonNegativeInteger, columnFamily, countedRelations, entityName, fieldUpdateOf, fillOnFields, filterFieldKeys, findVectorIndex, findVectorSort, definedEntries, getKeys, holdsForeignKey, jsonKey, jsonPathKeys, getRelationRequestSummary, hasKeys, isFieldUpdateOp, isJsonObject, isJsonUpdateOp, isOperatorMap, isOperatorObject, isRecord, isVectorSearch, normalizeScalarFieldSelection, parentJoins, parseGroupMap, parseRelationAtKey, parseRelationSize, parseSortDirection, rankedTextSearch, someKey, targetJoins, textSortOf, vectorDistanceOf, } from '../util/index.js';
10
10
  import { UqlUsageError } from '../util/uqlError.js';
11
11
  import { decodeBigIntsExcept } from '../util/wideNumber.js';
@@ -32,12 +32,12 @@ export const mongoDialectFeatures = {
32
32
  };
33
33
  /** What `toWireId` converts: the hex spelling of an `ObjectId`, and nothing looser. */
34
34
  const HEX_24 = /^[0-9a-f]{24}$/i;
35
- /** `raw()` renders SQL, which MongoDB has no equivalent of: refused rather than emitted as `{}`. */
35
+ /** `sql()` renders SQL, which MongoDB has no equivalent of: refused rather than emitted as `{}`. */
36
36
  function rawRefusal(place) {
37
- return new UqlUsageError(`raw() in ${place} is not supported on MongoDB`);
37
+ return new UqlUsageError(`sql() in ${place} is not supported on MongoDB`);
38
38
  }
39
39
  function assertNoRaw(value, place) {
40
- if (value instanceof QueryRaw) {
40
+ if (value instanceof QuerySql) {
41
41
  throw rawRefusal(place);
42
42
  }
43
43
  }
@@ -5,7 +5,7 @@ import { indexNodeToSchema } from '../migrate/generator/indexNodeToSchema.js';
5
5
  import { assertIndexPredicate, refusedIndexPredicate } from '../migrate/indexPredicate.js';
6
6
  import { sides } from '../migrate/schemaChange.js';
7
7
  import { indexChanges } from '../schema/indexDifferences.js';
8
- import { QueryRaw, } from '../type/index.js';
8
+ import { QuerySql, } from '../type/index.js';
9
9
  import { indexDistance, unsupportedVectorMetric } from '../type/vector.js';
10
10
  import { declaredIndexes, declaredIndexName, renderIndexColumn } from '../util/ddlExpression.util.js';
11
11
  import { fulltextConfig, fulltextWeights } from '../util/dialect.util.js';
@@ -83,7 +83,7 @@ export class MongoSchemaGenerator extends MongoDialect {
83
83
  * what that holds or what a migration carries as JSON.
84
84
  */
85
85
  indexFilter(where, entity, indexName) {
86
- if (where instanceof QueryRaw) {
86
+ if (where instanceof QuerySql) {
87
87
  throw new UqlUsageError(`mongodb does not support partial indexes from a SQL predicate (index "${indexName}")`);
88
88
  }
89
89
  assertIndexPredicate(where, this.dialectName, indexName);
@@ -107,7 +107,7 @@ export class MongoSchemaGenerator extends MongoDialect {
107
107
  }
108
108
  /** A check's filter, refused where it is SQL or holds what a migration cannot carry as JSON. */
109
109
  checkFilter(where, entity, collectionName) {
110
- if (where instanceof QueryRaw) {
110
+ if (where instanceof QuerySql) {
111
111
  throw new UqlUsageError(`mongodb does not support checks from a SQL predicate (collection "${collectionName}")`);
112
112
  }
113
113
  const filter = this.renderFilter(entity, where);
@@ -5,7 +5,7 @@ import { jsonArraySlotArgs, jsonPath, jsonSlotArgs } from '../dialect/jsonSql.js
5
5
  import { MergeSqlDialect } from '../dialect/mergeSqlDialect.js';
6
6
  import { getMeta } from '../entity/index.js';
7
7
  import { canonicalToSql, resolveColumnCanonicalType } from '../schema/canonicalType.js';
8
- import { QueryRaw } from '../type/index.js';
8
+ import { QuerySql } from '../type/index.js';
9
9
  import { parseQueryLock } from '../type/index.js';
10
10
  import { bytesToHex } from '../util/bytes.js';
11
11
  import { isAutoIncrement, isExactDecimal, jsonPathKeys } from '../util/field.util.js';
@@ -337,11 +337,11 @@ export class MsSqlDialect extends MergeSqlDialect {
337
337
  return typeof value === 'boolean' ? `CAST(${placeholder} AS BIT)` : placeholder;
338
338
  }
339
339
  /**
340
- * An object or array bound as JSON, or a `raw()` rendered in place, which is the half both binders
340
+ * An object or array bound as JSON, or a `sql()` rendered in place, which is the half both binders
341
341
  * spell the same way; `undefined` for a scalar - where they diverge.
342
342
  */
343
343
  #jsonCompound(ctx, value) {
344
- if (value instanceof QueryRaw) {
344
+ if (value instanceof QuerySql) {
345
345
  return this.rawFragment(ctx, value);
346
346
  }
347
347
  if (value === null || typeof value !== 'object') {
@@ -1,7 +1,7 @@
1
1
  import { AGGREGATE_VALUE_ALIAS, TOTAL_ALIAS } from '../dialect/aliases.js';
2
2
  import { getMeta, namesKey } from '../entity/index.js';
3
3
  import { buildUpdateResult, chunk, clone, getInsertFieldKeys, insertShapeOf, isAutoIncrement } from '../util/index.js';
4
- import { statementOf } from '../util/raw.js';
4
+ import { statementOf } from '../util/sql.js';
5
5
  import { UqlUsageError } from '../util/uqlError.js';
6
6
  import { AbstractQuerier } from './abstractQuerier.js';
7
7
  import { streamViaCursor } from './cursorStream.js';
@@ -34,7 +34,7 @@ export declare function storedType(dialectName: DialectName, sqlType: string, re
34
34
  * the engine settles an unstated bound. Migrations and drift both compare through it.
35
35
  */
36
36
  export declare function engineType(dialect: AbstractDialect): (type: CanonicalType) => CanonicalType;
37
- /** A field's canonical type; a timestamp without precision gets a `Date`'s milliseconds, unless it is `raw` SQL. */
37
+ /** A field's canonical type; a timestamp without precision gets a `Date`'s milliseconds, unless it is `sql` SQL. */
38
38
  export declare function fieldOptionsToCanonical(options: FieldOptions): CanonicalType;
39
39
  /** Whether two canonical types are equal, guessing no engine default: `DiffOptions.normalizeType` settles those. */
40
40
  export declare function areTypesEqual(a: CanonicalType, b: CanonicalType): boolean;
@@ -1,9 +1,9 @@
1
1
  // Canonical types, between an engine's SQL types and TypeScript's.
2
2
  import { fieldOf, getMeta, soleIdOf } from '../entity/metadata/definition.js';
3
- import { QueryRaw } from '../type/index.js';
3
+ import { QuerySql } from '../type/index.js';
4
4
  import { DATE_PRECISION } from '../util/date.js';
5
5
  import { columnFamily, isIntegerColumn } from '../util/field.util.js';
6
- import { constantSql } from '../util/raw.js';
6
+ import { constantSql } from '../util/sql.js';
7
7
  /** Whether a category is one of the vector types, narrowing it to the cast pgvector names use. */
8
8
  export function isVectorCategory(category) {
9
9
  return category === 'vector' || category === 'halfvec' || category === 'sparsevec';
@@ -267,12 +267,12 @@ export function sqlToCanonical(sqlType, reported = {}) {
267
267
  };
268
268
  }
269
269
  /**
270
- * The SQL type a field declares, however it named one: `columnType`, the engine's own as a `raw`
270
+ * The SQL type a field declares, however it named one: `columnType`, the engine's own as a `sql`
271
271
  * constant, or a `type` that is a SQL string rather than a constructor.
272
272
  */
273
273
  function declaredSqlType(options) {
274
274
  const { columnType, type } = options;
275
- if (columnType instanceof QueryRaw) {
275
+ if (columnType instanceof QuerySql) {
276
276
  return constantSql(columnType);
277
277
  }
278
278
  return columnType ?? (typeof type === 'string' ? type : undefined);
@@ -346,10 +346,10 @@ export function storedType(dialectName, sqlType, reported) {
346
346
  export function engineType(dialect) {
347
347
  return (type) => storedType(dialect.dialectName, canonicalToSql(type, dialect));
348
348
  }
349
- /** A field's canonical type; a timestamp without precision gets a `Date`'s milliseconds, unless it is `raw` SQL. */
349
+ /** A field's canonical type; a timestamp without precision gets a `Date`'s milliseconds, unless it is `sql` SQL. */
350
350
  export function fieldOptionsToCanonical(options) {
351
351
  const type = fieldType(options);
352
- return options.columnType instanceof QueryRaw ? type : withTimestampPrecision(type, DATE_PRECISION);
352
+ return options.columnType instanceof QuerySql ? type : withTimestampPrecision(type, DATE_PRECISION);
353
353
  }
354
354
  function fieldType(options) {
355
355
  // A SQL type is read exactly as an introspected one is, whichever option named it, so a bound stated
@@ -1,9 +1,9 @@
1
- import { QueryRaw, type SqlValueName } from '../type/index.js';
1
+ import { QuerySql, type SqlValueName } from '../type/index.js';
2
2
  /**
3
3
  * The kind of a {@link SqlExpression}: a value uql exports by name, which `formatDefaultValue` spells for the
4
4
  * engine at DDL time, or `raw`, carrying its own SQL.
5
5
  */
6
- export type SqlExpressionKind = SqlValueName | 'raw';
6
+ export type SqlExpressionKind = SqlValueName | 'sql';
7
7
  /**
8
8
  * A column default that is SQL rather than a literal, whether an entity or a migration declares it or
9
9
  * introspection reads it back. It is a class, not a plain object, so a JSON default cannot pass for one.
@@ -11,7 +11,7 @@ export type SqlExpressionKind = SqlValueName | 'raw';
11
11
  export declare class SqlExpression {
12
12
  readonly kind: SqlExpressionKind;
13
13
  readonly sql?: string | undefined;
14
- /** `sql` is set only for the `raw` kind, which carries its own text verbatim. */
14
+ /** `sql` is set only for the `sql` kind, which carries its own text verbatim. */
15
15
  constructor(kind: SqlExpressionKind, sql?: string | undefined);
16
16
  static isExpression(value: unknown): value is SqlExpression;
17
17
  /** Wraps `sql` in parentheses, which every engine accepts for a default expression and SQLite and MySQL require. */
@@ -23,7 +23,7 @@ export declare class SqlExpression {
23
23
  * A default in schema form: a value uql exports (`currentTimestamp`) becomes its kind, so each engine spells it
24
24
  * for the column it fills; other `raw` becomes the SQL `compile` renders, parenthesized; a literal is kept.
25
25
  */
26
- export declare function schemaDefault(value: unknown, compile: (sql: QueryRaw) => string): unknown;
26
+ export declare function schemaDefault(value: unknown, compile: (sql: QuerySql) => string): unknown;
27
27
  /**
28
28
  * A default as text to compare: numbers as their digits, other text as written, and objects (SQL included) and text
29
29
  * holding a JSON object or list as JSON with its keys in order, equal as documents, since `jsonb` reprints them.
@@ -1,6 +1,6 @@
1
- import { QueryRaw, SQL_VALUE_NAMES } from '../type/index.js';
1
+ import { QuerySql, SQL_VALUE_NAMES } from '../type/index.js';
2
2
  import { isRecord } from '../util/object.util.js';
3
- import { SQL_VALUES } from '../util/raw.js';
3
+ import { SQL_VALUES } from '../util/sql.js';
4
4
  /**
5
5
  * A column default that is SQL rather than a literal, whether an entity or a migration declares it or
6
6
  * introspection reads it back. It is a class, not a plain object, so a JSON default cannot pass for one.
@@ -8,7 +8,7 @@ import { SQL_VALUES } from '../util/raw.js';
8
8
  export class SqlExpression {
9
9
  kind;
10
10
  sql;
11
- /** `sql` is set only for the `raw` kind, which carries its own text verbatim. */
11
+ /** `sql` is set only for the `sql` kind, which carries its own text verbatim. */
12
12
  constructor(kind, sql) {
13
13
  this.kind = kind;
14
14
  this.sql = sql;
@@ -18,7 +18,7 @@ export class SqlExpression {
18
18
  }
19
19
  /** Wraps `sql` in parentheses, which every engine accepts for a default expression and SQLite and MySQL require. */
20
20
  static parenthesized(sql) {
21
- return new SqlExpression('raw', `(${sql})`);
21
+ return new SqlExpression('sql', `(${sql})`);
22
22
  }
23
23
  /** Its SQL, or its kind, as diffs and drift reports show it. */
24
24
  toString() {
@@ -35,7 +35,7 @@ export function schemaDefault(value, compile) {
35
35
  if (name) {
36
36
  return new SqlExpression(name);
37
37
  }
38
- return value instanceof QueryRaw ? SqlExpression.parenthesized(compile(value)) : value;
38
+ return value instanceof QuerySql ? SqlExpression.parenthesized(compile(value)) : value;
39
39
  }
40
40
  /**
41
41
  * A default as text to compare: numbers as their digits, other text as written, and objects (SQL included) and text
@@ -1,7 +1,7 @@
1
1
  import { ANSI_SQL_VALUES, AbstractSqlDialect, } from '../dialect/abstractSqlDialect.js';
2
2
  import { BYTES_PREFIX } from '../dialect/hydrateColumn.js';
3
3
  import { chainedCall, groupsPerCall, jsonSetCall, jsonPath, jsonArraySlotArgs, jsonSlotArgs, } from '../dialect/jsonSql.js';
4
- import { QueryRaw, } from '../type/index.js';
4
+ import { QuerySql, } from '../type/index.js';
5
5
  import { indexDistance, isVectorIndexType } from '../type/vector.js';
6
6
  import { declaredIndexName } from '../util/ddlExpression.util.js';
7
7
  import { findVectorIndex, findVectorSort, textSearchFields, vectorCandidates } from '../util/dialect.util.js';
@@ -101,7 +101,7 @@ export class SqliteDialect extends AbstractSqlDialect {
101
101
  }
102
102
  const name = declaredIndexName(index.name, this.resolveTableName(meta), [{ column: colName }]);
103
103
  const table = this.escapeId(prefix ?? this.resolveTableAlias(meta), true, true);
104
- const nearest = new QueryRaw(({ ctx }) => {
104
+ const nearest = new QuerySql(({ ctx }) => {
105
105
  ctx.append(`${table}rowid IN (SELECT id FROM vector_top_k(`);
106
106
  ctx.addValue(name);
107
107
  ctx.append(', ');
@@ -1,7 +1,7 @@
1
1
  import type { EntityMeta, EntityPredicate, UpdatePayload } from './entity.js';
2
2
  import type { Query, QueryConflictPaths, QueryPage, QueryRenderOptions, QuerySearch, RelationQuery } from './query.js';
3
3
  import type { QueryAggMap, QueryAggregate, QueryAggregateOp, QueryGroupMap } from './queryAggregate.js';
4
- import type { QueryRawRenderOptions } from './queryRaw.js';
4
+ import type { QuerySqlRenderOptions } from './querySql.js';
5
5
  import type { QueryWhere } from './queryWhere.js';
6
6
  import type { Type } from './utility.js';
7
7
  import type { QueryVectorQuery } from './vector.js';
@@ -262,7 +262,7 @@ export type TriggerRows = {
262
262
  readonly where?: string;
263
263
  };
264
264
  /** Where DDL's SQL sits: the row a trigger's predicate reads, as its prefix, and a set-based body's rows. */
265
- export type DdlRenderOptions = Pick<QueryComparisonOptions, 'escapedPrefix' | 'operand'> & Pick<QueryRawRenderOptions, 'rows'>;
265
+ export type DdlRenderOptions = Pick<QueryComparisonOptions, 'escapedPrefix' | 'operand'> & Pick<QuerySqlRenderOptions, 'rows'>;
266
266
  /**
267
267
  * A write a trigger's body runs, as `insertInto`, `upsertInto`, `updateTable`, `deleteFrom` and `refuse` state
268
268
  * it. Held untyped here, past those helpers' typing, since the dialect renders it by the entity's metadata alone.
@@ -291,7 +291,7 @@ export type TriggerWrite = {
291
291
  readonly message: string;
292
292
  };
293
293
  /**
294
- * What a SQL statement is rendered through, as a `raw` callback and a query context see it:
294
+ * What a SQL statement is rendered through, as a `sql` callback and a query context see it:
295
295
  * `AbstractSqlDialect` is the one implementation.
296
296
  */
297
297
  export interface SqlQueryDialect {