@prisma/orm-mysql 8.0.0-rc.22-dev.12 → 8.0.0-rc.22-dev.13

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.
@@ -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-targets/mysql/9-facade/dist/mysql-static-DTHc0Eoh.mjs
11
- var version = "8.0.0-rc.22-dev.12";
10
+ //#region ../../../3-targets/mysql/9-facade/dist/mysql-static-1yYsheIU.mjs
11
+ var version = "8.0.0-rc.22-dev.13";
12
12
  const serializer = new MysqlContractSerializer();
13
13
  const validator = `${mysqlTarget.targetId}@${version}`;
14
14
  /**
@@ -80,4 +80,4 @@ function mysqlStatic(options) {
80
80
  //#endregion
81
81
  export { validateMysqlContract as i, contractFromJson as n, mysqlStatic as r, buildMysqlStaticContext as t };
82
82
 
83
- //# sourceMappingURL=mysql-static-DTHc0Eoh-CLml_HCC.mjs.map
83
+ //# sourceMappingURL=mysql-static-1yYsheIU-DWNhi8vn.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"mysql-static-DTHc0Eoh-CLml_HCC.mjs","names":[],"sources":["../../../../3-targets/mysql/9-facade/dist/mysql-static-DTHc0Eoh.mjs"],"sourcesContent":["import mysqlAdapter from \"@internal/adapter-mysql/runtime\";\nimport { UNBOUND_NAMESPACE_ID } from \"@internal/framework-components/ir\";\nimport { createRawLane, sql } from \"@internal/sql-builder/runtime\";\nimport { createExecutionContext, createSqlExecutionStack, createToSql } from \"@internal/sql-runtime\";\nimport mysqlTarget, { MysqlContractSerializer } from \"@internal/target-mysql/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.22-dev.12\";\n//#endregion\n//#region src/static/contract-from-json.ts\nconst serializer = new MysqlContractSerializer();\nconst validator = `${mysqlTarget.targetId}@${version}`;\n/**\n* Validates an emitted MySQL `contract.json` and returns it as the contract type the application\n* names, ready to pass to `mysql({ contract })` and `mysqlStatic({ 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 validateMysqlContract(contract) {\n\treturn validateContractOnce(contract, validator, () => serializer.deserializeContract(serializer.serializeContract(contract)));\n}\n//#endregion\n//#region src/static/mysql-static.ts\nfunction buildMysqlStaticContext(contract, context, stack) {\n\tconst { rawCodecInferer } = stack.adapter;\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 mysql 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 mysql builder output\");\n\treturn {\n\t\tcontext,\n\t\tcontract,\n\t\tenums,\n\t\tsql: sqlDb,\n\t\traw,\n\t\ttoSql: createToSql(stack, contract)\n\t};\n}\n/**\n* The query surfaces of a MySQL client without a driver: `sql`, `raw`, `enums` and `toSql`. Use\n* it where loading the MySQL driver is not wanted.\n*\n* @example\n* ```ts\n* const { enums } = mysqlStatic({ contract: contractFromJson<Contract>(contractJson) });\n* ```\n*/\nfunction mysqlStatic(options) {\n\tconst contract = validateMysqlContract(options.contract);\n\tconst stack = createSqlExecutionStack({\n\t\ttarget: mysqlTarget,\n\t\tadapter: mysqlAdapter,\n\t\textensions: options.extensions ?? []\n\t});\n\treturn buildMysqlStaticContext(contract, createExecutionContext({\n\t\tcontract,\n\t\tstack\n\t}), stack);\n}\n//#endregion\nexport { validateMysqlContract as i, mysqlStatic as n, contractFromJson as r, buildMysqlStaticContext as t };\n\n//# sourceMappingURL=mysql-static-DTHc0Eoh.mjs.map"],"mappings":";;;;;;;;;;AAUA,IAAI,UAAU;AAGd,MAAM,aAAa,IAAI,wBAAwB;AAC/C,MAAM,YAAY,GAAG,YAAY,SAAS,GAAG;;;;;;;;;;;;;;;;;AAiB7C,SAAS,iBAAiB,MAAM;CAC/B,OAAO,qBAAqB,MAAM,YAAY,UAAU,WAAW,oBAAoB,KAAK,CAAC;AAC9F;AACA,SAAS,sBAAsB,UAAU;CACxC,OAAO,qBAAqB,UAAU,iBAAiB,WAAW,oBAAoB,WAAW,kBAAkB,QAAQ,CAAC,CAAC;AAC9H;AAGA,SAAS,wBAAwB,UAAU,SAAS,OAAO;CAC1D,MAAM,EAAE,oBAAoB,MAAM;CAClC,MAAM,eAAe,IAAI;EACxB;EACA;CACD,CAAC,CAAC,CAAC;CACH,cAAc,cAAc,+DAA+D;CAC3F,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,+DAA+D;CACpF,OAAO;EACN;EACA;EACA;EACA,KAAK;EACL;EACA,OAAO,YAAY,OAAO,QAAQ;CACnC;AACD;;;;;;;;;;AAUA,SAAS,YAAY,SAAS;CAC7B,MAAM,WAAW,sBAAsB,QAAQ,QAAQ;CACvD,MAAM,QAAQ,wBAAwB;EACrC,QAAQ;EACR,SAAS;EACT,YAAY,QAAQ,cAAc,CAAC;CACpC,CAAC;CACD,OAAO,wBAAwB,UAAU,uBAAuB;EAC/D;EACA;CACD,CAAC,GAAG,KAAK;AACV"}
1
+ {"version":3,"file":"mysql-static-1yYsheIU-DWNhi8vn.mjs","names":[],"sources":["../../../../3-targets/mysql/9-facade/dist/mysql-static-1yYsheIU.mjs"],"sourcesContent":["import mysqlAdapter from \"@internal/adapter-mysql/runtime\";\nimport { UNBOUND_NAMESPACE_ID } from \"@internal/framework-components/ir\";\nimport { createRawLane, sql } from \"@internal/sql-builder/runtime\";\nimport { createExecutionContext, createSqlExecutionStack, createToSql } from \"@internal/sql-runtime\";\nimport mysqlTarget, { MysqlContractSerializer } from \"@internal/target-mysql/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.22-dev.13\";\n//#endregion\n//#region src/static/contract-from-json.ts\nconst serializer = new MysqlContractSerializer();\nconst validator = `${mysqlTarget.targetId}@${version}`;\n/**\n* Validates an emitted MySQL `contract.json` and returns it as the contract type the application\n* names, ready to pass to `mysql({ contract })` and `mysqlStatic({ 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 validateMysqlContract(contract) {\n\treturn validateContractOnce(contract, validator, () => serializer.deserializeContract(serializer.serializeContract(contract)));\n}\n//#endregion\n//#region src/static/mysql-static.ts\nfunction buildMysqlStaticContext(contract, context, stack) {\n\tconst { rawCodecInferer } = stack.adapter;\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 mysql 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 mysql builder output\");\n\treturn {\n\t\tcontext,\n\t\tcontract,\n\t\tenums,\n\t\tsql: sqlDb,\n\t\traw,\n\t\ttoSql: createToSql(stack, contract)\n\t};\n}\n/**\n* The query surfaces of a MySQL client without a driver: `sql`, `raw`, `enums` and `toSql`. Use\n* it where loading the MySQL driver is not wanted.\n*\n* @example\n* ```ts\n* const { enums } = mysqlStatic({ contract: contractFromJson<Contract>(contractJson) });\n* ```\n*/\nfunction mysqlStatic(options) {\n\tconst contract = validateMysqlContract(options.contract);\n\tconst stack = createSqlExecutionStack({\n\t\ttarget: mysqlTarget,\n\t\tadapter: mysqlAdapter,\n\t\textensions: options.extensions ?? []\n\t});\n\treturn buildMysqlStaticContext(contract, createExecutionContext({\n\t\tcontract,\n\t\tstack\n\t}), stack);\n}\n//#endregion\nexport { validateMysqlContract as i, mysqlStatic as n, contractFromJson as r, buildMysqlStaticContext as t };\n\n//# sourceMappingURL=mysql-static-1yYsheIU.mjs.map"],"mappings":";;;;;;;;;;AAUA,IAAI,UAAU;AAGd,MAAM,aAAa,IAAI,wBAAwB;AAC/C,MAAM,YAAY,GAAG,YAAY,SAAS,GAAG;;;;;;;;;;;;;;;;;AAiB7C,SAAS,iBAAiB,MAAM;CAC/B,OAAO,qBAAqB,MAAM,YAAY,UAAU,WAAW,oBAAoB,KAAK,CAAC;AAC9F;AACA,SAAS,sBAAsB,UAAU;CACxC,OAAO,qBAAqB,UAAU,iBAAiB,WAAW,oBAAoB,WAAW,kBAAkB,QAAQ,CAAC,CAAC;AAC9H;AAGA,SAAS,wBAAwB,UAAU,SAAS,OAAO;CAC1D,MAAM,EAAE,oBAAoB,MAAM;CAClC,MAAM,eAAe,IAAI;EACxB;EACA;CACD,CAAC,CAAC,CAAC;CACH,cAAc,cAAc,+DAA+D;CAC3F,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,+DAA+D;CACpF,OAAO;EACN;EACA;EACA;EACA,KAAK;EACL;EACA,OAAO,YAAY,OAAO,QAAQ;CACnC;AACD;;;;;;;;;;AAUA,SAAS,YAAY,SAAS;CAC7B,MAAM,WAAW,sBAAsB,QAAQ,QAAQ;CACvD,MAAM,QAAQ,wBAAwB;EACrC,QAAQ;EACR,SAAS;EACT,YAAY,QAAQ,cAAc,CAAC;CACpC,CAAC;CACD,OAAO,wBAAwB,UAAU,uBAAuB;EAC/D;EACA;CACD,CAAC,GAAG,KAAK;AACV"}
package/dist/runtime.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { i as validateMysqlContract, t as buildMysqlStaticContext } from "./mysql-static-DTHc0Eoh-CLml_HCC.mjs";
1
+ import { i as validateMysqlContract, t as buildMysqlStaticContext } from "./mysql-static-1yYsheIU-DWNhi8vn.mjs";
2
2
  import { ifDefined } from "@prisma/orm-framework/utils/defined";
