@prisma/orm-sqlite 8.0.0-rc.18-dev.30 → 8.0.0-rc.18-dev.32

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.
@@ -201,6 +201,12 @@ declare const enumType: BoundEnumType<{
201
201
  readonly json: import("@prisma/orm-framework/contract/types").JsonValue;
202
202
  readonly traits: "equality" | "order" | "numeric";
203
203
  }, "traits" | "output" | "input">;
204
+ readonly "sql/raw@1": Pick<{
205
+ readonly input: unknown;
206
+ readonly output: unknown;
207
+ readonly json: import("@prisma/orm-framework/contract/types").JsonValue;
208
+ readonly traits: never;
209
+ }, "traits" | "output" | "input">;
204
210
  }>;
205
211
  //#endregion
206
212
  //#region src/contract/gen.d.ts
@@ -1 +1 @@
1
- {"version":3,"file":"contract-builder.d.mts","names":[],"sources":["../../../../3-extensions/sqlite/dist/contract-builder.d.mts"],"mappings":";;;;;;;;;;;KAUK,mBAAmB;KACnB,oBAAoB;KACpB,kBAAkB,eAAe;KACjC,mBAAmB,eAAe;KAClC,kBAAkB,eAAe;KACjC,+BAA+B;;KAE/B,uBAAuB;KACvB,aAAa,cAAc,iBAAiB,eAAe,kBAAkB,mBAAmB,eAAe,8CAA8C,cAAc,iBAAiB,2BAA2B,4CAA4C,kBAAkB,mBAAmB,WAAW;WAC7S,QAAQ;WACR,SAAS;WACT,aAAa;WACb,QAAQ;WACR,SAAS;WACT,qBAAqB;WACrB,kBAAkB,OAAO,sBAAsB;WAC/C,aAAa;WACb,gBAAgB;;KAEtB,mBAAmB,mBAAmB,eAAe,8CAA8C,2BAA2B,4CAA4C,KAAK,gBAAgB,WAAW,YAAY,sBAAsB,sBAAsB;;WAE5P,qBAAqB;;WAErB,cAAc;;WAEd,iBAAiB;;KAEvB,iBAAiB,cAAc,iBAAiB,eAAe,kBAAkB,mBAAmB,eAAe,8CAA8C,cAAc,iBAAiB,2BAA2B,gCAAgC,mBAAmB,YAAY;WACpR,QAAQ;WACR,SAAS;WACT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uBAAuB,2BAA2B,cAAc,KAAK,wCAAwC,0BAA0B,mBAAmB,WAAW,YAAY,YAAY,mBAAmB,WAAW,YAAY,YAAY,MAAM,MAAM,OAAO,UAAU,SAAS,YAAY,iBAAiB,MAAM,oBAAoB,WAAW,mBAAmB,WAAW,uBAAuB,WAAW;;;;cAInb,UAAU;WACb,cAAc;aACZ;aACA;aACA,yCAAyC;aACzC;;WAEF,iBAAiB;aACf;aACA;aACA,yCAAyC;aACzC;;WAEF,aAAa;aACX;aACA;aACA,yCAAyC;aACzC;;WAEF,eAAe;aACb;aACA;aACA,yCAAyC;aACzC;;WAEF,iBAAiB;aACf;aACA;aACA,yCAAyC;aACzC;;WAEF,oBAAoB;aAClB;aACA;aACA,yCAAyC;aACzC;;WAEF,iBAAiB;aACf;aACA;aACA,yCAAyC;aACzC;;WAEF,iBAAiB;aACf,OAAO,WAAW;aAClB,QAAQ,WAAW;aACnB,yCAAyC;aACzC;;WAEF,qBAAqB;aACnB,OAAO;aACP,QAAQ;aACR,yCAAyC;aACzC;;WAEF,iBAAiB;aACf,0CAA0C;aAC1C,2CAA2C;aAC3C,yCAAyC;aACzC;;WAEF,mBAAmB;aACjB;aACA;aACA,yCAAyC;aACzC;;WAEF,yBAAyB;aACvB;aACA;aACA,yCAAyC;aACzC;;;;;;;;cAQC,KAAK,kCAAkC,sBAAsB"}
1
+ {"version":3,"file":"contract-builder.d.mts","names":[],"sources":["../../../../3-extensions/sqlite/dist/contract-builder.d.mts"],"mappings":";;;;;;;;;;;KAUK,mBAAmB;KACnB,oBAAoB;KACpB,kBAAkB,eAAe;KACjC,mBAAmB,eAAe;KAClC,kBAAkB,eAAe;KACjC,+BAA+B;;KAE/B,uBAAuB;KACvB,aAAa,cAAc,iBAAiB,eAAe,kBAAkB,mBAAmB,eAAe,8CAA8C,cAAc,iBAAiB,2BAA2B,4CAA4C,kBAAkB,mBAAmB,WAAW;WAC7S,QAAQ;WACR,SAAS;WACT,aAAa;WACb,QAAQ;WACR,SA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sBAAsB"}
package/dist/runtime.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { i as validateSqliteContract, t as buildSqliteStaticContext } from "./sqlite-static-ChY34tsf-Dkdgx_nX.mjs";
1
+ import { i as validateSqliteContract, t as buildSqliteStaticContext } from "./sqlite-static-FIzNnSBq-zXmUb8TI.mjs";
2
2
  import { ifDefined } from "@prisma/orm-framework/utils/defined";
3
3
  import sqliteAdapter from "@prisma/orm-target-sqlite/adapter/runtime";
