@vibeorm/sql 4.0.0 → 4.2.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/ast.d.ts CHANGED
@@ -19,10 +19,11 @@ export type ColRef = {
19
19
  * Projection-only wire transform. `jsonText` uses the dialect's JSON text
20
20
  * projection to preserve SQL NULL versus the JSON document `null` before
21
21
  * driver parsing, without converting a postgres `json` column to `jsonb`.
22
- * The other transforms are postgres only. `castText` renders
23
- * `"col"::text AS "col"`, `encodeBase64` renders
24
- * `encode("col", 'base64') AS "col"`. Two users: the lateral subselect (SQL
25
- * review B3 — raw `to_jsonb` would ship BigInt/Decimal as float64 JSON
22
+ * `castText` renders a dialect text cast and preserves `alias ?? name`,
23
+ * including timestamp identity before driver Date truncation. PostgreSQL
24
+ * uses `"col"::text`; SQLite/MySQL use CAST AS TEXT/CHAR. `encodeBase64`
25
+ * is postgres-only and renders `encode("col", 'base64')`. Other users:
26
+ * the lateral subselect (SQL review B3: raw `to_jsonb` would ship BigInt/Decimal as float64 JSON
26
27
  * numbers and Bytes as `\x` hex text), and every row projection of a
27
28
  * `Float[]`/`Json[]` column (bun:sql's array parser refuses float arrays
28
29
  * printed with an exponent and json arrays holding integers beyond int32;
@@ -77,6 +78,8 @@ export type AggRef = {
77
78
  export type AggSelect = {
78
79
  readonly agg: AggRef;
79
80
  readonly alias: string;
81
+ /** Projection-only result cast; native aggregate comparisons and ordering stay typed. */
82
+ readonly castText?: true;
80
83
  };
81
84
  /**
82
85
  * JSON path predicates (Prisma's Json filter surface). `not` is `equals` with
@@ -467,6 +470,12 @@ export type KeyTableMember = {
467
470
  } | {
468
471
  readonly kind: "decimal";
469
472
  readonly scale: number;
473
+ }
474
+ /** MySQL-only lossless temporal operands in mixed collation-aware key tuples. */
475
+ | {
476
+ readonly kind: "timestamp";
477
+ } | {
478
+ readonly kind: "time";
470
479
  } | {
471
480
  readonly kind: "citext";
472
481
  } | {
@@ -641,7 +650,8 @@ export declare function excludedRef(params: {
641
650
  export declare function isExcludedRef(value: unknown): value is ExcludedRef;
642
651
  /**
643
652
  * One RETURNING column: a bare column name renders `"col"`; `castText` renders
644
- * `"col"::text AS "col"` (postgres only) for `Float[]`/`Json[]`. `jsonText`
653
+ * a dialect text cast (postgres `::text`, sqlite `CAST AS TEXT`) for lossless
654
+ * transport, including timestamps and postgres arrays. `jsonText`
645
655
  * applies the dialect's JSON text projection, as {@link ColRef.transform} does
646
656
  * for SELECT. Dialects without RETURNING still omit the clause and flag it.
647
657
  */
package/dist/dialect.d.ts CHANGED
@@ -93,6 +93,19 @@ export type ConflictKeyEquality = {
93
93
  */
94
94
  readonly duplicatesInOneStatement: "reject" | "lastWriteWins";
95
95
  };
96
+ /**
97
+ * How an INSERT that names no column renders, when every value is its column
98
+ * default. `defaultValues`: `INSERT INTO t DEFAULT VALUES`, exactly one row per
99
+ * statement; `conflictClause` says whether a conflict clause may follow it
100
+ * (postgres: yes; sqlite's grammar has no upsert clause after DEFAULT VALUES).
101
+ * `emptyRow`: `INSERT INTO t () VALUES ()`, any number of rows (mysql).
102
+ */
103
+ export type EmptyInsertSyntax = {
104
+ readonly form: "defaultValues";
105
+ readonly conflictClause: boolean;
106
+ } | {
107
+ readonly form: "emptyRow";
108
+ };
96
109
  export type SqlDialect = {
97
110
  readonly name: Dialect;
98
111
  /** Frozen feature table — consumed by runtime, migrate, generator, tests. */
@@ -230,6 +243,8 @@ export type SqlDialect = {
230
243
  * rows are grouped by column set into separate statements there (M4).
231
244
  */
232
245
  readonly rowDefaultKeyword: boolean;
246
+ /** How an INSERT that names no column renders ({@link EmptyInsertSyntax}). */
247
+ readonly emptyInsert: EmptyInsertSyntax;
233
248
  /**
234
249
  * How a {@link ChainStatement} (an ordered chain of read and data-modifying
235
250
  * steps ending in one SELECT — round-trip campaign EPIC 4/F) renders, or
@@ -54,6 +54,8 @@ export declare function renderMigrationSessionRestore(params: {
54
54
  * expressions as PostgreSQL itself deparses them (newline-joined so every
55
55
  * adapter decodes one plain text column), its partial predicate and the full
56
56
  * `pg_get_indexdef` text for the operator to read in an error message.
57
+ * Complete recovery also reads NULL uniqueness and lossless ordered JSON text
58
+ * for key and included definitions. PostgreSQL 16/17/18 expose these fields.
57
59
  *
58
60
  * `indisvalid = false` is the state a cancelled/failed concurrent build
59
61
  * leaves behind: the index exists, is skipped by the planner, and is still
@@ -0,0 +1,15 @@
1
+ import type { SqlDialect } from "../dialect.ts";
2
+ /**
3
+ * Compare both JSON trees by decoded key/index paths, node type and atomic value.
4
+ * Object order and JSON escape spelling do not matter; array positions do.
5
+ * Container nodes retain empty-object/array distinctions, and multiplicity stops
6
+ * duplicate object members from disappearing as they would in a set difference.
7
+ * SQL NULL remains unknown. The tree input is guarded against non-JSON scalar
8
+ * text even when SQLite evaluates this expression before the outer type guard.
9
+ */
10
+ export declare function renderSqliteJsonEquality(params: {
11
+ dialect: SqlDialect;
12
+ left: string;
13
+ right: string;
14
+ }): string;
15
+ //# sourceMappingURL=sqlite-json-equality.d.ts.map
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export { cloneTimestampDate, compareTimestampDates, timestampIdentityKey, timestampIdentityText } from "./timestamp-identity.ts";
1
2
  export { nativeEnumArrayParameter, isNativeEnumArrayParameter } from "./native-enum-parameter.ts";
2
3
  export type { NativeEnumArrayParameter } from "./native-enum-parameter.ts";
3
4
  export { isJsonListParameter, jsonListParameter } from "./json-list-parameter.ts";
@@ -19,6 +20,7 @@ export { MODULE_JOURNAL_COLUMN, renderModuleJournal } from "./module-journal.ts"
19
20
  export { renderSqliteFtsUpdateTrigger, sqliteFtsUpdateUpgrade } from "./dialects/sqlite-fts.ts";
20
21
  export { SQLITE_SESSION_SQL } from "./dialects/sqlite-session.ts";
21
22
  export { sql, isSqlFragment, renderSqlFragment, compileSql, sqlUsesIncoming, mapConflictColumns } from "./composable.ts";
23
+ export { registerSqlHandleCheck } from "./sql-handles.ts";
22
24
  export type { SqlFragment, SqlTag } from "./composable.ts";
23
25
  export { createSqlQuery, createSqlCommand, isSqlQuery, isSqlCommand, compileSqlQuery, compileSqlCommand } from "./query-plan.ts";
24
26
  export type { SqlQuery, SqlCommand, SqlPlanRender, CompiledSqlQuery, CompiledSqlCommand, ReusableSqlQuery, ReusableSqlCommand } from "./query-plan.ts";
@@ -27,7 +29,7 @@ export { isSqlParam, createSqlInput, sqlInputContract, createSqlInputScope, seal
27
29
  export type { SqlParam, SqlInput, SqlInputMap, SqlInputValue, SqlInputValues, SqlInputTokens, SqlExecutionParams, SqlInputContract, SqlInputScope } from "./sql-input.ts";
28
30
  export { isSqlBindingCollector, recordSqlBinding, recordSqlBindingCheck } from "./sql-bindings.ts";
29
31
  export type { SqlBindingSource, SqlParameterTransport, SqlBindingEncoder } from "./sql-bindings.ts";
30
- export { decode, encode, resultScalarContract } from "./result-decoder.ts";
32
+ export { decode, encode, resultScalarContract, sameResultDecoder } from "./result-decoder.ts";
31
33
  export type { ResultDecoder, ResultReadDecoder, ResultParameterEncoder, ResultScalarContract, Decoded, ExtendedDateTime } from "./result-decoder.ts";
32
34
  /**
33
35
  * @vibeorm/sql — dialect-aware SQL layer for VibeORM v2.
@@ -38,7 +40,7 @@ export type { ResultDecoder, ResultReadDecoder, ResultParameterEncoder, ResultSc
38
40
  export { compileExclusion, renderExclusionSetup, renderExclusionDdl, renderExclusionCatalog, renderExclusionProbe } from "./exclusion.ts";
39
41
  export type { AdvisoryLockKey, AdvisoryLockStatement, AggFn, AggRef, AggSelect, ChainResult, ChainRowSource, ChainStatement, ChainStep, ChainStepStatement, ChainTally, ChainVeto, ColRef, ComparisonOp, CountSubquery, DeleteStatement, ExcludedRef, InnerJoin, KeyTableJoin, KeyTableMember, InsertSelectStatement, InsertStatement, ReturningColumn, JsonFilterOp, LateralJoin, ListSetOperation, OnConflictClause, OnConflictDoNothing, OnConflictUpdate, OrderByAggregate, OrderByColumn, OrderBySubquery, OrderTerm, RowLock, RowNumberProjection, DbNowMarker, JsonParamCell, SelectExpr, SelectStatement, SetOperation, SetOperator, SqlExpr, SqlStatement, StepColumnRef, TableRef, UpdateStatement, } from "./ast.ts";
40
42
  export { ADVISORY_LOCK_RESULT_COLUMN, CHAIN_VETO_PREFIX, CHAIN_VETO_TOKEN_PATTERN, SQL_DEFAULT_CELL, chainVetoToken, dbNowMarker, excludedRef, isDbNowMarker, isExcludedRef, isJsonParamCell, isListSetOperation, isSetOperation, isSqlDefaultCell, isStepColumnRef, jsonParamCell, returningColumnName, stepColumnRef, } from "./ast.ts";
41
- export type { AdvisoryLockFunctions, AdvisoryLockModeFunctions, RowLockSyntax, SqlDialect, } from "./dialect.ts";
43
+ export type { AdvisoryLockFunctions, AdvisoryLockModeFunctions, RowLockSyntax, EmptyInsertSyntax, SqlDialect, } from "./dialect.ts";
42
44
  export { ADVISORY_KEY_BOUNDS, describeRowLock, renderAdvisoryLock, renderRowLockClause } from "./locks.ts";
43
45
  export { JSON_TRANSPORT, projectionOutputName } from "./json-transport.ts";
44
46
  export { postgresDialect } from "./dialects/postgres.ts";