3
3
  import mysqlAdapter from "@prisma/orm-target-mysql/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-targets/mysql/9-facade/dist/runtime.mjs"],"sourcesContent":["import { i as validateMysqlContract, t as buildMysqlStaticContext } from \"./mysql-static-DTHc0Eoh.mjs\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport mysqlAdapter from \"@internal/adapter-mysql/runtime\";\nimport mysqlDriver from \"@internal/driver-mysql/runtime\";\nimport { UNBOUND_NAMESPACE_ID } from \"@internal/framework-components/ir\";\nimport { createRawLane, sql } from \"@internal/sql-builder/runtime\";\nimport { orm, prepareQuery } from \"@internal/sql-orm-client\";\nimport { SqlRuntimeBase, activitySource, createExecutionContext, createSqlExecutionStack, delegatingActivitySource, delegatingRuntime, toRuntimeOptions, withTransaction, withTransactionMembers } from \"@internal/sql-runtime\";\nimport mysqlTarget from \"@internal/target-mysql/runtime\";\nimport { assertDefined } from \"@internal/utils/assertions\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { InternalError } from \"@internal/utils/internal-error\";\nimport { structuredError } from \"@internal/utils/structured-error\";\nimport { type } from \"arktype\";\n//#region src/errors.ts\nfunction mysqlClientError(code, message, options) {\n\treturn structuredError(code, message, options);\n}\n//#endregion\n//#region src/runtime/binding.ts\nfunction invalidUrl(message, meta) {\n\treturn structuredError(\"RUNTIME.BINDING_INVALID\", message, { meta: {\n\t\textension: \"mysql\",\n\t\t...meta\n\t} });\n}\n/** Checks `url` as the Postgres facade checks its own: a non-empty URL that parses, with the `mysql://` scheme. No part of the URL goes into the error. */\nfunction validateMysqlUrl(url) {\n\tconst trimmed = url.trim();\n\tif (trimmed.length === 0) throw invalidUrl(\"MySQL URL must be a non-empty string\", { reason: \"empty url\" });\n\tlet parsed;\n\ttry {\n\t\tparsed = new URL(trimmed);\n\t} catch {\n\t\tthrow invalidUrl(\"MySQL URL must be a valid URL\", { reason: \"unparseable url\" });\n\t}\n\tif (parsed.protocol !== \"mysql:\") throw invalidUrl(\"MySQL URL must use mysql://\", {\n\t\treason: \"wrong scheme\",\n\t\treceived: parsed.protocol\n\t});\n\treturn trimmed;\n}\nfunction resolveMysqlBinding(input) {\n\treturn {\n\t\tkind: \"url\",\n\t\turl: validateMysqlUrl(input.url)\n\t};\n}\nfunction resolveOptionalMysqlBinding(options) {\n\treturn options.url === void 0 ? void 0 : resolveMysqlBinding({ url: options.url });\n}\n//#endregion\n//#region src/runtime/mysql-options.ts\nconst streamOptionSchema = type(\"boolean | undefined\");\n/** Checks `stream` when the factory is called, as the Postgres facade checks `cursor`. */\nfunction validateStreamOption(stream) {\n\tconst result = streamOptionSchema(stream);\n\tif (result instanceof type.errors) throw mysqlClientError(\"RUNTIME.ARGUMENT_INVALID\", \"Invalid stream option\", {\n\t\twhy: result.summary,\n\t\tfix: \"Pass stream: true to stream rows as they arrive, or leave stream unset to read each whole result first.\",\n\t\tmeta: {\n\t\t\textension: \"mysql\",\n\t\t\thelper: \"mysql\",\n\t\t\targument: \"stream\",\n\t\t\treceived: stream\n\t\t}\n\t});\n\treturn result ?? false;\n}\n//#endregion\n//#region src/runtime/mysql-runtime.ts\nvar MysqlRuntimeImpl = class extends SqlRuntimeBase {};\n//#endregion\n//#region src/runtime/mysql.ts\nfunction mysqlOrm(orm) {\n\tconst namespace = orm[UNBOUND_NAMESPACE_ID];\n\tassertDefined(namespace, \"the unbound namespace always exists on a mysql builder output\");\n\treturn blindCast(Reflect.get(namespace, \"fragment\") === void 0 ? Object.create(namespace, { fragment: { value: Reflect.get(orm, \"fragment\") } }) : namespace);\n}\n/**\n* Builds the members of a MySQL transaction over `txCtx`, so every statement they run goes through the transaction. Preparing sends nothing to the database, so `prepare` uses `prepareRuntime`; the prepared statement runs on the queryable it is given.\n*/\nfunction buildMysqlTransactionMembers(options, txCtx) {\n\tconst { context, collections, rawCodecInferer, enums, toSql, prepareRuntime } = options;\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 mysql builder output\");\n\treturn {\n\t\tsql: blindCast(sqlNamespace),\n\t\torm: mysqlOrm(orm({\n\t\t\truntime: {\n\t\t\t\tquery(plan) {\n\t\t\t\t\treturn txCtx.query(plan);\n\t\t\t\t},\n\t\t\t\texecute(plan) {\n\t\t\t\t\treturn txCtx.execute(plan);\n\t\t\t\t},\n\t\t\t\t[activitySource]: delegatingActivitySource(() => txCtx)\n\t\t\t},\n\t\t\tcontext,\n\t\t\t...ifDefined(\"collections\", collections)\n\t\t})),\n\t\traw: createRawLane({\n\t\t\tcontext,\n\t\t\trawCodecInferer\n\t\t}),\n\t\tenums,\n\t\ttoSql,\n\t\tprepare(declaration, callback) {\n\t\t\treturn prepareQuery(prepareRuntime, declaration, callback);\n\t\t}\n\t};\n}\n/**\n* Creates a lazy MySQL 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-mysql/static';\n* import mysql from '@prisma/orm-mysql/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 = mysql({ contract, url: process.env.DATABASE_URL });\n* ```\n*/\nfunction mysql(options) {\n\tconst stream = validateStreamOption(options.stream);\n\tconst contract = validateMysqlContract(options.contract);\n\tlet binding = resolveOptionalMysqlBinding(options);\n\tconst stack = createSqlExecutionStack({\n\t\ttarget: mysqlTarget,\n\t\tadapter: mysqlAdapter,\n\t\tdriver: mysqlDriver,\n\t\textensions: options.extensions ?? []\n\t});\n\tconst context = createExecutionContext({\n\t\tcontract,\n\t\tstack,\n\t\tdriver: mysqlDriver\n\t});\n\tconst { sql, raw: rawSqlTag, enums, toSql } = buildMysqlStaticContext(contract, context, stack);\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 closedError = () => mysqlClientError(\"DRIVER.NOT_CONNECTED\", \"MySQL client is closed\", { meta: { extension: \"mysql\" } });\n\tconst connectDriver = async (resolvedBinding) => {\n\t\tif (driverConnected) return;\n\t\tif (!runtimeDriver) throw new InternalError(\"MySQL 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 closedError();\n\t\tif (backgroundConnectError !== void 0) throw backgroundConnectError;\n\t\tif (runtimeInstance) return runtimeInstance;\n\t\tconst adapter = stack.adapter.create(stack);\n\t\tconst driver = stack.driver.create({\n\t\t\tstream,\n\t\t\t...ifDefined(\"poolOptions\", options.poolOptions)\n\t\t});\n\t\townedDispose = () => driver.close();\n\t\truntimeDriver = driver;\n\t\tif (binding !== void 0) connectDriver(binding).catch(() => void 0);\n\t\truntimeInstance = new MysqlRuntimeImpl({\n\t\t\tcontext,\n\t\t\tadapter,\n\t\t\tdriver,\n\t\t\t...toRuntimeOptions(options),\n\t\t\tcloseRefusal: \"at-once\"\n\t\t});\n\t\treturn runtimeInstance;\n\t};\n\tconst workRuntime = delegatingRuntime(getRuntime);\n\tconst orm$1 = mysqlOrm(orm({\n\t\tcontext,\n\t\t...ifDefined(\"collections\", options.collections),\n\t\truntime: workRuntime\n\t}));\n\tfunction prepare(declaration, callback) {\n\t\treturn prepareQuery(workRuntime, declaration, callback);\n\t}\n\treturn {\n\t\tsql,\n\t\torm: orm$1,\n\t\tenums,\n\t\traw: rawSqlTag,\n\t\ttoSql,\n\t\tcontext,\n\t\tcontract,\n\t\tstack,\n\t\tquery(plan, execOptions) {\n\t\t\treturn workRuntime.query(plan, execOptions);\n\t\t},\n\t\texecute(plan, execOptions) {\n\t\t\treturn workRuntime.execute(plan, execOptions);\n\t\t},\n\t\tasync connect(bindingInput) {\n\t\t\tif (closed) throw closedError();\n\t\t\tif (driverConnected || connectPromise) {\n\t\t\t\tif (bindingInput !== void 0) throw mysqlClientError(\"DRIVER.ALREADY_CONNECTED\", \"MySQL client is already bound\", {\n\t\t\t\t\twhy: \"connect() was given options after the client was bound to a database.\",\n\t\t\t\t\tfix: \"Call connect() without options, or create a new client for another database.\",\n\t\t\t\t\tmeta: { extension: \"mysql\" }\n\t\t\t\t});\n\t\t\t\tconst runtime = getRuntime();\n\t\t\t\tawait connectPromise;\n\t\t\t\tif (closed) throw closedError();\n\t\t\t\treturn runtime;\n\t\t\t}\n\t\t\tbackgroundConnectError = void 0;\n\t\t\tif (bindingInput !== void 0) binding = resolveMysqlBinding(bindingInput);\n\t\t\tif (binding === void 0) throw mysqlClientError(\"RUNTIME.BINDING_MISSING\", \"MySQL binding not configured. Pass url to mysql(...) or call db.connect({ url }).\", { meta: { extension: \"mysql\" } });\n\t\t\tconst runtime = getRuntime();\n\t\t\tif (driverConnected) return runtime;\n\t\t\tawait connectDriver(binding);\n\t\t\tif (closed) throw closedError();\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\treturn withTransaction(workRuntime, (txCtx) => {\n\t\t\t\treturn fn(withTransactionMembers(txCtx, buildMysqlTransactionMembers({\n\t\t\t\t\tcontext,\n\t\t\t\t\tcollections: options.collections,\n\t\t\t\t\trawCodecInferer: stack.adapter.rawCodecInferer,\n\t\t\t\t\tenums,\n\t\t\t\t\ttoSql,\n\t\t\t\t\tprepareRuntime: workRuntime\n\t\t\t\t}, txCtx)));\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 { MysqlRuntimeImpl, mysql as default };\n\n//# sourceMappingURL=runtime.mjs.map"],"mappings":";;;;;;;;;;;;;;;AAeA,SAAS,iBAAiB,MAAM,SAAS,SAAS;CACjD,OAAO,gBAAgB,MAAM,SAAS,OAAO;AAC9C;AAGA,SAAS,WAAW,SAAS,MAAM;CAClC,OAAO,gBAAgB,2BAA2B,SAAS,EAAE,MAAM;EAClE,WAAW;EACX,GAAG;CACJ,EAAE,CAAC;AACJ;;AAEA,SAAS,iBAAiB,KAAK;CAC9B,MAAM,UAAU,IAAI,KAAK;CACzB,IAAI,QAAQ,WAAW,GAAG,MAAM,WAAW,wCAAwC,EAAE,QAAQ,YAAY,CAAC;CAC1G,IAAI;CACJ,IAAI;EACH,SAAS,IAAI,IAAI,OAAO;CACzB,QAAQ;EACP,MAAM,WAAW,iCAAiC,EAAE,QAAQ,kBAAkB,CAAC;CAChF;CACA,IAAI,OAAO,aAAa,UAAU,MAAM,WAAW,+BAA+B;EACjF,QAAQ;EACR,UAAU,OAAO;CAClB,CAAC;CACD,OAAO;AACR;AACA,SAAS,oBAAoB,OAAO;CACnC,OAAO;EACN,MAAM;EACN,KAAK,iBAAiB,MAAM,GAAG;CAChC;AACD;AACA,SAAS,4BAA4B,SAAS;CAC7C,OAAO,QAAQ,QAAQ,KAAK,IAAI,KAAK,IAAI,oBAAoB,EAAE,KAAK,QAAQ,IAAI,CAAC;AAClF;AAGA,MAAM,qBAAqB,KAAK,qBAAqB;;AAErD,SAAS,qBAAqB,QAAQ;CACrC,MAAM,SAAS,mBAAmB,MAAM;CACxC,IAAI,kBAAkB,KAAK,QAAQ,MAAM,iBAAiB,4BAA4B,yB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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-targets/mysql/9-facade/dist/runtime.mjs"],"sourcesContent":["import { i as validateMysqlContract, t as buildMysqlStaticContext } from \"./mysql-static-1yYsheIU.mjs\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport mysqlAdapter from \"@internal/adapter-mysql/runtime\";\nimport mysqlDriver from \"@internal/driver-mysql/runtime\";\nimport { UNBOUND_NAMESPACE_ID } from \"@internal/framework-components/ir\";\nimport { createRawLane, sql } from \"@internal/sql-builder/runtime\";\nimport { orm, prepareQuery } from \"@internal/sql-orm-client\";\nimport { SqlRuntimeBase, activitySource, createExecutionContext, createSqlExecutionStack, delegatingActivitySource, delegatingRuntime, toRuntimeOptions, withTransaction, withTransactionMembers } from \"@internal/sql-runtime\";\nimport mysqlTarget from \"@internal/target-mysql/runtime\";\nimport { assertDefined } from \"@internal/utils/assertions\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { InternalError } from \"@internal/utils/internal-error\";\nimport { structuredError } from \"@internal/utils/structured-error\";\nimport { type } from \"arktype\";\n//#region src/errors.ts\nfunction mysqlClientError(code, message, options) {\n\treturn structuredError(code, message, options);\n}\n//#endregion\n//#region src/runtime/binding.ts\nfunction invalidUrl(message, meta) {\n\treturn structuredError(\"RUNTIME.BINDING_INVALID\", message, { meta: {\n\t\textension: \"mysql\",\n\t\t...meta\n\t} });\n}\n/** Checks `url` as the Postgres facade checks its own: a non-empty URL that parses, with the `mysql://` scheme. No part of the URL goes into the error. */\nfunction validateMysqlUrl(url) {\n\tconst trimmed = url.trim();\n\tif (trimmed.length === 0) throw invalidUrl(\"MySQL URL must be a non-empty string\", { reason: \"empty url\" });\n\tlet parsed;\n\ttry {\n\t\tparsed = new URL(trimmed);\n\t} catch {\n\t\tthrow invalidUrl(\"MySQL URL must be a valid URL\", { reason: \"unparseable url\" });\n\t}\n\tif (parsed.protocol !== \"mysql:\") throw invalidUrl(\"MySQL URL must use mysql://\", {\n\t\treason: \"wrong scheme\",\n\t\treceived: parsed.protocol\n\t});\n\treturn trimmed;\n}\nfunction resolveMysqlBinding(input) {\n\treturn {\n\t\tkind: \"url\",\n\t\turl: validateMysqlUrl(input.url)\n\t};\n}\nfunction resolveOptionalMysqlBinding(options) {\n\treturn options.url === void 0 ? void 0 : resolveMysqlBinding({ url: options.url });\n}\n//#endregion\n//#region src/runtime/mysql-options.ts\nconst streamOptionSchema = type(\"boolean | undefined\");\n/** Checks `stream` when the factory is called, as the Postgres facade checks `cursor`. */\nfunction validateStreamOption(stream) {\n\tconst result = streamOptionSchema(stream);\n\tif (result instanceof type.errors) throw mysqlClientError(\"RUNTIME.ARGUMENT_INVALID\", \"Invalid stream option\", {\n\t\twhy: result.summary,\n\t\tfix: \"Pass stream: true to stream rows as they arrive, or leave stream unset to read each whole result first.\",\n\t\tmeta: {\n\t\t\textension: \"mysql\",\n\t\t\thelper: \"mysql\",\n\t\t\targument: \"stream\",\n\t\t\treceived: stream\n\t\t}\n\t});\n\treturn result ?? false;\n}\n//#endregion\n//#region src/runtime/mysql-runtime.ts\nvar MysqlRuntimeImpl = class extends SqlRuntimeBase {};\n//#endregion\n//#region src/runtime/mysql.ts\nfunction mysqlOrm(orm) {\n\tconst namespace = orm[UNBOUND_NAMESPACE_ID];\n\tassertDefined(namespace, \"the unbound namespace always exists on a mysql builder output\");\n\treturn blindCast(Reflect.get(namespace, \"fragment\") === void 0 ? Object.create(namespace, { fragment: { value: Reflect.get(orm, \"fragment\") } }) : namespace);\n}\n/**\n* Builds the members of a MySQL transaction over `txCtx`, so every statement they run goes through the transaction. Preparing sends nothing to the database, so `prepare` uses `prepareRuntime`; the prepared statement runs on the queryable it is given.\n*/\nfunction buildMysqlTransactionMembers(options, txCtx) {\n\tconst { context, collections, rawCodecInferer, enums, toSql, prepareRuntime } = options;\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 mysql builder output\");\n\treturn {\n\t\tsql: blindCast(sqlNamespace),\n\t\torm: mysqlOrm(orm({\n\t\t\truntime: {\n\t\t\t\tquery(plan) {\n\t\t\t\t\treturn txCtx.query(plan);\n\t\t\t\t},\n\t\t\t\texecute(plan) {\n\t\t\t\t\treturn txCtx.execute(plan);\n\t\t\t\t},\n\t\t\t\t[activitySource]: delegatingActivitySource(() => txCtx)\n\t\t\t},\n\t\t\tcontext,\n\t\t\t...ifDefined(\"collections\", collections)\n\t\t})),\n\t\traw: createRawLane({\n\t\t\tcontext,\n\t\t\trawCodecInferer\n\t\t}),\n\t\tenums,\n\t\ttoSql,\n\t\tprepare(declaration, callback) {\n\t\t\treturn prepareQuery(prepareRuntime, declaration, callback);\n\t\t}\n\t};\n}\n/**\n* Creates a lazy MySQL 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-mysql/static';\n* import mysql from '@prisma/orm-mysql/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 = mysql({ contract, url: process.env.DATABASE_URL });\n* ```\n*/\nfunction mysql(options) {\n\tconst stream = validateStreamOption(options.stream);\n\tconst contract = validateMysqlContract(options.contract);\n\tlet binding = resolveOptionalMysqlBinding(options);\n\tconst stack = createSqlExecutionStack({\n\t\ttarget: mysqlTarget,\n\t\tadapter: mysqlAdapter,\n\t\tdriver: mysqlDriver,\n\t\textensions: options.extensions ?? []\n\t});\n\tconst context = createExecutionContext({\n\t\tcontract,\n\t\tstack,\n\t\tdriver: mysqlDriver\n\t});\n\tconst { sql, raw: rawSqlTag, enums, toSql } = buildMysqlStaticContext(contract, context, stack);\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 closedError = () => mysqlClientError(\"DRIVER.NOT_CONNECTED\", \"MySQL client is closed\", { meta: { extension: \"mysql\" } });\n\tconst connectDriver = async (resolvedBinding) => {\n\t\tif (driverConnected) return;\n\t\tif (!runtimeDriver) throw new InternalError(\"MySQL 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 closedError();\n\t\tif (backgroundConnectError !== void 0) throw backgroundConnectError;\n\t\tif (runtimeInstance) return runtimeInstance;\n\t\tconst adapter = stack.adapter.create(stack);\n\t\tconst driver = stack.driver.create({\n\t\t\tstream,\n\t\t\t...ifDefined(\"poolOptions\", options.poolOptions)\n\t\t});\n\t\townedDispose = () => driver.close();\n\t\truntimeDriver = driver;\n\t\tif (binding !== void 0) connectDriver(binding).catch(() => void 0);\n\t\truntimeInstance = new MysqlRuntimeImpl({\n\t\t\tcontext,\n\t\t\tadapter,\n\t\t\tdriver,\n\t\t\t...toRuntimeOptions(options),\n\t\t\tcloseRefusal: \"at-once\"\n\t\t});\n\t\treturn runtimeInstance;\n\t};\n\tconst workRuntime = delegatingRuntime(getRuntime);\n\tconst orm$1 = mysqlOrm(orm({\n\t\tcontext,\n\t\t...ifDefined(\"collections\", options.collections),\n\t\truntime: workRuntime\n\t}));\n\tfunction prepare(declaration, callback) {\n\t\treturn prepareQuery(workRuntime, declaration, callback);\n\t}\n\treturn {\n\t\tsql,\n\t\torm: orm$1,\n\t\tenums,\n\t\traw: rawSqlTag,\n\t\ttoSql,\n\t\tcontext,\n\t\tcontract,\n\t\tstack,\n\t\tquery(plan, execOptions) {\n\t\t\treturn workRuntime.query(plan, execOptions);\n\t\t},\n\t\texecute(plan, execOptions) {\n\t\t\treturn workRuntime.execute(plan, execOptions);\n\t\t},\n\t\tasync connect(bindingInput) {\n\t\t\tif (closed) throw closedError();\n\t\t\tif (driverConnected || connectPromise) {\n\t\t\t\tif (bindingInput !== void 0) throw mysqlClientError(\"DRIVER.ALREADY_CONNECTED\", \"MySQL client is already bound\", {\n\t\t\t\t\twhy: \"connect() was given options after the client was bound to a database.\",\n\t\t\t\t\tfix: \"Call connect() without options, or create a new client for another database.\",\n\t\t\t\t\tmeta: { extension: \"mysql\" }\n\t\t\t\t});\n\t\t\t\tconst runtime = getRuntime();\n\t\t\t\tawait connectPromise;\n\t\t\t\tif (closed) throw closedError();\n\t\t\t\treturn runtime;\n\t\t\t}\n\t\t\tbackgroundConnectError = void 0;\n\t\t\tif (bindingInput !== void 0) binding = resolveMysqlBinding(bindingInput);\n\t\t\tif (binding === void 0) throw mysqlClientError(\"RUNTIME.BINDING_MISSING\", \"MySQL binding not configured. Pass url to mysql(...) or call db.connect({ url }).\", { meta: { extension: \"mysql\" } });\n\t\t\tconst runtime = getRuntime();\n\t\t\tif (driverConnected) return runtime;\n\t\t\tawait connectDriver(binding);\n\t\t\tif (closed) throw closedError();\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\treturn withTransaction(workRuntime, (txCtx) => {\n\t\t\t\treturn fn(withTransactionMembers(txCtx, buildMysqlTransactionMembers({\n\t\t\t\t\tcontext,\n\t\t\t\t\tcollections: options.collections,\n\t\t\t\t\trawCodecInferer: stack.adapter.rawCodecInferer,\n\t\t\t\t\tenums,\n\t\t\t\t\ttoSql,\n\t\t\t\t\tprepareRuntime: workRuntime\n\t\t\t\t}, txCtx)));\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 { MysqlRuntimeImpl, mysql as default };\n\n//# sourceMappingURL=runtime.mjs.map"],"mappings":";;;;;;;;;;;;;;;AAeA,SAAS,iBAAiB,MAAM,SAAS,SAAS;CACjD,OAAO,gBAAgB,MAAM,SAAS,OAAO;AAC9C;AAGA,SAAS,WAAW,SAAS,MAAM;CAClC,OAAO,gBAAgB,2BAA2B,SAAS,EAAE,MAAM;EAClE,WAAW;EACX,GAAG;CACJ,EAAE,CAAC;AACJ;;AAEA,SAAS,iBAAiB,KAAK;CAC9B,MAAM,UAAU,IAAI,KAAK;CACzB,IAAI,QAAQ,WAAW,GAAG,MAAM,WAAW,wCAAwC,EAAE,QAAQ,YAAY,CAAC;CAC1G,IAAI;CACJ,IAAI;EACH,SAAS,IAAI,IAAI,OAAO;CACzB,QAAQ;EACP,MAAM,WAAW,iCAAiC,EAAE,QAAQ,kBAAkB,CAAC;CAChF;CACA,IAAI,OAAO,aAAa,UAAU,MAAM,WAAW,+BAA+B;EACjF,QAAQ;EACR,UAAU,OAAO;CAClB,CAAC;CACD,OAAO;AACR;AACA,SAAS,oBAAoB,OAAO;CACnC,OAAO;EACN,MAAM;EACN,KAAK,iBAAiB,MAAM,GAAG;CAChC;AACD;AACA,SAAS,4BAA4B,SAAS;CAC7C,OAAO,QAAQ,QAAQ,KAAK,IAAI,KAAK,IAAI,oBAAoB,EAAE,KAAK,QAAQ,IAAI,CAAC;AAClF;AAGA,MAAM,qBAAqB,KA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;KAC/B;KACA;KACA,gBAAgB;IACjB,GAAG,KAAK,CAAC,CAAC;GACX,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"}