4
4
  import { UNBOUND_NAMESPACE_ID } from "@prisma/orm-framework/components/ir";
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.mjs","names":[],"sources":["../../../../3-extensions/sqlite/dist/runtime.mjs"],"sourcesContent":["import { i as validateSqliteContract, t as buildSqliteStaticContext } from \"./sqlite-static-ChY34tsf.mjs\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport sqliteAdapter from \"@internal/adapter-sqlite/runtime\";\nimport sqliteDriver from \"@internal/driver-sqlite/runtime\";\nimport { instantiateExecutionStack } from \"@internal/framework-components/execution\";\nimport { UNBOUND_NAMESPACE_ID } from \"@internal/framework-components/ir\";\nimport { sql } from \"@internal/sql-builder/runtime\";\nimport { orm, prepareQuery } from \"@internal/sql-orm-client\";\nimport { SqlRuntimeBase, activitySource, createExecutionContext, createSqlExecutionStack, delegatingActivitySource, withTransaction } from \"@internal/sql-runtime\";\nimport sqliteTarget from \"@internal/target-sqlite/runtime\";\nimport { assertDefined } from \"@internal/utils/assertions\";\nimport { blindCast, castAs } from \"@internal/utils/casts\";\nimport { InternalError } from \"@internal/utils/internal-error\";\nimport { structuredError } from \"@internal/utils/structured-error\";\n//#region src/errors.ts\nfunction sqliteError(code, message, options) {\n\treturn structuredError(code, message, options);\n}\n//#endregion\n//#region src/runtime/binding.ts\nfunction resolveSqliteBinding(input) {\n\treturn {\n\t\tkind: \"path\",\n\t\tpath: input.path\n\t};\n}\nfunction resolveOptionalSqliteBinding(options) {\n\tif (options.path === void 0) return;\n\treturn {\n\t\tkind: \"path\",\n\t\tpath: options.path\n\t};\n}\n//#endregion\n//#region src/runtime/sqlite-runtime.ts\nvar SqliteRuntimeImpl = class extends SqlRuntimeBase {};\n//#endregion\n//#region src/runtime/sqlite.ts\nfunction unboundOrm(orm) {\n\tconst value = orm[UNBOUND_NAMESPACE_ID];\n\tassertDefined(value, \"the unbound namespace always exists on a sqlite builder output\");\n\treturn blindCast(value);\n}\n/**\n* Creates a lazy SQLite client. The client infers its contract type from `contract`: a value from\n* `contractFromJson` for an emitted contract, or a TypeScript-authored contract. A contract is\n* validated once, however many clients are built from it. The database opens on the first query\n* or `connect()`.\n*\n* @example\n* ```ts\n* import { contractFromJson } from '@prisma/orm-sqlite/static';\n* import sqlite from '@prisma/orm-sqlite/runtime';\n* import type { Contract } from './contract.d';\n* import contractJson from './contract.json' with { type: 'json' };\n*\n* export const contract = contractFromJson<Contract>(contractJson);\n* export const db = sqlite({ contract, path: './dev.db' });\n* ```\n*/\nfunction sqlite(options) {\n\tconst contract = validateSqliteContract(options.contract);\n\tlet binding = resolveOptionalSqliteBinding(options);\n\tconst stack = createSqlExecutionStack({\n\t\ttarget: sqliteTarget,\n\t\tadapter: sqliteAdapter,\n\t\tdriver: sqliteDriver,\n\t\textensions: options.extensions ?? []\n\t});\n\tconst context = createExecutionContext({\n\t\tcontract,\n\t\tstack,\n\t\tdriver: sqliteDriver\n\t});\n\tconst { sql: sql$1, raw: rawSqlTag, enums } = buildSqliteStaticContext(contract, context, stack.adapter.rawCodecInferer);\n\tlet runtimeInstance;\n\tlet runtimeDriver;\n\tlet driverConnected = false;\n\tlet connectPromise;\n\tlet closePromise;\n\tlet backgroundConnectError;\n\tlet closed = false;\n\tlet ownedDispose;\n\tconst connectDriver = async (resolvedBinding) => {\n\t\tif (driverConnected) return;\n\t\tif (!runtimeDriver) throw new InternalError(\"SQLite runtime driver missing\");\n\t\tif (connectPromise) return connectPromise;\n\t\tconnectPromise = runtimeDriver.connect(resolvedBinding).then(() => {\n\t\t\tdriverConnected = true;\n\t\t}).catch((err) => {\n\t\t\tbackgroundConnectError = err;\n\t\t\tconnectPromise = void 0;\n\t\t\tthrow err;\n\t\t});\n\t\treturn connectPromise;\n\t};\n\tconst getRuntime = () => {\n\t\tif (closed) throw sqliteError(\"DRIVER.NOT_CONNECTED\", \"SQLite client is closed\", { meta: { extension: \"sqlite\" } });\n\t\tif (backgroundConnectError !== void 0) throw backgroundConnectError;\n\t\tif (runtimeInstance) return runtimeInstance;\n\t\tconst stackInstance = instantiateExecutionStack(stack);\n\t\tconst driverDescriptor = stack.driver;\n\t\tif (!driverDescriptor) throw new InternalError(\"Driver descriptor missing from execution stack\");\n\t\tconst driver = driverDescriptor.create();\n\t\townedDispose = () => driver.close();\n\t\truntimeDriver = driver;\n\t\tif (binding !== void 0) connectDriver(binding).catch(() => void 0);\n\t\truntimeInstance = new SqliteRuntimeImpl({\n\t\t\tcontext,\n\t\t\tadapter: stackInstance.adapter,\n\t\t\tdriver,\n\t\t\t...ifDefined(\"verifyMarker\", options.verifyMarker),\n\t\t\t...ifDefined(\"middleware\", options.middleware),\n\t\t\t...ifDefined(\"log\", options.log),\n\t\t\tcloseRefusal: \"at-once\"\n\t\t});\n\t\treturn runtimeInstance;\n\t};\n\tconst orm$1 = unboundOrm(orm({\n\t\tcontext,\n\t\t...ifDefined(\"collections\", options.collections),\n\t\truntime: {\n\t\t\tquery(plan) {\n\t\t\t\treturn getRuntime().query(plan);\n\t\t\t},\n\t\t\texecute(plan) {\n\t\t\t\treturn getRuntime().execute(plan);\n\t\t\t},\n\t\t\tconnection() {\n\t\t\t\treturn getRuntime().connection();\n\t\t\t},\n\t\t\t[activitySource]: delegatingActivitySource(() => getRuntime())\n\t\t}\n\t}));\n\tfunction prepare(declaration, callback) {\n\t\treturn prepareQuery(getRuntime(), declaration, callback);\n\t}\n\treturn {\n\t\tsql: sql$1,\n\t\torm: orm$1,\n\t\tenums,\n\t\traw: rawSqlTag,\n\t\tcontext,\n\t\tcontract,\n\t\tstack,\n\t\tasync connect(bindingInput) {\n\t\t\tif (closed) throw sqliteError(\"DRIVER.NOT_CONNECTED\", \"SQLite client is closed\", { meta: { extension: \"sqlite\" } });\n\t\t\tif (driverConnected || connectPromise) throw sqliteError(\"DRIVER.ALREADY_CONNECTED\", \"SQLite client already connected\", { meta: { extension: \"sqlite\" } });\n\t\t\tbackgroundConnectError = void 0;\n\t\t\tif (bindingInput !== void 0) binding = resolveSqliteBinding(bindingInput);\n\t\t\tif (binding === void 0) throw sqliteError(\"RUNTIME.BINDING_MISSING\", \"SQLite binding not configured. Pass path to sqlite(...) or call db.connect({ path }).\", { meta: { extension: \"sqlite\" } });\n\t\t\tconst runtime = getRuntime();\n\t\t\tif (driverConnected) return runtime;\n\t\t\tawait connectDriver(binding);\n\t\t\treturn runtime;\n\t\t},\n\t\truntime() {\n\t\t\treturn getRuntime();\n\t\t},\n\t\tprepare,\n\t\ttransaction(fn) {\n\t\t\tlet runtime;\n\t\t\ttry {\n\t\t\t\truntime = getRuntime();\n\t\t\t} catch (err) {\n\t\t\t\treturn Promise.reject(err);\n\t\t\t}\n\t\t\treturn withTransaction(runtime, (txCtx) => {\n\t\t\t\tconst rawCodecInferer = stack.adapter.rawCodecInferer;\n\t\t\t\tconst txSqlNamespace = sql({\n\t\t\t\t\tcontext,\n\t\t\t\t\trawCodecInferer\n\t\t\t\t})[UNBOUND_NAMESPACE_ID];\n\t\t\t\tassertDefined(txSqlNamespace, \"the unbound namespace always exists on a sqlite builder output\");\n\t\t\t\tconst txSql = blindCast(txSqlNamespace);\n\t\t\t\tconst txOrm = unboundOrm(orm({\n\t\t\t\t\truntime: {\n\t\t\t\t\t\tquery(plan) {\n\t\t\t\t\t\t\treturn txCtx.query(plan);\n\t\t\t\t\t\t},\n\t\t\t\t\t\texecute(plan) {\n\t\t\t\t\t\t\treturn txCtx.execute(plan);\n\t\t\t\t\t\t},\n\t\t\t\t\t\t[activitySource]: delegatingActivitySource(() => txCtx)\n\t\t\t\t\t},\n\t\t\t\t\tcontext,\n\t\t\t\t\t...ifDefined(\"collections\", options.collections)\n\t\t\t\t}));\n\t\t\t\treturn fn(Object.assign(castAs(Object.create(txCtx)), {\n\t\t\t\t\tsql: txSql,\n\t\t\t\t\torm: txOrm,\n\t\t\t\t\tenums\n\t\t\t\t}));\n\t\t\t});\n\t\t},\n\t\tclose() {\n\t\t\tif (closePromise) return closePromise;\n\t\t\tclosed = true;\n\t\t\tclosePromise = (async () => {\n\t\t\t\tawait connectPromise?.catch(() => void 0);\n\t\t\t\tawait ownedDispose?.();\n\t\t\t})();\n\t\t\treturn closePromise;\n\t\t},\n\t\t[Symbol.asyncDispose]() {\n\t\t\treturn this.close();\n\t\t}\n\t};\n}\n//#endregion\nexport { SqliteRuntimeImpl, sqlite as default };\n\n//# sourceMappingURL=runtime.mjs.map"],"mappings":";;;;;;;;;;;;;;;AAeA,SAAS,YAAY,MAAM,SAAS,SAAS;CAC5C,OAAO,gBAAgB,MAAM,SAAS,OAAO;AAC9C;AAGA,SAAS,qBAAqB,OAAO;CACpC,OAAO;EACN,MAAM;EACN,MAAM,MAAM;CACb;AACD;AACA,SAAS,6BAA6B,SAAS;CAC9C,IAAI,QAAQ,SAAS,KAAK,GAAG;CAC7B,OAAO;EACN,MAAM;EACN,MAAM,QAAQ;CACf;AACD;AAGA,IAAI,oBAAoB,cAAc,eAAe,CAAC;AAGtD,SAAS,WAAW,KAAK;CACxB,MAAM,QAAQ,IAAI;CAClB,cAAc,OAAO,gEAAgE;CACrF,OAAO,UAAU,KAAK;AACvB;;;;;;;;;;;;;;;;;;AAkBA,SAAS,OAAO,SAAS;CACxB,MAAM,WAAW,uBAAuB,QAAQ,QAAQ;CACxD,IAAI,UAAU,6BAA6B,OAAO;CAClD,MAAM,QAAQ,wBAAwB;EACrC,QAAQ;EACR,SAAS;EACT,QAAQ;EACR,YAAY,QAAQ,cAAc,CAAC;CACpC,CAAC;CACD,MAAM,UAAU,uBAAuB;EACtC;EACA;EACA,QAAQ;CACT,CA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,MAAM,QAAQ,WAAW,IAAI;KAC5B,SAAS;MACR,MAAM,MAAM;OACX,OAAO,MAAM,MAAM,IAAI;MACxB;MACA,QAAQ,MAAM;OACb,OAAO,MAAM,QAAQ,IAAI;MAC1B;OACC,iBAAiB,+BAA+B,KAAK;KACvD;KACA;KACA,GAAG,UAAU,eAAe,QAAQ,WAAW;IAChD,CAAC,CAAC;IACF,OAAO,GAAG,OAAO,OAAO,OAAO,OAAO,OAAO,KAAK,CAAC,GAAG;KACrD,KAAK;KACL,KAAK;KACL;IACD,CAAC,CAAC;GACH,CAAC;EACF;EACA,QAAQ;GACP,IAAI,cAAc,OAAO;GACzB,SAAS;GACT,gBAAgB,YAAY;IAC3B,MAAM,gBAAgB,YAAY,KAAK,CAAC;IACxC,MAAM,eAAe;GACtB,EAAA,CAAG;GACH,OAAO;EACR;EACA,CAAC,OAAO,gBAAgB;GACvB,OAAO,KAAK,MAAM;EACnB;CACD;AACD"}
1
+ {"version":3,"file":"runtime.mjs","names":[],"sources":["../../../../3-extensions/sqlite/dist/runtime.mjs"],"sourcesContent":["import { i as validateSqliteContract, t as buildSqliteStaticContext } from \"./sqlite-static-FIzNnSBq.mjs\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport sqliteAdapter from \"@internal/adapter-sqlite/runtime\";\nimport sqliteDriver from \"@internal/driver-sqlite/runtime\";\nimport { instantiateExecutionStack } from \"@internal/framework-components/execution\";\nimport { UNBOUND_NAMESPACE_ID } from \"@internal/framework-components/ir\";\nimport { sql } from \"@internal/sql-builder/runtime\";\nimport { orm, prepareQuery } from \"@internal/sql-orm-client\";\nimport { SqlRuntimeBase, activitySource, createExecutionContext, createSqlExecutionStack, delegatingActivitySource, withTransaction } from \"@internal/sql-runtime\";\nimport sqliteTarget from \"@internal/target-sqlite/runtime\";\nimport { assertDefined } from \"@internal/utils/assertions\";\nimport { blindCast, castAs } from \"@internal/utils/casts\";\nimport { InternalError } from \"@internal/utils/internal-error\";\nimport { structuredError } from \"@internal/utils/structured-error\";\n//#region src/errors.ts\nfunction sqliteError(code, message, options) {\n\treturn structuredError(code, message, options);\n}\n//#endregion\n//#region src/runtime/binding.ts\nfunction resolveSqliteBinding(input) {\n\treturn {\n\t\tkind: \"path\",\n\t\tpath: input.path\n\t};\n}\nfunction resolveOptionalSqliteBinding(options) {\n\tif (options.path === void 0) return;\n\treturn {\n\t\tkind: \"path\",\n\t\tpath: options.path\n\t};\n}\n//#endregion\n//#region src/runtime/sqlite-runtime.ts\nvar SqliteRuntimeImpl = class extends SqlRuntimeBase {};\n//#endregion\n//#region src/runtime/sqlite.ts\nfunction unboundOrm(orm) {\n\tconst value = orm[UNBOUND_NAMESPACE_ID];\n\tassertDefined(value, \"the unbound namespace always exists on a sqlite builder output\");\n\treturn blindCast(value);\n}\n/**\n* Creates a lazy SQLite client. The client infers its contract type from `contract`: a value from\n* `contractFromJson` for an emitted contract, or a TypeScript-authored contract. A contract is\n* validated once, however many clients are built from it. The database opens on the first query\n* or `connect()`.\n*\n* @example\n* ```ts\n* import { contractFromJson } from '@prisma/orm-sqlite/static';\n* import sqlite from '@prisma/orm-sqlite/runtime';\n* import type { Contract } from './contract.d';\n* import contractJson from './contract.json' with { type: 'json' };\n*\n* export const contract = contractFromJson<Contract>(contractJson);\n* export const db = sqlite({ contract, path: './dev.db' });\n* ```\n*/\nfunction sqlite(options) {\n\tconst contract = validateSqliteContract(options.contract);\n\tlet binding = resolveOptionalSqliteBinding(options);\n\tconst stack = createSqlExecutionStack({\n\t\ttarget: sqliteTarget,\n\t\tadapter: sqliteAdapter,\n\t\tdriver: sqliteDriver,\n\t\textensions: options.extensions ?? []\n\t});\n\tconst context = createExecutionContext({\n\t\tcontract,\n\t\tstack,\n\t\tdriver: sqliteDriver\n\t});\n\tconst { sql: sql$1, raw: rawSqlTag, enums } = buildSqliteStaticContext(contract, context, stack.adapter.rawCodecInferer);\n\tlet runtimeInstance;\n\tlet runtimeDriver;\n\tlet driverConnected = false;\n\tlet connectPromise;\n\tlet closePromise;\n\tlet backgroundConnectError;\n\tlet closed = false;\n\tlet ownedDispose;\n\tconst connectDriver = async (resolvedBinding) => {\n\t\tif (driverConnected) return;\n\t\tif (!runtimeDriver) throw new InternalError(\"SQLite runtime driver missing\");\n\t\tif (connectPromise) return connectPromise;\n\t\tconnectPromise = runtimeDriver.connect(resolvedBinding).then(() => {\n\t\t\tdriverConnected = true;\n\t\t}).catch((err) => {\n\t\t\tbackgroundConnectError = err;\n\t\t\tconnectPromise = void 0;\n\t\t\tthrow err;\n\t\t});\n\t\treturn connectPromise;\n\t};\n\tconst getRuntime = () => {\n\t\tif (closed) throw sqliteError(\"DRIVER.NOT_CONNECTED\", \"SQLite client is closed\", { meta: { extension: \"sqlite\" } });\n\t\tif (backgroundConnectError !== void 0) throw backgroundConnectError;\n\t\tif (runtimeInstance) return runtimeInstance;\n\t\tconst stackInstance = instantiateExecutionStack(stack);\n\t\tconst driverDescriptor = stack.driver;\n\t\tif (!driverDescriptor) throw new InternalError(\"Driver descriptor missing from execution stack\");\n\t\tconst driver = driverDescriptor.create();\n\t\townedDispose = () => driver.close();\n\t\truntimeDriver = driver;\n\t\tif (binding !== void 0) connectDriver(binding).catch(() => void 0);\n\t\truntimeInstance = new SqliteRuntimeImpl({\n\t\t\tcontext,\n\t\t\tadapter: stackInstance.adapter,\n\t\t\tdriver,\n\t\t\t...ifDefined(\"verifyMarker\", options.verifyMarker),\n\t\t\t...ifDefined(\"middleware\", options.middleware),\n\t\t\t...ifDefined(\"log\", options.log),\n\t\t\tcloseRefusal: \"at-once\"\n\t\t});\n\t\treturn runtimeInstance;\n\t};\n\tconst orm$1 = unboundOrm(orm({\n\t\tcontext,\n\t\t...ifDefined(\"collections\", options.collections),\n\t\truntime: {\n\t\t\tquery(plan) {\n\t\t\t\treturn getRuntime().query(plan);\n\t\t\t},\n\t\t\texecute(plan) {\n\t\t\t\treturn getRuntime().execute(plan);\n\t\t\t},\n\t\t\tconnection() {\n\t\t\t\treturn getRuntime().connection();\n\t\t\t},\n\t\t\t[activitySource]: delegatingActivitySource(() => getRuntime())\n\t\t}\n\t}));\n\tfunction prepare(declaration, callback) {\n\t\treturn prepareQuery(getRuntime(), declaration, callback);\n\t}\n\treturn {\n\t\tsql: sql$1,\n\t\torm: orm$1,\n\t\tenums,\n\t\traw: rawSqlTag,\n\t\tcontext,\n\t\tcontract,\n\t\tstack,\n\t\tasync connect(bindingInput) {\n\t\t\tif (closed) throw sqliteError(\"DRIVER.NOT_CONNECTED\", \"SQLite client is closed\", { meta: { extension: \"sqlite\" } });\n\t\t\tif (driverConnected || connectPromise) throw sqliteError(\"DRIVER.ALREADY_CONNECTED\", \"SQLite client already connected\", { meta: { extension: \"sqlite\" } });\n\t\t\tbackgroundConnectError = void 0;\n\t\t\tif (bindingInput !== void 0) binding = resolveSqliteBinding(bindingInput);\n\t\t\tif (binding === void 0) throw sqliteError(\"RUNTIME.BINDING_MISSING\", \"SQLite binding not configured. Pass path to sqlite(...) or call db.connect({ path }).\", { meta: { extension: \"sqlite\" } });\n\t\t\tconst runtime = getRuntime();\n\t\t\tif (driverConnected) return runtime;\n\t\t\tawait connectDriver(binding);\n\t\t\treturn runtime;\n\t\t},\n\t\truntime() {\n\t\t\treturn getRuntime();\n\t\t},\n\t\tprepare,\n\t\ttransaction(fn) {\n\t\t\tlet runtime;\n\t\t\ttry {\n\t\t\t\truntime = getRuntime();\n\t\t\t} catch (err) {\n\t\t\t\treturn Promise.reject(err);\n\t\t\t}\n\t\t\treturn withTransaction(runtime, (txCtx) => {\n\t\t\t\tconst rawCodecInferer = stack.adapter.rawCodecInferer;\n\t\t\t\tconst txSqlNamespace = sql({\n\t\t\t\t\tcontext,\n\t\t\t\t\trawCodecInferer\n\t\t\t\t})[UNBOUND_NAMESPACE_ID];\n\t\t\t\tassertDefined(txSqlNamespace, \"the unbound namespace always exists on a sqlite builder output\");\n\t\t\t\tconst txSql = blindCast(txSqlNamespace);\n\t\t\t\tconst txOrm = unboundOrm(orm({\n\t\t\t\t\truntime: {\n\t\t\t\t\t\tquery(plan) {\n\t\t\t\t\t\t\treturn txCtx.query(plan);\n\t\t\t\t\t\t},\n\t\t\t\t\t\texecute(plan) {\n\t\t\t\t\t\t\treturn txCtx.execute(plan);\n\t\t\t\t\t\t},\n\t\t\t\t\t\t[activitySource]: delegatingActivitySource(() => txCtx)\n\t\t\t\t\t},\n\t\t\t\t\tcontext,\n\t\t\t\t\t...ifDefined(\"collections\", options.collections)\n\t\t\t\t}));\n\t\t\t\treturn fn(Object.assign(castAs(Object.create(txCtx)), {\n\t\t\t\t\tsql: txSql,\n\t\t\t\t\torm: txOrm,\n\t\t\t\t\tenums\n\t\t\t\t}));\n\t\t\t});\n\t\t},\n\t\tclose() {\n\t\t\tif (closePromise) return closePromise;\n\t\t\tclosed = true;\n\t\t\tclosePromise = (async () => {\n\t\t\t\tawait connectPromise?.catch(() => void 0);\n\t\t\t\tawait ownedDispose?.();\n\t\t\t})();\n\t\t\treturn closePromise;\n\t\t},\n\t\t[Symbol.asyncDispose]() {\n\t\t\treturn this.close();\n\t\t}\n\t};\n}\n//#endregion\nexport { SqliteRuntimeImpl, sqlite as default };\n\n//# sourceMappingURL=runtime.mjs.map"],"mappings":";;;;;;;;;;;;;;;AAeA,SAAS,YAAY,MAAM,SAAS,SAAS;CAC5C,OAAO,gBAAgB,MAAM,SAAS,OAAO;AAC9C;AAGA,SAAS,qBAAqB,OAAO;CACpC,OAAO;EACN,MAAM;EACN,MAAM,MAAM;CACb;AACD;AACA,SAAS,6BAA6B,SAAS;CAC9C,IAAI,QAAQ,SAAS,KAAK,GAAG;CAC7B,OAAO;EACN,MAAM;EACN,MAAM,QAAQ;CACf;AACD;AAGA,IAAI,oBAAoB,cAAc,eAAe,CAAC;AAGtD,SAAS,WAAW,KAAK;CACxB,MAAM,QAAQ,IAAI;CAClB,cAAc,OAAO,gEAAgE;CACrF,OAAO,UAAU,KAAK;AACvB;;;;;;;;;;;;;;;;;;AAkBA,SAAS,OAAO,SAAS;CAC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K;IACb,OAAO,QAAQ,OAAO,GAAG;GAC1B;GACA,OAAO,gBAAgB,UAAU,UAAU;IAC1C,MAAM,kBAAkB,MAAM,QAAQ;IACtC,MAAM,iBAAiB,IAAI;KAC1B;KACA;IACD,CAAC,CAAC,CAAC;IACH,cAAc,gBAAgB,gEAAgE;IAC9F,MAAM,QAAQ,UAAU,cAAc;IACtC,MAAM,QAAQ,WAAW,IAAI;KAC5B,SAAS;MACR,MAAM,MAAM;OACX,OAAO,MAAM,MAAM,IAAI;MACxB;MACA,QAAQ,MAAM;OACb,OAAO,MAAM,QAAQ,IAAI;MAC1B;OACC,iBAAiB,+BAA+B,KAAK;KACvD;KACA;KACA,GAAG,UAAU,eAAe,QAAQ,WAAW;IAChD,CAAC,CAAC;IACF,OAAO,GAAG,OAAO,OAAO,OAAO,OAAO,OAAO,KAAK,CAAC,GAAG;KACrD,KAAK;KACL,KAAK;KACL;IACD,CAAC,CAAC;GACH,CAAC;EACF;EACA,QAAQ;GACP,IAAI,cAAc,OAAO;GACzB,SAAS;GACT,gBAAgB,YAAY;IAC3B,MAAM,gBAAgB,YAAY,KAAK,CAAC;IACxC,MAAM,eAAe;GACtB,EAAA,CAAG;GACH,OAAO;EACR;EACA,CAAC,OAAO,gBAAgB;GACvB,OAAO,KAAK,MAAM;EACnB;CACD;AACD"}
@@ -7,8 +7,8 @@ import { assertDefined } from "@prisma/orm-framework/utils/assertions";
7
7
  import { blindCast } from "@prisma/orm-framework/utils/casts";