package/dist/static.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { n as contractFromJson, r as mysqlStatic } from "./mysql-static-DTHc0Eoh-CLml_HCC.mjs";
1
+ import { n as contractFromJson, r as mysqlStatic } from "./mysql-static-1yYsheIU-DWNhi8vn.mjs";
2
2
  export { contractFromJson, mysqlStatic as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/orm-mysql",
3
- "version": "8.0.0-rc.22-dev.12",
3
+ "version": "8.0.0-rc.22-dev.13",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -10,18 +10,18 @@
10
10
  "skills"
11
11
  ],
12
12
  "dependencies": {
13
- "@prisma/orm-family-sql": "8.0.0-rc.22-dev.12",
14
- "@prisma/orm-framework": "8.0.0-rc.22-dev.12",
15
- "@prisma/orm-target-mysql": "8.0.0-rc.22-dev.12",
16
- "@prisma/orm-toolchain": "8.0.0-rc.22-dev.12",
13
+ "@prisma/orm-family-sql": "8.0.0-rc.22-dev.13",
14
+ "@prisma/orm-framework": "8.0.0-rc.22-dev.13",
15
+ "@prisma/orm-target-mysql": "8.0.0-rc.22-dev.13",
16
+ "@prisma/orm-toolchain": "8.0.0-rc.22-dev.13",
17
17
  "arktype": "^2.2.2",
18
18
  "pathe": "^2.0.3",
19
19
  "temporal-spec": "1.0.1"
20
20
  },