8
8
  import { validateContractOnce } from "@prisma/orm-framework/contract/validate-once";
9
9
  import { buildNamespacedEnums } from "@prisma/orm-framework/contract/enum-accessor";
10
- //#region ../../../3-extensions/sqlite/dist/sqlite-static-ChY34tsf.mjs
11
- var version = "8.0.0-rc.18-dev.30";
10
+ //#region ../../../3-extensions/sqlite/dist/sqlite-static-FIzNnSBq.mjs
11
+ var version = "8.0.0-rc.18-dev.32";
12
12
  const serializer = new SqliteContractSerializer();
13
13
  const validator = `${sqliteTarget.targetId}@${version}`;
14
14
  /**
@@ -78,4 +78,4 @@ function sqliteStatic(options) {
78
78
  //#endregion
79
79
  export { validateSqliteContract as i, contractFromJson as n, sqliteStatic as r, buildSqliteStaticContext as t };
80
80
 
81
- //# sourceMappingURL=sqlite-static-ChY34tsf-Dkdgx_nX.mjs.map
81
+ //# sourceMappingURL=sqlite-static-FIzNnSBq-zXmUb8TI.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"sqlite-static-ChY34tsf-Dkdgx_nX.mjs","names":[],"sources":["../../../../3-extensions/sqlite/dist/sqlite-static-ChY34tsf.mjs"],"sourcesContent":["import sqliteAdapter from \"@internal/adapter-sqlite/runtime\";\nimport { UNBOUND_NAMESPACE_ID } from \"@internal/framework-components/ir\";\nimport { createRawLane, sql } from \"@internal/sql-builder/runtime\";\nimport { createExecutionContext, createSqlExecutionStack } from \"@internal/sql-runtime\";\nimport sqliteTarget, { SqliteContractSerializer } from \"@internal/target-sqlite/runtime\";\nimport { assertDefined } from \"@internal/utils/assertions\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { validateContractOnce } from \"@internal/contract/validate-once\";\nimport { buildNamespacedEnums } from \"@internal/contract/enum-accessor\";\n//#region package.json\nvar version = \"8.0.0-rc.18-dev.30\";\n//#endregion\n//#region src/static/contract-from-json.ts\nconst serializer = new SqliteContractSerializer();\nconst validator = `${sqliteTarget.targetId}@${version}`;\n/**\n* Validates an emitted SQLite `contract.json` and returns it as the contract type the application\n* names, ready to pass to `sqlite({ contract })` and `sqliteStatic({ contract })`. Clients built\n* from the result do not validate it again.\n*\n* The returned value's top level is frozen; its nested objects are not. Do not change `json` or the\n* returned value after the call: clients built from the value later do not validate it again.\n*\n* @example\n* ```ts\n* import type { Contract } from './contract.d';\n* import contractJson from './contract.json' with { type: 'json' };\n*\n* export const contract = contractFromJson<Contract>(contractJson);\n* ```\n*/\nfunction contractFromJson(json) {\n\treturn validateContractOnce(json, validator, (input) => serializer.deserializeContract(input));\n}\nfunction validateSqliteContract(contract) {\n\treturn validateContractOnce(contract, validator, () => serializer.deserializeContract(serializer.serializeContract(contract)));\n}\n//#endregion\n//#region src/static/sqlite-static.ts\nfunction buildSqliteStaticContext(contract, context, rawCodecInferer) {\n\tconst sqlNamespace = sql({\n\t\tcontext,\n\t\trawCodecInferer\n\t})[UNBOUND_NAMESPACE_ID];\n\tassertDefined(sqlNamespace, \"the unbound namespace always exists on a sqlite builder output\");\n\tconst sqlDb = blindCast(sqlNamespace);\n\tconst raw = createRawLane({\n\t\tcontext,\n\t\trawCodecInferer\n\t});\n\tconst enums = Object.freeze(buildNamespacedEnums(context.contract.domain, (codecId) => context.contractCodecs.forCodecRef({ codecId })))[UNBOUND_NAMESPACE_ID];\n\tassertDefined(enums, \"the unbound namespace always exists on a sqlite builder output\");\n\treturn {\n\t\tcontext,\n\t\tcontract,\n\t\tenums,\n\t\tsql: sqlDb,\n\t\traw\n\t};\n}\n/**\n* The query surfaces of a SQLite client without a driver: `sql`, `raw` and `enums`. Use it where\n* loading `node:sqlite` is not wanted.\n*\n* @example\n* ```ts\n* const { enums } = sqliteStatic({ contract: contractFromJson<Contract>(contractJson) });\n* ```\n*/\nfunction sqliteStatic(options) {\n\tconst contract = validateSqliteContract(options.contract);\n\tconst stack = createSqlExecutionStack({\n\t\ttarget: sqliteTarget,\n\t\tadapter: sqliteAdapter,\n\t\textensions: options.extensions ?? []\n\t});\n\treturn buildSqliteStaticContext(contract, createExecutionContext({\n\t\tcontract,\n\t\tstack\n\t}), stack.adapter.rawCodecInferer);\n}\n//#endregion\nexport { validateSqliteContract as i, sqliteStatic as n, contractFromJson as r, buildSqliteStaticContext as t };\n\n//# sourceMappingURL=sqlite-static-ChY34tsf.mjs.map"],"mappings":";;;;;;;;;;AAUA,IAAI,UAAU;AAGd,MAAM,aAAa,IAAI,yBAAyB;AAChD,MAAM,YAAY,GAAG,aAAa,SAAS,GAAG;;;;;;;;;;;;;;;;;AAiB9C,SAAS,iBAAiB,MAAM;CAC/B,OAAO,qBAAqB,MAAM,YAAY,UAAU,WAAW,oBAAoB,KAAK,CAAC;AAC9F;AACA,SAAS,uBAAuB,UAAU;CACzC,OAAO,qBAAqB,UAAU,iBAAiB,WAAW,oBAAoB,WAAW,kBAAkB,QAAQ,CAAC,CAAC;AAC9H;AAGA,SAAS,yBAAyB,UAAU,SAAS,iBAAiB;CACrE,MAAM,eAAe,IAAI;EACxB;EACA;CACD,CAAC,CAAC,CAAC;CACH,cAAc,cAAc,gEAAgE;CAC5F,MAAM,QAAQ,UAAU,YAAY;CACpC,MAAM,MAAM,cAAc;EACzB;EACA;CACD,CAAC;CACD,MAAM,QAAQ,OAAO,OAAO,qBAAqB,QAAQ,SAAS,SAAS,YAAY,QAAQ,eAAe,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;CACzI,cAAc,OAAO,gEAAgE;CACrF,OAAO;EACN;EACA;EACA;EACA,KAAK;EACL;CACD;AACD;;;;;;;;;;AAUA,SAAS,aAAa,SAAS;CAC9B,MAAM,WAAW,uBAAuB,QAAQ,QAAQ;CACxD,MAAM,QAAQ,wBAAwB;EACrC,QAAQ;EACR,SAAS;EACT,YAAY,QAAQ,cAAc,CAAC;CACpC,CAAC;CACD,OAAO,yBAAyB,UAAU,uBAAuB;EAChE;EACA;CACD,CAAC,GAAG,MAAM,QAAQ,eAAe;AAClC"}
1
+ {"version":3,"file":"sqlite-static-FIzNnSBq-zXmUb8TI.mjs","names":[],"sources":["../../../../3-extensions/sqlite/dist/sqlite-static-FIzNnSBq.mjs"],"sourcesContent":["import sqliteAdapter from \"@internal/adapter-sqlite/runtime\";\nimport { UNBOUND_NAMESPACE_ID } from \"@internal/framework-components/ir\";\nimport { createRawLane, sql } from \"@internal/sql-builder/runtime\";\nimport { createExecutionContext, createSqlExecutionStack } from \"@internal/sql-runtime\";\nimport sqliteTarget, { SqliteContractSerializer } from \"@internal/target-sqlite/runtime\";\nimport { assertDefined } from \"@internal/utils/assertions\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { validateContractOnce } from \"@internal/contract/validate-once\";\nimport { buildNamespacedEnums } from \"@internal/contract/enum-accessor\";\n//#region package.json\nvar version = \"8.0.0-rc.18-dev.32\";\n//#endregion\n//#region src/static/contract-from-json.ts\nconst serializer = new SqliteContractSerializer();\nconst validator = `${sqliteTarget.targetId}@${version}`;\n/**\n* Validates an emitted SQLite `contract.json` and returns it as the contract type the application\n* names, ready to pass to `sqlite({ contract })` and `sqliteStatic({ contract })`. Clients built\n* from the result do not validate it again.\n*\n* The returned value's top level is frozen; its nested objects are not. Do not change `json` or the\n* returned value after the call: clients built from the value later do not validate it again.\n*\n* @example\n* ```ts\n* import type { Contract } from './contract.d';\n* import contractJson from './contract.json' with { type: 'json' };\n*\n* export const contract = contractFromJson<Contract>(contractJson);\n* ```\n*/\nfunction contractFromJson(json) {\n\treturn validateContractOnce(json, validator, (input) => serializer.deserializeContract(input));\n}\nfunction validateSqliteContract(contract) {\n\treturn validateContractOnce(contract, validator, () => serializer.deserializeContract(serializer.serializeContract(contract)));\n}\n//#endregion\n//#region src/static/sqlite-static.ts\nfunction buildSqliteStaticContext(contract, context, rawCodecInferer) {\n\tconst sqlNamespace = sql({\n\t\tcontext,\n\t\trawCodecInferer\n\t})[UNBOUND_NAMESPACE_ID];\n\tassertDefined(sqlNamespace, \"the unbound namespace always exists on a sqlite builder output\");\n\tconst sqlDb = blindCast(sqlNamespace);\n\tconst raw = createRawLane({\n\t\tcontext,\n\t\trawCodecInferer\n\t});\n\tconst enums = Object.freeze(buildNamespacedEnums(context.contract.domain, (codecId) => context.contractCodecs.forCodecRef({ codecId })))[UNBOUND_NAMESPACE_ID];\n\tassertDefined(enums, \"the unbound namespace always exists on a sqlite builder output\");\n\treturn {\n\t\tcontext,\n\t\tcontract,\n\t\tenums,\n\t\tsql: sqlDb,\n\t\traw\n\t};\n}\n/**\n* The query surfaces of a SQLite client without a driver: `sql`, `raw` and `enums`. Use it where\n* loading `node:sqlite` is not wanted.\n*\n* @example\n* ```ts\n* const { enums } = sqliteStatic({ contract: contractFromJson<Contract>(contractJson) });\n* ```\n*/\nfunction sqliteStatic(options) {\n\tconst contract = validateSqliteContract(options.contract);\n\tconst stack = createSqlExecutionStack({\n\t\ttarget: sqliteTarget,\n\t\tadapter: sqliteAdapter,\n\t\textensions: options.extensions ?? []\n\t});\n\treturn buildSqliteStaticContext(contract, createExecutionContext({\n\t\tcontract,\n\t\tstack\n\t}), stack.adapter.rawCodecInferer);\n}\n//#endregion\nexport { validateSqliteContract as i, sqliteStatic as n, contractFromJson as r, buildSqliteStaticContext as t };\n\n//# sourceMappingURL=sqlite-static-FIzNnSBq.mjs.map"],"mappings":";;;;;;;;;;AAUA,IAAI,UAAU;AAGd,MAAM,aAAa,IAAI,yBAAyB;AAChD,MAAM,YAAY,GAAG,aAAa,SAAS,GAAG;;;;;;;;;;;;;;;;;AAiB9C,SAAS,iBAAiB,MAAM;CAC/B,OAAO,qBAAqB,MAAM,YAAY,UAAU,WAAW,oBAAoB,KAAK,CAAC;AAC9F;AACA,SAAS,uBAAuB,UAAU;CACzC,OAAO,qBAAqB,UAAU,iBAAiB,WAAW,oBAAoB,WAAW,kBAAkB,QAAQ,CAAC,CAAC;AAC9H;AAGA,SAAS,yBAAyB,UAAU,SAAS,iBAAiB;CACrE,MAAM,eAAe,IAAI;EACxB;EACA;CACD,CAAC,CAAC,CAAC;CACH,cAAc,cAAc,gEAAgE;CAC5F,MAAM,QAAQ,UAAU,YAAY;CACpC,MAAM,MAAM,cAAc;EACzB;EACA;CACD,CAAC;CACD,MAAM,QAAQ,OAAO,OAAO,qBAAqB,QAAQ,SAAS,SAAS,YAAY,QAAQ,eAAe,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;CACzI,cAAc,OAAO,gEAAgE;CACrF,OAAO;EACN;EACA;EACA;EACA,KAAK;EACL;CACD;AACD;;;;;;;;;;AAUA,SAAS,aAAa,SAAS;CAC9B,MAAM,WAAW,uBAAuB,QAAQ,QAAQ;CACxD,MAAM,QAAQ,wBAAwB;EACrC,QAAQ;EACR,SAAS;EACT,YAAY,QAAQ,cAAc,CAAC;CACpC,CAAC;CACD,OAAO,yBAAyB,UAAU,uBAAuB;EAChE;EACA;CACD,CAAC,GAAG,MAAM,QAAQ,eAAe;AAClC"}
package/dist/static.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { n as contractFromJson, r as sqliteStatic } from "./sqlite-static-ChY34tsf-Dkdgx_nX.mjs";
1
+ import { n as contractFromJson, r as sqliteStatic } from "./sqlite-static-FIzNnSBq-zXmUb8TI.mjs";
2
2
  export { contractFromJson, sqliteStatic as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/orm-sqlite",
3
- "version": "8.0.0-rc.18-dev.30",
3
+ "version": "8.0.0-rc.18-dev.32",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -10,17 +10,17 @@
10
10
  "skills"
11
11
  ],