21
21
  "devDependencies": {
22
- "@internal/mysql": "8.0.0-rc.22-dev.12",
23
- "@repo/tsconfig": "8.0.0-rc.22-dev.12",
24
- "@repo/tsdown": "8.0.0-rc.22-dev.12",
22
+ "@internal/mysql": "8.0.0-rc.22-dev.13",
23
+ "@repo/tsconfig": "8.0.0-rc.22-dev.13",
24
+ "@repo/tsdown": "8.0.0-rc.22-dev.13",
25
25
  "tsdown": "0.22.14",
26
26
  "typescript": "5.9.3"
27
27
  },
@@ -15,7 +15,7 @@ description: >-
15
15
  ORM 7 or earlier (schema.prisma + @prisma/client).
16
16
  metadata:
17
17
  library: '@prisma/orm-mysql'
18
- library_version: '8.0.0-rc.22-dev.12'
18
+ library_version: '8.0.0-rc.22-dev.13'
19
19
  version: '2026-09-12'
20
20
  ---
21
21
 
@@ -117,6 +117,8 @@ model Post {
117
117
 
118
118
  Then run `pnpm prisma contract emit` (or rely on the Vite plugin — see `references/build.md`). Specify cascade behaviour explicitly with `onDelete` / `onUpdate`; the default is `Restrict`.
119
119
 
120
+ **Integer, decimal, float, text, boolean and binary types.** On PostgreSQL, `Int`, `BigInt`, `Float`, `Decimal`, `String`, `Boolean` and `Bytes` are convenience types: bare, each is the usual type (`Int` an `int4`, `BigInt` an `int8` read as a `bigint`, `Decimal` a `numeric` read as decimal text, `String` a `text`). An optional `storage` chooses another database type, and `BigInt` also takes `as`: `Int(storage: int2)`, `BigInt(as: number)` (an `int8` read as a `number` in the safe-integer range), `BigInt(storage: numeric)` (an integer of any size, read as a `bigint`), `Float(storage: float4)`, `Decimal(precision: 10, scale: 2)`, `String(storage: varchar, length: 12)`, `String(storage: char, length: 3)`. `String(length: 12)` is refused: `length` applies only to `varchar` and `char`. The contract stores the explicit type each call chooses, named after the database type (`Int2`, `Int4`, `Int8BigInt`, `Int8Number`, `NumericString`, `NumericBigInt`, `Float4`, `Float8`, `Text`, `Varchar`, `Char`, `Bool`, `Bytea`), and writing that type directly is the same. `SmallInt`, `BigIntNumber`, `Numeric`, `UnboundedInt`, `Real` and `VarChar` are deprecated names of `Int2`, `Int8Number`, `NumericString`, `NumericBigInt`, `Float4` and `Varchar`, and warn `PSL_DEPRECATED_SCALAR_NAME`. In a TypeScript contract: `type.BigInt({ as: 'number' })`, `type.String({ storage: 'varchar', length: 64 })`.
121
+
120
122
  **Date and time types.** On PostgreSQL, write a field with a convenience type named for what it means: `DateTime` (a moment in time, a `timestamptz(3)` read as a JavaScript `Date`), `Date` (a calendar date, read as a string such as `"2024-02-29"`), `Time` (a time of day, read as a string) or `Duration` (an ISO 8601 duration string such as `"P1M"`). None needs `Temporal`. Optional arguments choose another explicit type: `as`, the value the application reads (`jsDate`, `temporal` or `string` for `DateTime`; `string` or `temporal` for `Date` and `Time`; `string` or `parts` for `Duration`), `storage`, the database type that stores it (`timestamptz` or `timestamp` for `DateTime`; `time` or, with `as: string`, `timetz` for `Time`), and `precision`: `DateTime(as: temporal)`, `DateTime(storage: timestamp)`, `Time(precision: 0)`. The contract stores only the explicit type, and `contract print` writes it; the full table is [Scalar types](https://github.com/prisma/orm/blob/main/docs/reference/scalar-types.md). SQLite has the same four types with the same defaults, all stored as text: `DateTime` reads a `Date`, `DateTime(as: temporal)` a `Temporal.Instant` and `DateTime(as: string)` the stored text `"2024-01-01T00:00:00.000Z"`; `Date` and `Time` read `"2024-02-29"` and `"09:30:00.000"`, or `Temporal.PlainDate` and `Temporal.PlainTime` with `as: temporal`; `Duration` reads an ISO 8601 duration. SQLite has no `storage` choices and no `precision`: an instant and a time hold milliseconds. MySQL has the same four types with the same defaults: `DateTime` is a `datetime(3)` read as a `Date`, `storage: timestamp` picks a `timestamp` column (1970 to 2038), and `as: temporal` and `as: string` default to `precision: 6`; `Date` and `Time` read `"2024-02-29"` and `"09:30:00"`; `Duration` is ISO 8601 text in a `varchar(191)`. Every MySQL instant is UTC, and a value written with more fraction digits than its column holds is cut to the column's precision, not rounded, but a value with digits below a microsecond (a `Temporal` value ending in `.123456789`) is refused, so round it to microseconds first; a column with no written precision holds whole seconds. `Time(3)` is refused, because the first argument is `as`; write `Time(precision: 3)`. In a TypeScript contract the helpers take one object: `type.DateTime({ as: 'string', precision: 6 })`, `type.Time({ storage: 'timetz' })`.
121
123
 
122
124
  **Temporal columns.** On PostgreSQL, `DateTemporal`, `TimestampTemporal(p)`, `TimestampInstant(p)`, `TimestamptzTemporal(p)` and `TimeTemporal(p)`, on SQLite `DatetimeTemporal`, `DateTemporal` and `TimeTemporal`, on MySQL `DatetimeTemporal(p)`, `TimestampTemporal(p)`, `DateTemporal` and `TimeTemporal(p)` (and a convenience type with `as: temporal` on any of them) read and write `Temporal` values (`Temporal.PlainDate`, `PlainDateTime`, `Instant` for both instant types, `PlainTime`), never JavaScript `Date`. They need a global `Temporal` at query time: Node.js 26.8.2 and later ship `globalThis.Temporal`; 26.8.1 and earlier — including every 22 and 24 release — do not, and the first read or write of such a column throws `RUNTIME.TEMPORAL_UNAVAILABLE`. On those runtimes either `import 'temporal-polyfill/full/global'` before the first query (add `temporal-polyfill` as a dependency) or author the column as `DateString` / `TimestampString(p)` / `TimestamptzString(p)` / `TimeString(p)`, which carry ISO 8601 text, the same on every server (`2024-01-01T00:00:00Z` for a `timestamptz`, the instant in UTC), and need no `Temporal`, or as `TimestamptzJsDate(p)` / `TimestampJsDate(p)`, which read a JavaScript `Date`. `IntervalParts(p)` reads `{ months, days, micros }` and `IntervalString(p)` an ISO 8601 duration such as `P1Y2M`. `prisma contract emit`, `prisma db init` and the other commands need no global `Temporal`: the Postgres, SQLite and MySQL targets load `temporal-polyfill` as a fallback `Temporal` for the control plane, and set no global. `temporal-polyfill` is a required peer dependency of `@prisma/orm-postgres`, `@prisma/orm-sqlite` and `@prisma/orm-mysql`. npm, pnpm and bun install it automatically. With Yarn, add `temporal-polyfill` (`^1.0.4`) to the project's dependencies, or the commands fail because Node.js cannot find the package. That fallback is held once per process. An application that loads control-plane code in its own process, such as server code under `vite dev` with the Prisma Vite plugin or a script that calls the control client, decodes dates without its own `Temporal`, and then fails in production. An application that uses the Temporal codecs must load its own `Temporal`. A TypeScript contract file that constructs a `Temporal` value must load an implementation too.
@@ -162,7 +164,7 @@ An alias is expanded into each field that uses it: the column stores the alias's
162
164
 
163
165
  Values the client generates are written `@onCreate(fn())` and `@onUpdate(fn())`: `id String @id @onCreate(uuid(7))`, `slug String @onCreate(nanoid(12))`, `updatedAt DateTime @onCreate(now()) @onUpdate(now())`. `@default(...)` is a database default only (`now()`, `autoincrement()`, a literal, or `` sql`...` ``); `@default(uuid())` is refused with `PSL_GENERATOR_IN_DEFAULT`. In the TS builder, write `.onCreate(gen.uuid(7))` and `.onUpdate(gen.now())`. Column defaults and generators can sit on one field: `@default(now()) @onCreate(now())`.
164
166
 
165
- In the TS builder, an alias is a constant passed as the field, because field builders are immutable: `const Slug = field.column(type.VarChar(64))`, `const UpdatedAt = field.column(type.TimestampString(3)).onCreate(gen.now()).onUpdate(gen.now())`, then `slug: Slug, updatedAt: UpdatedAt.default(now())`. `type.*` has a helper for every PSL type constructor, and the contributed aliases are `type.temporal.CreatedAt()`, `type.temporal.UpdatedAt()` and the identifier aliases such as `type.Ulid()` (`type.sql.Ulid()` on every SQL target), used as `field.column(type.temporal.UpdatedAt())` and `field.column(type.Ulid()).id().onCreate(gen.ulid())`. A definition has no `types` key (`CONTRACT.TYPES_KEY_REMOVED`), and `field.namedType(...)` takes only an enum handle.
167
+ In the TS builder, an alias is a constant passed as the field, because field builders are immutable: `const Slug = field.column(type.String({ storage: 'varchar', length: 64 }))`, `const UpdatedAt = field.column(type.TimestampString(3)).onCreate(gen.now()).onUpdate(gen.now())`, then `slug: Slug, updatedAt: UpdatedAt.default(now())`. `type.*` has a helper for every PSL type constructor, and the contributed aliases are `type.temporal.CreatedAt()`, `type.temporal.UpdatedAt()` and the identifier aliases such as `type.Ulid()` (`type.sql.Ulid()` on every SQL target), used as `field.column(type.temporal.UpdatedAt())` and `field.column(type.Ulid()).id().onCreate(gen.ulid())`. A definition has no `types` key (`CONTRACT.TYPES_KEY_REMOVED`), and `field.namedType(...)` takes only an enum handle.
166
168
 
167
169
  Note: scalar lists (e.g. `String[]`) are gated on the target's `sql.scalarList` capability — PostgreSQL declares it, so `tags String[]` lowers to an array column (with a generated no-NULL-elements check; write `tags String?[]` for a list whose elements may be null, which gets no such check); SQLite does not, and rejects the field with `PSL_SCALAR_LIST_UNSUPPORTED_TARGET`. Implicit Prisma-ORM many-to-many (list navigation on both sides without a join model) is rejected by the SQL interpreter — declare the join model explicitly and the ORM traverses it for you (`references/queries.md`). Composite/embeddable types (`type Address { ... }` with `address Address` on a model) are supported: the interpreter lowers them to storage value objects, at `storage.namespaces.<ns>.entries.valueObject`, and stores them as `jsonb` columns. See *Workflow — Value objects* below.
168
170
 
@@ -514,7 +516,7 @@ Infer captures indexes at full fidelity — expression, partial (`where:`), uniq
514
516
  5. **Confusing the config `extensions` with the TS builder's `extensions`.** Same packs, two surfaces, one field name but two shapes: `ormConfig({ extensions: [pgvector] })` (array of *control* descriptors from `@internal/extension-<name>/control`) versus `defineContract({ extensions: { pgvector } })` (record of *pack* descriptors from `@internal/extension-<name>/pack`).
515
517
  6. **Writing a flat `prisma.config.ts`.** `export default defineConfig({ contract, extensions })` from the target config alone is the pre-rc.4 shape and fails with `CONFIG.VERSION_MARKER_MISSING`. Wrap it: `definePrismaConfig({ orm: ormConfig({...}) })`.
516
518
  7. **Renaming a model or field and expecting the planner to detect it.** The contract does not record renames, so the planner sees a destructive drop+add. State the rename on the command line with `--rename old:new` on `migration plan` or `db update` (see `references/migrations.md`); the planner then renames instead of dropping. Do not invent a rename attribute in the contract source.
517
- 8. **Quoting a type-constructor argument.** A type constructor's argument is a value, read as an attribute argument is. Write a length, precision or scale as a plain whole number: `VarChar(255)`, `Numeric(10, 2)`. `VarChar("255")` is refused with `Expected a number; write 255`, and on Postgres `VarChar(255.0)` is refused too, because a number with a fraction is not a 32-bit integer.
519
+ 8. **Quoting a type-constructor argument.** A type constructor's argument is a value, read as an attribute argument is. Write a length, precision or scale as a plain whole number: `Varchar(255)`, `NumericString(10, 2)`, `String(storage: varchar, length: 255)`. `Varchar("255")` is refused with `Expected a number; write 255`, and on Postgres `Varchar(255.0)` is refused too, because a number with a fraction is not a 32-bit integer.
518
520
 
519
521
  ## What Prisma 8 doesn't do yet
520
522
 
@@ -91,7 +91,7 @@ Treat the rendered import lines as framework-managed on both targets:
91
91
  | A database that changes only through migrations, such as production | `migration plan` + `db migrate` | It must run a reviewed, hashed migration. |
92
92
  | A deploy says there is no migration path, or `MIGRATION.MARKER_MISMATCH` | See *A database whose marker is not in the migration graph* | Never reset the database. |
93
93
  | Adding a column that needs a backfill | `migration plan --backfill Model.field` (writes `placeholder`), edit `migration.ts`, self-emit, then `db migrate` | `db update` does not author data transforms; the formal path does. Without `--backfill`, existing rows get a temporary value. |
94
- | Changing a field's type so values may not survive | `migration plan --convert Model.field`, fill `using`, self-emit, `db migrate` | Or `--delete Model.field` to let the database cast; the cast may cut or round values (Postgres cuts a longer text to a shorter `VarChar`), and a value it cannot cast fails the apply. |
94
+ | Changing a field's type so values may not survive | `migration plan --convert Model.field`, fill `using`, self-emit, `db migrate` | Or `--delete Model.field` to let the database cast; the cast may cut or round values (Postgres cuts a longer text to a shorter `varchar`), and a value it cannot cast fails the apply. |
95
95
  | Recovering from drift (DB diverged from contract) | `db sign` after manual fix, *or* `migration plan` if PN can plan the fix | Depends on which side is right. See *Recover from drift* below. |
96
96
 
97
97
  ## Dev → ship transition (the `db` ref pattern)
@@ -504,17 +504,17 @@ const byKind = await db.orm.public.User
504
504
  | --- | --- | --- |
505
505
  | `count()` | `number` | `0` |
506
506
  | `countBigInt()` | `bigint` | `0n` |
507
- | `sum(field)` over `int2` / `int4` / `int8` / `BigIntNumber` | `number \| null` | `null` (SQL `SUM` over zero rows is `NULL`) |
507
+ | `sum(field)` over `int2` / `int4` / `int8` / `BigInt(as: number)` | `number \| null` | `null` (SQL `SUM` over zero rows is `NULL`) |
508
508
  | `sumBigInt(field)` over any integer | `bigint \| null` | `null` |
509
509
  | `sum(field)` over `float4` / `float8` | `number \| null` | `null` |
510
510
  | `sum(field)` over `numeric` | decimal `string \| null` | `null` |
511
- | `sum(field)` over `UnboundedInt` | `bigint \| null` — that column's own family | `null` |
511
+ | `sum(field)` over `BigInt(storage: numeric)` | `bigint \| null` — that column's own family | `null` |
512
512
  | `avg(field)` over any integer | `number \| null` | `null` |
513
513
  | `avgDecimal(field)` over any integer or `numeric` | decimal `string \| null` | `null` |
514
514
  | `avg(field)` over a float | `number \| null` | `null` |
515
515
  | `min(field)` / `max(field)` | the column's own type `\| null` — `text` where the column is `varchar` | `null` |
516
516
 
517
- **`count()`, and `sum` over an integer column, throw outside ±(2^53 − 1) — they never round.** Those two are the results a guarded integer codec produces. The rows above the guard does not reach: `sum` over `numeric`, `UnboundedInt`, or a float column, and every `avg`, which is a fraction already. The error is `RUNTIME.DECODE_FAILED` (`… value must be an integer within the safe integer range, got …`), and it fires on the include path too. That is the trade the defaults make: a `number` you can compare, serialise, and do arithmetic with, and a loud failure instead of a quietly wrong total. Switch that one call to `sumBigInt` / `countBigInt` where the magnitude is real.
517
+ **`count()`, and `sum` over an integer column, throw outside ±(2^53 − 1) — they never round.** Those two are the results a guarded integer codec produces. The rows above the guard does not reach: `sum` over `numeric`, `BigInt(storage: numeric)`, or a float column, and every `avg`, which is a fraction already. The error is `RUNTIME.DECODE_FAILED` (`… value must be an integer within the safe integer range, got …`), and it fires on the include path too. That is the trade the defaults make: a `number` you can compare, serialise, and do arithmetic with, and a loud failure instead of a quietly wrong total. Switch that one call to `sumBigInt` / `countBigInt` where the magnitude is real.
518
518
 
519
519
  **Float and Decimal columns keep their own family.** `sum` over `numeric` is still a decimal string, and `sum` over `float8` still a `number` — the defaults policy is about integers, and a column whose author chose `numeric` already chose its representation.
520
520
 
@@ -219,7 +219,7 @@ Then run the snippet from *Your first arc* above against the `User` model. When
219
219
 
220
220
  ## Workflow — Brownfield-DB (existing database, no contract)
221
221
 
222
- The concept: against an existing database with no PN contract, `contract infer` walks the live schema (tables, columns, indexes — including expression and partial ones — constraints, and RLS enablement + policies) and writes a PSL contract that describes it. Where authoring would generate a CHECK constraint the database does not carry (the element-non-null check on a list column), infer writes the list with nullable elements (`String?[]`), which derives no such check, so the contract declares exactly what the database enforces. The reverse gap is closed too: a hand-written CHECK constraint the database enforces that authoring would never have generated comes back as `@@check(expression: <reprint>, map: "<name>")`, so it is a declared object from the first pull instead of an invisible extra a later destructive plan could drop. That inferred check warns (`PN_EXACT_NAME_BODY_COMPARISON`) the next time you run `contract emit` — expected, not a defect: the warning fires on any `map:` body regardless of who wrote it, and the comparison stays sound because both sides are Postgres's own reprint. Date and time columns come back as the convenience types with their defaults, and only the arguments that differ: `timestamptz(3)` as `DateTime` (a JavaScript `Date`), a `timestamptz` with no declared precision as `DateTime(precision: 6)`, `timestamp(3)` as `DateTime(storage: timestamp)`, `date` as `Date`, `time` as `Time` and `interval` as `Duration` (ISO strings). A `Date` holds milliseconds, so a timestamp column whose values use microseconds reads with them dropped: change such a field to `DateTime(as: temporal)` or `DateTime(as: string)` to keep them. The result is a *starting point*, not the final contract — review and clean it up, then `db sign` to record the current contract hash as the marker (instead of letting `db init` try to recreate the schema from scratch). By default `db sign` also sets the `db` ref and stores the contract snapshot, so the next `migration plan` chains from the adopted schema — even when the database is named with `--db`. `--advance-ref <name>` writes another ref instead and `--no-advance-ref` writes none; in either case the next plan needs `--from` or a `db` ref you set yourself.
222
+ The concept: against an existing database with no PN contract, `contract infer` walks the live schema (tables, columns, indexes — including expression and partial ones — constraints, and RLS enablement + policies) and writes a PSL contract that describes it. Where authoring would generate a CHECK constraint the database does not carry (the element-non-null check on a list column), infer writes the list with nullable elements (`String?[]`), which derives no such check, so the contract declares exactly what the database enforces. The reverse gap is closed too: a hand-written CHECK constraint the database enforces that authoring would never have generated comes back as `@@check(expression: <reprint>, map: "<name>")`, so it is a declared object from the first pull instead of an invisible extra a later destructive plan could drop. That inferred check warns (`PN_EXACT_NAME_BODY_COMPARISON`) the next time you run `contract emit` — expected, not a defect: the warning fires on any `map:` body regardless of who wrote it, and the comparison stays sound because both sides are Postgres's own reprint. Columns come back as the convenience types with their defaults, and only the arguments that differ: `int2` as `Int(storage: int2)`, `numeric(10,2)` as `Decimal(precision: 10, scale: 2)`, `varchar(12)` as `String(storage: varchar, length: 12)`, `timestamptz(3)` as `DateTime` (a JavaScript `Date`), a `timestamptz` with no declared precision as `DateTime(precision: 6)`, `timestamp(3)` as `DateTime(storage: timestamp)`, `date` as `Date`, `time` as `Time` and `interval` as `Duration` (ISO strings). A `Date` holds milliseconds, so a timestamp column whose values use microseconds reads with them dropped: change such a field to `DateTime(as: temporal)` or `DateTime(as: string)` to keep them. The result is a *starting point*, not the final contract — review and clean it up, then `db sign` to record the current contract hash as the marker (instead of letting `db init` try to recreate the schema from scratch). By default `db sign` also sets the `db` ref and stores the contract snapshot, so the next `migration plan` chains from the adopted schema — even when the database is named with `--db`. `--advance-ref <name>` writes another ref instead and `--no-advance-ref` writes none; in either case the next plan needs `--from` or a `db` ref you set yourself.
223
223
 
224
224
  ```bash
225
225
  mkdir my-app && cd my-app