12
12
  "dependencies": {
13
- "@prisma/orm-family-sql": "8.0.0-rc.18-dev.30",
14
- "@prisma/orm-framework": "8.0.0-rc.18-dev.30",
15
- "@prisma/orm-target-sqlite": "8.0.0-rc.18-dev.30",
16
- "@prisma/orm-toolchain": "8.0.0-rc.18-dev.30",
13
+ "@prisma/orm-family-sql": "8.0.0-rc.18-dev.32",
14
+ "@prisma/orm-framework": "8.0.0-rc.18-dev.32",
15
+ "@prisma/orm-target-sqlite": "8.0.0-rc.18-dev.32",
16
+ "@prisma/orm-toolchain": "8.0.0-rc.18-dev.32",
17
17
  "pathe": "^2.0.3",
18
18
  "tinyglobby": "^0.2.17"
19
19
  },
20
20
  "devDependencies": {
21
- "@internal/sqlite": "8.0.0-rc.18-dev.30",
22
- "@repo/tsconfig": "8.0.0-rc.18-dev.30",
23
- "@repo/tsdown": "8.0.0-rc.18-dev.30",
21
+ "@internal/sqlite": "8.0.0-rc.18-dev.32",
22
+ "@repo/tsconfig": "8.0.0-rc.18-dev.32",
23
+ "@repo/tsdown": "8.0.0-rc.18-dev.32",
24
24
  "tsdown": "0.22.14",
25
25
  "typescript": "5.9.3"
26
26
  },
@@ -15,7 +15,7 @@ description: >-
15
15
  ORM 7 or earlier (schema.prisma + @prisma/client).
16
16
  metadata:
17
17
  library: '@prisma/orm-sqlite'
18
- library_version: '8.0.0-rc.18-dev.30'
18
+ library_version: '8.0.0-rc.18-dev.32'
19
19
  version: '2026-09-12'
20
20
  ---
21
21
 
@@ -23,6 +23,7 @@ Both files are **emitted artefacts**. Edit the source; never the JSON or `.d.ts`
23
23
  - User wants to add a namespace block (Postgres schema) or a cross-contract foreign key.
24
24
  - User wants to set `@@control` on a model or configure `defaultControlPolicy`.
25
25
  - User wants to use a custom type from an extension (`pgvector.Vector(length: 1536)`, `postgis.Geometry(...)`).
26
+ - User needs a column of a database type no Prisma column type covers (`tsvector`, `ltree`, `circle`, a domain): a raw column, `Raw("...")`.
26
27
  - User wants to install or configure an extension via `extensions: [...]` in `prisma.config.ts`, including `@internal/extension-supabase`.
27
28
  - User is migrating between authoring sources (PSL ↔ TypeScript builder).
28
29
  - User received `CONFIG.CONTRACT_MISSING`, `CONTRACT.VALIDATION_FAILED`, or `CONFIG.MISSING_EXTENSION_PACKS` from `contract emit`.
@@ -232,6 +233,27 @@ If you reference `pgvector.*` without registering the descriptor in the config,
232
233
 
233
234
  For canonical worked examples covering single and multi-extension setups, read `examples/prisma-8-demo/prisma.config.ts`, `examples/multi-extension-monorepo/app/prisma.config.ts` and `examples/prisma-8-postgis-demo/prisma.config.ts`.
234
235
 
236
+ ## Workflow — Raw columns (a type no column type covers)
237
+
238
+ The concept: `Raw("<type>")` declares a column whose type Prisma does not model, such as `tsvector`, `ltree`, `circle` or a domain of the user's own. Migrations write the text as given, and `db verify` compares it with the type the database reports, exactly. Values are typed `unknown`, read the same flat and through includes, and write back as read. On Postgres the ORM reads each value as the text the database prints for it. On SQLite a value keeps the shape of its storage class: a number, a string, a `Uint8Array` for a BLOB, or null. The ORM offers no filters or ordering on raw values. Raw columns exist on Postgres and SQLite.
239
+
240
+ ```prisma
241
+ model Category {
242
+ id Int @id
243
+ search Raw("tsvector")
244
+ area Raw("circle") @default(sql`'<(0,0),1>'::circle`)
245
+ net Raw("cidr")?
246
+ }
247
+ ```
248
+
249
+ In the TypeScript builder, use `field.column(type.Raw('tsvector'))` in the callback overload, or `field.column(rawColumn('tsvector'))` with `rawColumn` from the adapter's column types.
250
+
251
+ - Write the type as the database catalog prints it: `integer`, not `int4`; `character varying(10)`, not `varchar(10)`. Another form reports a type mismatch in `db verify`, and the finding names the text to write.
252
+ - A raw column's default is a `sql` expression. A literal default is refused at emit (`` Expected sql`...` ``).
253
+ - The text is one type name: words and double-quoted names separated by single spaces, the first optionally after one schema name and a dot, each optionally followed by parentheses of letters, digits, underscores, commas, spaces and a minus sign before a digit, and at most one trailing `[]`. `geometry(Point,4326)`, `double precision` and `app.email` (a domain whose schema is not on the `search_path`) are fine; quotes of other kinds, `$` and operators are refused.
254
+ - PSL strings have no escapes, so a type whose name needs double quotes cannot be written with `Raw`.
255
+ - Changing the text changes the column's type: `migration plan` writes `ALTER COLUMN ... TYPE`. If the database has no cast between the two types, name the field with `--convert` and write the conversion. The generated call is `alterColumnType({ ..., type: "text", raw: true })`; keep `raw: true` when editing it, since a raw type is checked as written.
256
+
235
257
  ## Workflow — Polymorphism (`@@discriminator` / `@@base`)
236
258
 
237
259
  The concept (SQL targets): one base model declares the discriminator field; each variant model declares its base + discriminator value. The variant chooses STI vs MTI by **whether it sets `@@map(...)`**: no `@@map` means the variant inherits the base's table (single-table inheritance); `@@map("variant_table")` means the variant gets its own table joined 1:1 by primary key (multi-table inheritance).
@@ -533,7 +533,7 @@ In a terminal the command asks each question in turn; type `delete`, `allow`, or
533
533
  6. **Aggregate `check` closure in Postgres `this.dataTransform`.** Returning `count(*)` or `bool_and(...)` breaks the precheck/postcheck contract — both sides resolve to constants. Use a rowset shape: `select('id').where(<violation>).limit(1)`.
534
534
  7. **Two contract references in one migration.** Building a query plan against a different contract than the one passed to `this.dataTransform(endContract, ...)` raises `MIGRATION.DATA_TRANSFORM_CONTRACT_MISMATCH`. Always import `endContract` once at module scope and use the same reference.
535
535
  11. **Calling Postgres operations as free functions.** `addColumn('public', 'user', {...})` does not exist as an import; the operations are `this.addColumn({ schema, table, column })` and friends on the `Migration` base class, with `col(...)` building the column. Only `col`, `rawSql`, `placeholder`, `Migration`, and `MigrationCLI` are imported.
536
- 8. **Renaming a model or field without a statement.** The planner cannot tell a rename from a drop and a create, so without a statement it plans a destructive drop+add. State the rename on the command line: `migration plan --name <slug> --rename User:Person --rename Person.email:Person.emailAddress`, or the same `--rename` flags on `db update`. A field is named through its model as the new contract names it. The planner then renames the table or column and the constraints and indexes named after it; on MongoDB it renames the collection, and the field in every document that holds it (only in that variant's documents for a variant's field). On MongoDB a field is named by its stored name: `id @map("_id")` is `User._id`. For a rename statements do not cover, such as a model that keeps its name but changes its `@@map`, hand-edit `migration.ts` with `...this.renameTable(...)` or `...this.renameColumn(...)` (Postgres, SQLite) or `renameCollection(...)` (MongoDB), then self-emit.
536
+ 8. **Renaming a model or field without a statement.** The planner cannot tell a rename from a drop and a create, so without a statement it plans a destructive drop+add. State the rename on the command line: `migration plan --name <slug> --rename User:Person --rename Person.email:Person.emailAddress`, or the same `--rename` flags on `db update`. A field is named through its model as the new contract names it. The planner then renames the table or column and the constraints and indexes named after it; on MongoDB it renames the collection, and the field in every document that holds it (only in that variant's documents for a variant's field). On MongoDB a field is named by its name in the contract, as on SQL: `id @map("_id")` is `User.id`. A statement that keeps the stored name, such as `--rename User.name:User.title` where both are stored as `display_name`, plans nothing; one that changes it renames the field in the documents. A field whose `@map` changes while its name stays is planned as a removal of its old stored name, as on SQL, so the plan asks about it; no statement states a stored-name-only change, so to keep the values, edit the planned `migration.ts` to call `renameField(...)` instead, or rename the field in the database yourself before `db update`. For a rename statements do not cover, such as a model that keeps its name but changes its `@@map`, hand-edit `migration.ts` with `...this.renameTable(...)` or `...this.renameColumn(...)` (Postgres, SQLite) or `renameCollection(...)` (MongoDB), then self-emit.
537
537
  9. **Planning with no `db` ref and no `--from` in a project that already has migrations.** The origin falls through to the empty database, which would make the plan a full-create migration; `migration plan` refuses with `MIGRATION.PLAN_ORIGIN_UNKNOWN` rather than writing it. Pick the exit that matches your intent — the error lists them, and `references/migration-model.md` § *The trap* explains which to choose.
538
538
  10. **Hand-authoring `migration.ts` from a blank file, or rewriting the rendered import line.** Migration files are framework-rendered — let `prisma migration plan` (or `migration new`) render the package, then edit only the holes the framework leaves for you. On Postgres leave the rendered `@internal/postgres/migration` (or `@internal/sqlite/migration`) import path alone; on Mongo leave `@prisma/orm-mongo/target/migration` as rendered. Add symbols to the existing import line rather than introducing new import paths.
539
539
  12. **Replaying migrations onto a database that is already ahead.** `db migrate` on a database with no marker runs every migration, skipping operations already applied. When the database is already past a migration (it has `x int8` where the migration adds `x int4`), the run stops at that migration's precheck with `MIGRATION.PRECHECK_FAILED`. Adopt such a database with `prisma db sign` (after `contract infer` if needed), not by replaying history.
@@ -47,6 +47,8 @@ const recent = await db.orm.posts
47
47
  .all();
48
48
  ```
49
49
 
50
+ **Field names, not stored names.** The ORM names a field by its name in the contract, never by the key its documents store it under. A field declared `id ObjectId @id @map("_id")` is `id` in every ORM call and row, and documents store it as `_id`; passing `_id` to the ORM fails with `ORM.FIELD_UNKNOWN`, whose message names the field to use. The pipeline builder (`db.query`) works on documents, so it names stored names: `_id` there. A raw filter expression passed to the ORM's `.where(...)`, such as `MongoFieldFilter.eq('displayName', 'Ada')` or a `MongoExprFilter`, names fields too and is translated; one built for `db.query` names stored names, so do not pass it to the ORM.
51
+
50
52
  **`.where(...)`** accepts a plain object whose keys are model field names and values are compared with equality (codec-aware — `ObjectId` fields accept string ids from the contract). Chain multiple `.where({ ... })` calls to AND-compose filters.
51
53
 
52
54
  For operators the object form doesn't cover (`.in([...])`, range comparisons, nested logic), pass a `MongoFilterExpr` — today that means importing filter helpers from `@prisma/orm-mongo/query-ast/execution` (a façade-completeness gap; see *What Prisma 8 doesn't do yet* in [`queries.md`](./queries.md)). Prefer the object form whenever equality suffices.
@@ -60,7 +62,7 @@ const tutorials = await db.orm.posts.variant('tutorial').where({ authorId }).all
60
62
 
61
63
  **Sorting and pagination.** `.orderBy({ field: 1 | -1 })` (Mongo sort directions). `.limit(n)` maps to `$limit`; `.offset(n)` maps to `$skip`.
62
64
 
63
- **`.first()` vs `.all()`.** `.first()` issues a limit-1 read; `.all()` returns every matching document. There is no `.first({ pk })` shorthand on Mongo — filter on `_id` explicitly: `.where({ _id: id }).first()`.
65
+ **`.first()` vs `.all()`.** `.first()` issues a limit-1 read; `.all()` returns every matching document. There is no `.first({ pk })` shorthand on Mongo — filter on the id field explicitly: `.where({ id }).first()`.
64
66
 
65
67
  Mongo `.all()` returns the same `AsyncIterableResult` shape as Postgres — `await db.orm.users.all()` yields an array; see *Consuming the result* in [`queries.md`](./queries.md).
66
68
 
@@ -83,7 +85,7 @@ Relation names match the contract's `@relation` field names. Nested includes fol
83
85
  Mongo mutations require a preceding `.where(...)` filter (except `.create` / `.createAll`). Updates accept either a partial document or a field-accessor callback for Mongo operators:
84
86
 
85
87
  ```typescript
86
- // Create — returns the row with server-assigned `_id`.
88
+ // Create — returns the row with the server-assigned `id` (stored as `_id`).
87
89
  const user = await db.orm.users.create({
88
90
  name: 'Alice',
89
91
  email: 'alice@example.com',
@@ -92,11 +94,11 @@ const user = await db.orm.users.create({
92
94
  });
93
95
 
94
96
  // Update one — plain object replaces top-level fields.
95
- await db.orm.users.where({ _id: user._id }).update({ bio: 'Writer' });
97
+ await db.orm.users.where({ id: user.id }).update({ bio: 'Writer' });
96
98
 
97
99
  // Update one — field operations ($push, $inc, dot-path $set).
98
100
  await db.orm.users
99
- .where({ _id: user._id })
101
+ .where({ id: user.id })
100
102
  .update((u) => [u.tags.push('admin'), u.loginCount.inc(1)]);
101
103
 
102
104
  // Update many / delete many — iterate or count.
@@ -105,7 +107,7 @@ const updated = await db.orm.users
105
107
  .updateAll({ bio: 'filled' });
106
108
  for await (const row of updated) { /* each modified doc */ }
107
109
 
108
- await db.orm.users.where({ _id: user._id }).delete();
110
+ await db.orm.users.where({ id: user.id }).delete();
109
111
 
110
112
  // Upsert — filter via .where(), split create vs update branches.
111
113
  await db.orm.users.where({ email: 'alice@example.com' }).upsert({
@@ -144,7 +146,7 @@ Import `acc` and expression helpers (`fn`) from `@prisma/orm-mongo/query-builder
144
146
 
145
147
  ## Workflow — Query builder (`db.query`)
146
148
 
147
- The concept: `db.query.from('<root>')` starts a typed aggregation-pipeline chain. Terminal methods produce a `MongoQueryPlan`; run it through the runtime with `query(plan)` (an `AsyncIterableResult` of documents — `await` it for an array):
149
+ The concept: `db.query.from('<root>')` starts a typed aggregation-pipeline chain over documents, so it names each field by its stored name (`_id` for a field declared `id … @map("_id")`). Terminal methods produce a `MongoQueryPlan`; run it through the runtime with `query(plan)` (an `AsyncIterableResult` of documents — `await` it for an array):
148
150
 
149
151
  ```typescript
150
152
  // src/queries/analytics.ts