viborm 1.7.0 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{adapter-namespace-BMss0hKo.mjs → adapter-namespace-VikEzb7o.mjs} +2 -2
- package/dist/{adapter-namespace-BMss0hKo.mjs.map → adapter-namespace-VikEzb7o.mjs.map} +1 -1
- package/dist/adapters.d.mts +1 -1
- package/dist/adapters.mjs +1 -1
- package/dist/{batch-refs-DWMYN0fw.mjs → batch-refs-ZHBzfoBC.mjs} +2 -2
- package/dist/{batch-refs-DWMYN0fw.mjs.map → batch-refs-ZHBzfoBC.mjs.map} +1 -1
- package/dist/{builder-B4n-7I7Q.mjs → builder-CEQ2TIq7.mjs} +2 -2
- package/dist/{builder-B4n-7I7Q.mjs.map → builder-CEQ2TIq7.mjs.map} +1 -1
- package/dist/bun-sql.d.mts +1 -1
- package/dist/bun-sql.mjs +1 -1
- package/dist/bun-sqlite.d.mts +1 -1
- package/dist/bun-sqlite.mjs +1 -1
- package/dist/cache/cloudflare-kv.d.mts +1 -1
- package/dist/cache/cloudflare-kv.mjs +1 -1
- package/dist/cache/memory.d.mts +1 -1
- package/dist/cache/memory.mjs +1 -1
- package/dist/cache.d.mts +1 -1
- package/dist/cache.mjs +1 -1
- package/dist/{chain-DVuRxjPO.mjs → chain-DG_4uSjk.mjs} +2 -2
- package/dist/{chain-DVuRxjPO.mjs.map → chain-DG_4uSjk.mjs.map} +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/{client-l7dSOul5.mjs → client-BJuTpcYj.mjs} +20 -20
- package/dist/client-BJuTpcYj.mjs.map +1 -0
- package/dist/client-BpQs13Fn.mjs +2 -0
- package/dist/client-BpQs13Fn.mjs.map +1 -0
- package/dist/{client-7ApJka0M.d.mts → client-CrBKhXo-.d.mts} +2 -2
- package/dist/client.d.mts +1 -1
- package/dist/client.mjs +1 -1
- package/dist/config.d.mts +1 -1
- package/dist/config.mjs +1 -1
- package/dist/d1.d.mts +1 -1
- package/dist/d1.mjs +1 -1
- package/dist/{datetime-physical-codec-DTdvABny.mjs → datetime-physical-codec-Cdgq6sGs.mjs} +2 -2
- package/dist/{datetime-physical-codec-DTdvABny.mjs.map → datetime-physical-codec-Cdgq6sGs.mjs.map} +1 -1
- package/dist/{driver-DaBNytbz.mjs → driver-DX8GWgGf.mjs} +2 -2
- package/dist/{driver-DaBNytbz.mjs.map → driver-DX8GWgGf.mjs.map} +1 -1
- package/dist/{driver-CK_IKqDa.mjs → driver-XlmOJFRH.mjs} +2 -2
- package/dist/{driver-CK_IKqDa.mjs.map → driver-XlmOJFRH.mjs.map} +1 -1
- package/dist/driver.d.mts +1 -1
- package/dist/driver.mjs +1 -1
- package/dist/every-CyllpuCG.mjs +2 -0
- package/dist/{every-6VrIclsx.mjs.map → every-CyllpuCG.mjs.map} +1 -1
- package/dist/{geo-area-codec-DvHcWF3g.mjs → geo-area-codec-B3QtKij8.mjs} +2 -2
- package/dist/{geo-area-codec-DvHcWF3g.mjs.map → geo-area-codec-B3QtKij8.mjs.map} +1 -1
- package/dist/{geo-point-codec-CIZxuIvE.mjs → geo-point-codec-Ggv29hSH.mjs} +2 -2
- package/dist/{geo-point-codec-CIZxuIvE.mjs.map → geo-point-codec-Ggv29hSH.mjs.map} +1 -1
- package/dist/{hydration-BUBkHlCK.mjs → hydration-Dd2H4EyY.mjs} +2 -2
- package/dist/{hydration-BUBkHlCK.mjs.map → hydration-Dd2H4EyY.mjs.map} +1 -1
- package/dist/{identifier-conversion-BXrBYgAq.mjs → identifier-conversion-BVE8cfFA.mjs} +2 -2
- package/dist/{identifier-conversion-BXrBYgAq.mjs.map → identifier-conversion-BVE8cfFA.mjs.map} +1 -1
- package/dist/{index-CsO6vG2h.d.mts → index-BlBkgxtx.d.mts} +82 -8
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +1 -1
- package/dist/instrumentation.d.mts +1 -1
- package/dist/instrumentation.mjs +1 -1
- package/dist/{key-Cz83fdLO.mjs → key-B4B1etH3.mjs} +2 -2
- package/dist/{key-Cz83fdLO.mjs.map → key-B4B1etH3.mjs.map} +1 -1
- package/dist/{keys-EP1Eq2eD.mjs → keys-CyfjT6uC.mjs} +2 -2
- package/dist/{keys-EP1Eq2eD.mjs.map → keys-CyfjT6uC.mjs.map} +1 -1
- package/dist/{libsql-ClGi2zY2.mjs → libsql-CcKrXiun.mjs} +2 -2
- package/dist/{libsql-ClGi2zY2.mjs.map → libsql-CcKrXiun.mjs.map} +1 -1
- package/dist/libsql.d.mts +1 -1
- package/dist/libsql.mjs +1 -1
- package/dist/{memory-B1GnzgZr.mjs → memory-B0HOEpPu.mjs} +2 -2
- package/dist/{memory-B1GnzgZr.mjs.map → memory-B0HOEpPu.mjs.map} +1 -1
- package/dist/migrations/mysql.d.mts +4 -4
- package/dist/migrations/mysql.mjs +1 -1
- package/dist/migrations/postgres.d.mts +4 -4
- package/dist/migrations/postgres.mjs +1 -1
- package/dist/migrations/sqlite.d.mts +4 -4
- package/dist/migrations/sqlite.mjs +1 -1
- package/dist/migrations/tenant.d.mts +2 -2
- package/dist/migrations/tenant.mjs +1 -1
- package/dist/migrations.d.mts +4 -4
- package/dist/migrations.mjs +1 -1
- package/dist/{model-DsXZ_pHE.mjs → model-u8Ug971J.mjs} +2 -2
- package/dist/{model-DsXZ_pHE.mjs.map → model-u8Ug971J.mjs.map} +1 -1
- package/dist/{mysql-adapter-D-Dq2FN9.mjs → mysql-adapter-CWisQgdc.mjs} +2 -2
- package/dist/{mysql-adapter-D-Dq2FN9.mjs.map → mysql-adapter-CWisQgdc.mjs.map} +1 -1
- package/dist/{mysql-hoo290Dd.mjs → mysql-sGTzkV2q.mjs} +2 -2
- package/dist/{mysql-hoo290Dd.mjs.map → mysql-sGTzkV2q.mjs.map} +1 -1
- package/dist/mysql2.d.mts +1 -1
- package/dist/mysql2.mjs +1 -1
- package/dist/neon-http.d.mts +1 -1
- package/dist/neon-http.mjs +1 -1
- package/dist/{normalized-result-23DWxZVY.mjs → normalized-result-ByvlIQqa.mjs} +2 -2
- package/dist/{normalized-result-23DWxZVY.mjs.map → normalized-result-ByvlIQqa.mjs.map} +1 -1
- package/dist/{object-store-9VfS-3sY.d.mts → object-store-C-VOh0LP.d.mts} +3 -3
- package/dist/on.d.mts +1 -1
- package/dist/ordering.d.mts +55 -19
- package/dist/ordering.mjs +8 -8
- package/dist/ordering.mjs.map +1 -1
- package/dist/permissions.d.mts +22 -3
- package/dist/permissions.mjs +1 -1
- package/dist/permissions.mjs.map +1 -1
- package/dist/pg.d.mts +1 -1
- package/dist/pg.mjs +1 -1
- package/dist/pglite.d.mts +1 -1
- package/dist/pglite.mjs +1 -1
- package/dist/{physical-t_gDjUCD.mjs → physical-CjG29tya.mjs} +2 -2
- package/dist/{physical-t_gDjUCD.mjs.map → physical-CjG29tya.mjs.map} +1 -1
- package/dist/planetscale.d.mts +1 -1
- package/dist/planetscale.mjs +1 -1
- package/dist/{planner-Cc3ABIUU.d.mts → planner-syQCWHHr.d.mts} +1 -1
- package/dist/{postgres-CqcP_qv-.mjs → postgres-C2uUUh0t.mjs} +2 -2
- package/dist/{postgres-CqcP_qv-.mjs.map → postgres-C2uUUh0t.mjs.map} +1 -1
- package/dist/{postgres-adapter-CYZAL2uo.mjs → postgres-adapter-CdUHI_lw.mjs} +2 -2
- package/dist/{postgres-adapter-CYZAL2uo.mjs.map → postgres-adapter-CdUHI_lw.mjs.map} +1 -1
- package/dist/{postgres-adapter-_o6EWuxW.mjs → postgres-adapter-D4v50VQk.mjs} +2 -2
- package/dist/{postgres-adapter-_o6EWuxW.mjs.map → postgres-adapter-D4v50VQk.mjs.map} +1 -1
- package/dist/{postgres-result-D94PyZ78.mjs → postgres-result-ehQiy2H-.mjs} +2 -2
- package/dist/{postgres-result-D94PyZ78.mjs.map → postgres-result-ehQiy2H-.mjs.map} +1 -1
- package/dist/postgres.d.mts +1 -1
- package/dist/postgres.mjs +1 -1
- package/dist/{provider-limits-kO9B3KCF.mjs → provider-limits-DolYOv3_.mjs} +2 -2
- package/dist/{provider-limits-kO9B3KCF.mjs.map → provider-limits-DolYOv3_.mjs.map} +1 -1
- package/dist/{result-shape-uaCsF_SZ.mjs → result-shape-dG_6HE7s.mjs} +2 -2
- package/dist/{result-shape-uaCsF_SZ.mjs.map → result-shape-dG_6HE7s.mjs.map} +1 -1
- package/dist/{rows-AtX0guAb.mjs → rows-CEYfrodD.mjs} +2 -2
- package/dist/rows-CEYfrodD.mjs.map +1 -0
- package/dist/rows-of-Djavcb19.mjs +2 -0
- package/dist/rows-of-Djavcb19.mjs.map +1 -0
- package/dist/{scalar-CZ_q89Hc.mjs → scalar-DNshDNz3.mjs} +2 -2
- package/dist/{scalar-CZ_q89Hc.mjs.map → scalar-DNshDNz3.mjs.map} +1 -1
- package/dist/schema/json.d.mts +1 -1
- package/dist/schema/json.mjs +1 -1
- package/dist/schema-DYPfTOQl.mjs +2 -0
- package/dist/{schema-CZTCxG2p.mjs.map → schema-DYPfTOQl.mjs.map} +1 -1
- package/dist/{schema-introspection-DoZHc1o7.mjs → schema-introspection-Bu2N__75.mjs} +2 -2
- package/dist/{schema-introspection-DoZHc1o7.mjs.map → schema-introspection-Bu2N__75.mjs.map} +1 -1
- package/dist/schema.d.mts +1 -1
- package/dist/schema.mjs +1 -1
- package/dist/{select-assembly-BtNtBsUh.mjs → select-assembly-Dcaqm09G.mjs} +2 -2
- package/dist/{select-assembly-BtNtBsUh.mjs.map → select-assembly-Dcaqm09G.mjs.map} +1 -1
- package/dist/soft-delete.d.mts +116 -14
- package/dist/soft-delete.mjs +1 -1
- package/dist/soft-delete.mjs.map +1 -1
- package/dist/sql-BsBoKwaf.mjs +2 -0
- package/dist/sql-BsBoKwaf.mjs.map +1 -0
- package/dist/{sql-BnXk8adi.d.mts → sql-D7JnXgUh.d.mts} +5 -0
- package/dist/sql.d.mts +1 -1
- package/dist/sql.mjs +1 -1
- package/dist/{sqlite-adapter-CnAwmszh.mjs → sqlite-adapter-BHx--tnz.mjs} +2 -2
- package/dist/{sqlite-adapter-CnAwmszh.mjs.map → sqlite-adapter-BHx--tnz.mjs.map} +1 -1
- package/dist/sqlite3.d.mts +1 -1
- package/dist/sqlite3.mjs +1 -1
- package/dist/{standard-sql-Ci8ROrql.mjs → standard-sql-BtzSzrof.mjs} +2 -2
- package/dist/standard-sql-BtzSzrof.mjs.map +1 -0
- package/dist/{to-many-BtLpp5cW.mjs → to-many-5gt2AWLE.mjs} +2 -2
- package/dist/{to-many-BtLpp5cW.mjs.map → to-many-5gt2AWLE.mjs.map} +1 -1
- package/dist/{utils-CAACs9Jw.mjs → utils-CmNRGkRq.mjs} +2 -2
- package/dist/{utils-CAACs9Jw.mjs.map → utils-CmNRGkRq.mjs.map} +1 -1
- package/dist/{v-Pb_jJOjC.mjs → v-CWY9ntMb.mjs} +2 -2
- package/dist/{v-Pb_jJOjC.mjs.map → v-CWY9ntMb.mjs.map} +1 -1
- package/dist/{validation-BSpO4DjI.mjs → validation-CMvAxrIo.mjs} +2 -2
- package/dist/{validation-BSpO4DjI.mjs.map → validation-CMvAxrIo.mjs.map} +1 -1
- package/dist/validation.d.mts +1 -1
- package/dist/validation.mjs +1 -1
- package/dist/{validator-Dthaj1Hz.mjs → validator-CYKdGTvX.mjs} +2 -2
- package/dist/{validator-Dthaj1Hz.mjs.map → validator-CYKdGTvX.mjs.map} +1 -1
- package/dist/version-B7NRPl4T.mjs +2 -0
- package/dist/{version-DvynkoaW.mjs.map → version-B7NRPl4T.mjs.map} +1 -1
- package/package.json +23 -23
- package/dist/client-Yqn0LqmI.mjs +0 -2
- package/dist/client-Yqn0LqmI.mjs.map +0 -1
- package/dist/client-l7dSOul5.mjs.map +0 -1
- package/dist/every-6VrIclsx.mjs +0 -2
- package/dist/insert-value-Cbp_bNxj.mjs +0 -2
- package/dist/insert-value-Cbp_bNxj.mjs.map +0 -1
- package/dist/rows-AtX0guAb.mjs.map +0 -1
- package/dist/schema-CZTCxG2p.mjs +0 -2
- package/dist/sql-DGtEeP8z.mjs +0 -2
- package/dist/sql-DGtEeP8z.mjs.map +0 -1
- package/dist/standard-sql-Ci8ROrql.mjs.map +0 -1
- package/dist/version-DvynkoaW.mjs +0 -2
package/dist/pg.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as Schema,
|
|
1
|
+
import { A as Schema, F as LinkedClientConfig, Ft as NoExtraDriverConfigKeys, It as VibORMClient, Nn as DriverTransactionOptions, Pn as TransactionOptionSupport, Rn as QueryExecutionContext, d as MigrationSessionAttestation, jt as DriverConfig, m as PinnedSessionReservation, s as DatabaseAdapter, u as Driver, zn as QueryResult } from "./index-BlBkgxtx.mjs";
|
|
2
2
|
import { Pool, PoolClient, PoolConfig, PoolConfig as PgOptions } from "pg";
|
|
3
3
|
|
|
4
4
|
//#region src/drivers/pg/index.d.ts
|
package/dist/pg.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{n as e}from"./chunk-BuuaeEvq.mjs";import{l as t}from"./execution-context-_oajgBi4.mjs";import{m as n,n as r,r as i,u as a}from"./error-mapping-D--MVRCY.mjs";import{t as o}from"./query-CTna5P9o.mjs";import{n as s}from"./transaction-D5LHYn-r.mjs";import{n as c}from"./suppressed-failure-DO0ej03b.mjs";import{n as l}from"./client-
|
|
1
|
+
import{n as e}from"./chunk-BuuaeEvq.mjs";import{l as t}from"./execution-context-_oajgBi4.mjs";import{m as n,n as r,r as i,u as a}from"./error-mapping-D--MVRCY.mjs";import{t as o}from"./query-CTna5P9o.mjs";import{n as s}from"./transaction-D5LHYn-r.mjs";import{n as c}from"./suppressed-failure-DO0ej03b.mjs";import{n as l}from"./client-BpQs13Fn.mjs";import{c as u,d,f,i as p,o as m,s as h,t as g,u as _}from"./driver-XlmOJFRH.mjs";import{t as v}from"./postgres-result-ehQiy2H-.mjs";import{t as y}from"./postgres-adapter-CdUHI_lw.mjs";import{n as b,t as x}from"./relation-bound-5hindjxU.mjs";import{Client as S,Pool as C,types as w}from"pg";const identityParser=e=>e,T={getTypeParser:(e,t)=>[1082,1114,1184,1115,1182,1185].includes(e)&&t!==`binary`?identityParser:w.getTypeParser(e,t)};function createOwnedPoolErrorState(){let e=0,t={retain(n){e+=1,t.backgroundFailure={error:n,generation:e,isAvailable:!0}}};return t}function holdClientErrors(e){let t,retain=e=>{t??=e};return e.on(`error`,retain),{failure:()=>t,stop:()=>{e.off(`error`,retain)}}}const E=new Set([`user`,`password`,`host`,`port`]),D=[`sslmode`,`sslcert`,`sslkey`,`sslrootcert`];function connectionRecord(e,t){let n=e.connectionString??t;if(!n)return e;if(typeof e.password==`function`)throw new o('Driver "pg" cannot keep a password callback beside a connection URL: node-postgres reads the password from the URL. Pass `host`, `user` and `database` in `options` instead.',{meta:{driver:`pg`,operation:`configuration`}});let r=f(n),i;try{i=new URL(r)}catch{i=void 0}let a=Object.entries(e).filter(([e,t])=>t!==void 0&&(E.has(e)||e===`database`||e===`ssl`||e!==`connectionString`&&i?.searchParams.has(e)));if(a.length===0)return{...e,connectionString:r};if(i===void 0)throw new o(`Driver "pg" could not read its connection URL to apply the connection options beside it.`,{meta:{driver:`pg`,operation:`configuration`}});for(let[e,t]of a)if(i.searchParams.delete(e),e===`ssl`)for(let e of D)i.searchParams.delete(e);else e===`database`?i.pathname=`/${String(t)}`:E.has(e)&&(typeof t==`string`||typeof t==`number`)&&i.searchParams.set(e,String(t));return{...e,connectionString:i.href}}const O={pool:!0,options:!0,pgvector:!0,postgis:!0,databaseUrl:!0,namespace:!0,sharedRelationBodies:!0,relationsPerStatement:!0,migrationSessionAttestation:!0};var PgDriver=class extends g{maxBindParametersPerStatement=65535;suppliedPool;connectionOptions;ownedPoolErrors=new WeakMap;serverVersion;readsServer;constructor(e={}){super(`postgresql`,`pg`);let t=d(e);this.suppliedPool=e.pool;let n={...e.options};h(`pg`,e,!!(this.suppliedPool||n.host||n.connectionString)),this.connectionOptions=connectionRecord(n,e.databaseUrl),this.suppliedPool&&(this.client=this.suppliedPool),y(this,t,e),this.readsServer=this.suppliedPool===void 0&&n.Client===void 0&&x(this.adapter,()=>this.serverVersion),m(this,`migrationSessionAttestation`,_(e))}migrationSessionEndpoints(){let e=this.suppliedPool?Reflect.get(this.suppliedPool,`options`):void 0,t=typeof e==`object`&&e?e:{};return[this.connectionOptions.host,this.connectionOptions.connectionString,Reflect.get(t,`host`),Reflect.get(t,`connectionString`)]}initClient(){if(this.suppliedPool!==void 0)return Promise.resolve(this.suppliedPool);let e=new C({types:T,...this.connectionOptions,...this.readsServer?{Client:this.readingClient()}:{}}),t=createOwnedPoolErrorState();return this.ownedPoolErrors.set(e,t),e.on(`error`,t.retain),Promise.resolve(e)}readingClient(){let read=e=>{this.serverVersion=e};return class extends S{constructor(e){super(e),this.connection.on(`parameterStatus`,e=>{e.parameterName===`server_version`&&read(e.parameterValue)})}}}readBackgroundPoolFailure(e){return this.ownedPoolErrors.get(e)?.backgroundFailure}clearBackgroundPoolFailure(e,t){if(t===void 0||!t.isAvailable)return!1;t.isAvailable=!1;let n=this.ownedPoolErrors.get(e);return n?.backgroundFailure?.generation===t.generation&&(n.backgroundFailure=void 0),!0}consumeBackgroundPoolFailure(e,t){if(this.clearBackgroundPoolFailure(e,t))return t?.error}throwPoolQueryFailure(e,t,n,r,a,o){let s=this.consumeBackgroundPoolFailure(e,t);throw s===void 0?n:c(i(n,{driverName:this.driverName,dialect:this.dialect,model:o?.model,operation:o?.operation,correlationId:o?.correlationId,query:r,params:this.getDiagnosticParameters(a??[],o),diagnostics:this.getErrorDisclosure(o),forceContext:!0}),s)}async acquirePooledClient(e,t={},n){let i=this.readBackgroundPoolFailure(e),a=!1;try{return await p(async()=>{try{let t=await e.connect();return this.clearBackgroundPoolFailure(e,i),t}finally{a=!0}},e=>e.release(),n,{driverName:this.driverName,form:`callback`})}catch(n){if(!a)throw n;let o=this.consumeBackgroundPoolFailure(e,i);throw o===void 0?n:c(r(n,{driverName:this.driverName,model:t.model,operation:t.operation,correlationId:t.correlationId,diagnostics:this.getErrorDisclosure(t)},`Database connection failed after the pool reported a background failure`),o)}}async closeClient(e){if(e===this.suppliedPool)return;let t=this.ownedPoolErrors.get(e);try{await e.end()}catch(n){let i=this.consumeBackgroundPoolFailure(e,t?.backgroundFailure);throw i===void 0?n:c(r(n,{driverName:this.driverName},`Database disconnection failed`),i)}t!==void 0&&(e.off(`error`,t.retain),t.backgroundFailure=void 0,this.ownedPoolErrors.delete(e))}async execute(e,t,n,r){return this.executeQuery(e,t,n,r,`execute`)}async executeRaw(e,t,n,r){return this.executeQuery(e,t,n,r,`executeRaw`)}async executeQuery(e,t,n,r,i){let a=r?.operation??i,o=this.readBackgroundPoolFailure(e),s=await e.query({text:t,values:n,types:T}).catch(i=>(b(this.adapter,i),this.throwPoolQueryFailure(e,o,i,t,n,r)));return this.clearBackgroundPoolFailure(e,o),{rows:s.rows,rowCount:v(s.rowCount,s.command,s.rows,{provider:`pg`,operation:a})}}transactionOptionSupport(){return{isolationLevel:`post-begin`,timeout:!0,maxWait:`acquisition`}}async transaction(e,r,i,o){if(`release`in e)throw a(this.driverName);let l=await this.acquirePooledClient(e,i,o?.maxWaitMs),u=holdClientErrors(l),withClientFailure=e=>{let t=u.failure();return t===void 0||t===e?e:c(e,t)},d,queryOrDiscard=async e=>{try{await l.query(e)}catch(e){throw d??=e instanceof Error?e:!0,withClientFailure(e)}};return n({begin:()=>queryOrDiscard(`BEGIN`),callback:async()=>{try{return await r(l)}catch(e){throw withClientFailure(e)}},commit:()=>{let e=u.failure();if(e!==void 0)throw e;return queryOrDiscard(`COMMIT`)},rollback:()=>u.failure()===void 0?queryOrDiscard(`ROLLBACK`):void 0,phases:t(i),close:()=>{try{let e=d??u.failure();if(e){l.release(e);return}l.release()}catch(e){throw super.transactionCleanupFailed(new s(`Driver "pg" could not release an unsafe transaction connection.`,{meta:{driver:`pg`,method:`$transaction`}})),e}finally{u.stop()}}})}transactionCleanupFailed(e){}async pinnedSession(){let e=await this.getClient({operation:`pinnedSession`});if(`release`in e)throw a(this.driverName);let t=await this.acquirePooledClient(e,{operation:`pinnedSession`}),n=holdClientErrors(t);return{session:t,lost:n.failure,release:e=>{try{t.release(n.failure()??(e?!0:void 0))}finally{n.stop()}return Promise.resolve()}}}};function createClient(e){u(e,`pg`,O);let{pool:t,options:n={},pgvector:r,postgis:i,databaseUrl:a}=e;return l(e,new PgDriver({namespace:d(e),migrationSessionAttestation:_(e),pool:t||void 0,options:n,...Object.hasOwn(e,`databaseUrl`)?{databaseUrl:a}:{},pgvector:r,postgis:i,sharedRelationBodies:e.sharedRelationBodies,relationsPerStatement:e.relationsPerStatement}))}export{PgDriver,createClient};
|
|
2
2
|
//# sourceMappingURL=pg.mjs.map
|
package/dist/pglite.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as Schema,
|
|
1
|
+
import { A as Schema, F as LinkedClientConfig, Ft as NoExtraDriverConfigKeys, It as VibORMClient, Pn as TransactionOptionSupport, Rn as QueryExecutionContext, jt as DriverConfig, m as PinnedSessionReservation, s as DatabaseAdapter, u as Driver, zn as QueryResult } from "./index-BlBkgxtx.mjs";
|
|
2
2
|
import { PGlite, PGliteOptions, PGliteOptions as PGliteOptions$1, Transaction } from "@electric-sql/pglite";
|
|
3
3
|
|
|
4
4
|
//#region src/drivers/pglite/index.d.ts
|
package/dist/pglite.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{n as e}from"./chunk-BuuaeEvq.mjs";import{o as t}from"./normalized-result-
|
|
1
|
+
import{n as e}from"./chunk-BuuaeEvq.mjs";import{o as t}from"./normalized-result-ByvlIQqa.mjs";import{l as n}from"./execution-context-_oajgBi4.mjs";import{f as r,u as i}from"./error-mapping-D--MVRCY.mjs";import{n as a}from"./client-BpQs13Fn.mjs";import{a as o,n as s}from"./pinned-session-De2rDjdO.mjs";import{c,d as l,r as u,t as d}from"./driver-XlmOJFRH.mjs";import{t as f}from"./postgres-adapter-CdUHI_lw.mjs";import{PGlite as p}from"@electric-sql/pglite";const m=Object.fromEntries([1082,1114,1184,1115,1182,1185].map(e=>[e,e=>e])),h={client:!0,dataDir:!0,options:!0,pgvector:!0,postgis:!0,sharedRelationBodies:!0,relationsPerStatement:!0,namespace:!0};function isPGliteDatabase(e){return`transaction`in e}var PGliteDriver=class extends d{maxBindParametersPerStatement=32767;serializeTransactions=!0;driverOptions;suppliedClient;constructor(e={}){super(`postgresql`,`pglite`);let t=l(e);this.driverOptions=e,this.suppliedClient=e.client,this.suppliedClient&&(this.client=this.suppliedClient,Object.defineProperty(this,`connectionQueue`,{value:u(this.suppliedClient)})),f(this,t,e)}async initClient(){if(this.suppliedClient!==void 0)return this.suppliedClient;let e=this.driverOptions.dataDir,t=this.driverOptions.options??{},n={...t,parsers:{1114:e=>e,...t.parsers}};return e?await p.create(e,n):await p.create(n)}async closeClient(e){e!==this.suppliedClient&&await e.close()}async execute(e,t,n,r){return this.executeQuery(e,t,n,r,`execute`)}async executeRaw(e,t,n,r){return this.executeQuery(e,t,n,r,`executeRaw`)}async executeQuery(e,n,r,i,a){let o=i?.operation??a,s=await e.query(n,r,{parsers:m}),c=t(s.affectedRows,{provider:`pglite`,operation:o});return{rows:s.rows,rowCount:s.rows.length>0?s.rows.length:c}}transactionOptionSupport(){return{isolationLevel:`post-begin`,timeout:!0,maxWait:`queue`}}transaction(e,t,a){if(!isPGliteDatabase(e))throw i(this.driverName);return r({run:t=>e.transaction(t),callback:t,phases:n(a),close:async()=>void 0})}async physicalPinnedSession(){return await this.getClient({operation:`pinnedSession`})}async pinnedSession(){let e=await this.getClient({operation:`pinnedSession`});if(!isPGliteDatabase(e))throw i(this.driverName);return{session:e,release:async t=>{if(t)try{await e.query(`SELECT pg_advisory_unlock_all()`)}catch(t){throw s(e),o(this.driverName,`No driver will pin a further migration session on that client. The client itself was NOT closed: it is the caller's database, not a pooled connection VibORM may discard.`,t)}}}}};function createClient(e){c(e,`pglite`,h);let{client:t,dataDir:n,options:r,pgvector:i,postgis:o}=e,s=l(e);return a(e,new PGliteDriver({client:t,dataDir:n,options:r,pgvector:i,postgis:o,sharedRelationBodies:e.sharedRelationBodies,relationsPerStatement:e.relationsPerStatement,namespace:s}))}export{PGliteDriver,createClient};
|
|
2
2
|
//# sourceMappingURL=pglite.mjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{n as e}from"./chunk-BuuaeEvq.mjs";import{at as t,rt as n}from"./geo-point-codec-
|
|
2
|
-
//# sourceMappingURL=physical-
|
|
1
|
+
import{n as e}from"./chunk-BuuaeEvq.mjs";import{at as t,rt as n}from"./geo-point-codec-Ggv29hSH.mjs";import{i as r,o as i,r as a,t as o}from"./native-types-CQH05hcr.mjs";const s=new WeakMap;function idDomainOfState(e){return e?.array===!0?void 0:idMemberDomainOfState(e)}function idMemberDomainOfState(e){if(e===void 0||e.type!==`string`)return;let n=s.get(e);if(n)return n;let r=e.autoGenerate;if(r===void 0||!t(r.kind)||r.implicit===!0)return;let i={format:r.kind,prefix:r.prefix,length:r.length};return s.set(e,i),i}const c=/^(?:text|citext|varchar\(\d+\))$/,l=/^(?:TINYTEXT|TEXT|MEDIUMTEXT|LONGTEXT|VARCHAR\(\d+\)|CHAR\(\d+\))$/,u=/^TEXT$/,d=/^(?:BINARY|VARBINARY)\((\d+)\)$/;function defaultIdStorage(e,t){let i=n(e);if(i===void 0)switch(t){case`pg`:return{representation:`text`,columnType:a.STRING.TEXT.type};case`mysql`:return{representation:`text`,columnType:`TEXT`};default:return{representation:`text`,columnType:r.STRING.TEXT.type}}switch(t){case`pg`:return e===`uuid`||e===`uuidv7`?{representation:`uuid`,columnType:a.STRING.UUID.type}:{representation:`bytes`,columnType:a.BLOB.BYTEA.type};case`mysql`:return{representation:`bytes`,columnType:o.BLOB.BINARY(i).type};default:return{representation:`bytes`,columnType:r.BLOB.BLOB.type}}}function isTextColumnType(e,t){switch(t){case`pg`:return c.test(e);case`mysql`:return l.test(e);default:return u.test(e)}}function binaryRepresentation(e,t,i){let s=n(t);if(s===void 0)return;if(i===`pg`)return e===a.BLOB.BYTEA.type?`bytes`:e===a.STRING.UUID.type&&(t===`uuid`||t===`uuidv7`)?`uuid`:void 0;if(i===`sqlite`)return e===r.BLOB.BLOB.type?`bytes`:void 0;if(e===o.BLOB.BLOB.type)return`bytes`;let c=d.exec(e);return c&&Number(c[1])===s?`bytes`:void 0}function idStorageOf(e,t,n){let r=i(t,n);if(r===void 0)return defaultIdStorage(e.format,n);let a=r.type;if(isTextColumnType(a,n))return{representation:`text`,columnType:a};let o=binaryRepresentation(a,e.format,n);return o===void 0?void 0:{representation:o,columnType:a}}function describeIdNativeTypes(e,t){let r=n(e),i=t===`pg`?`text, citext, varchar(n)`:t===`mysql`?`TEXT, TINYTEXT, MEDIUMTEXT, LONGTEXT, VARCHAR(n), CHAR(n)`:`TEXT`;return r===void 0?i:`${t===`pg`?e===`uuid`||e===`uuidv7`?`uuid, bytea`:`bytea`:t===`mysql`?`BINARY(${r}), VARBINARY(${r}), BLOB`:`BLOB`}, ${i}`}function sqliteDateTimePhysicalForm(e){let t=i(e,`sqlite`);return t===void 0?`text`:t.type===`INTEGER`?`epochMillis`:t.type===`REAL`?`julianDay`:`text`}export{idStorageOf as a,idMemberDomainOfState as i,describeIdNativeTypes as n,idDomainOfState as r,sqliteDateTimePhysicalForm as t};
|
|
2
|
+
//# sourceMappingURL=physical-CjG29tya.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"physical-t_gDjUCD.mjs","names":[],"sources":["../src/schema/scalars/string/id-domain.ts","../src/schema/scalars/datetime/physical.ts"],"sourcesContent":["/**\n * Where a DECLARED identifier domain is read from, and how it becomes a column.\n *\n * There is no second declaration: `ScalarState.autoGenerate` — the same record\n * `.uuid()`, `.ulid()`, `.ksuid()`, `.nanoid()` and `.cuid()` already write —\n * IS the domain. This module only projects it into the shape the codec takes,\n * and answers the one storage question the projection cannot: which physical\n * representation and which column spelling this domain has on a given dialect,\n * with a native type override taken into account.\n *\n * Storage lives HERE rather than in the codec because it is the only part of\n * the identifier language that speaks a dialect's vocabulary. The codec below\n * it stays pure — it takes a representation, never a provider — so the\n * validation schemas, which run long before any adapter exists, can use it.\n */\n\nimport {\n type IdDomain,\n type IdFormat,\n type IdRepresentation,\n idByteLength,\n isIdFormat,\n} from \"@validation/primitives/id-codec\";\nimport type { AutoGenerate, ScalarState } from \"../common\";\nimport {\n MYSQL,\n type NativeDialect,\n type NativeTypeDeclaration,\n nativeTypeFor,\n PG,\n SQLITE,\n} from \"../native-types\";\n\n// =============================================================================\n// THE DECLARED DOMAIN\n// =============================================================================\n\nconst DOMAINS = new WeakMap<ScalarState, IdDomain>();\n\n/**\n * The identifier domain a scalar state declares, or `undefined`.\n *\n * Only a NAMED format declares one. `.id()` installs a ULID generator without\n * naming a format (see {@link AutoGenerate.implicit}), so a `.id()` key has no\n * domain: nothing admits its values and nothing narrows its storage.\n *\n * A LIST answers `undefined` deliberately, exactly as the decimal descriptor\n * lookup does: physical parameter encoding, projection, decode and DDL must\n * not bind a whole container as one compact identifier. List admission reads\n * the same declaration through idMemberDomainOfState instead.\n *\n * The projection is memoized per state so the hot write path compares and\n * encodes against one object instead of allocating a domain per value.\n */\nexport function idDomainOfState(\n state: ScalarState | undefined\n): IdDomain | undefined {\n return state?.array === true ? undefined : idMemberDomainOfState(state);\n}\n\n/** The named member domain, also used by lists with plain string storage. */\nexport function idMemberDomainOfState(\n state: ScalarState | undefined\n): IdDomain | undefined {\n if (state === undefined || state.type !== \"string\") return undefined;\n const existing = DOMAINS.get(state);\n if (existing) return existing;\n const generate = state.autoGenerate;\n if (generate === undefined || !isIdFormat(generate.kind)) return undefined;\n // A format the caller did not NAME is not a domain the caller asserted:\n // `.id()` declares a key and carries a generator for convenience, and its\n // values stay whatever a string column holds. `.ulid().id()` names the\n // format and gets the domain, the admission and the compact column.\n if (generate.implicit === true) return undefined;\n const domain: IdDomain = {\n format: generate.kind,\n prefix: generate.prefix,\n length: generate.length,\n };\n DOMAINS.set(state, domain);\n return domain;\n}\n\n// =============================================================================\n// PHYSICAL STORAGE\n// =============================================================================\n\n/** The three dialects a column spelling is asked for. */\nexport type IdDialect = NativeDialect;\n\n/** What one domain is physically, on one dialect. */\nexport interface IdStorage {\n readonly representation: IdRepresentation;\n /** The column type this dialect spells it with. */\n readonly columnType: string;\n}\n\n// `char(n)` is absent deliberately. PostgreSQL BLANK-PADS `character(n)` to its\n// full width, so a 36-character uuid in a `char(40)` column reads back with four\n// trailing spaces and no value of the domain is ever returned — the column is\n// unusable from the moment it is created, for every n wider than the format's\n// own public spelling. MySQL's `CHAR(n)` pads on the way in and STRIPS on the\n// way out, so it keeps its place in that dialect's list.\nconst PG_TEXT_FAMILY = /^(?:text|citext|varchar\\(\\d+\\))$/;\nconst MYSQL_TEXT_FAMILY =\n /^(?:TINYTEXT|TEXT|MEDIUMTEXT|LONGTEXT|VARCHAR\\(\\d+\\)|CHAR\\(\\d+\\))$/;\nconst SQLITE_TEXT_FAMILY = /^TEXT$/;\nconst MYSQL_SIZED_BINARY = /^(?:BINARY|VARBINARY)\\((\\d+)\\)$/;\n\n/** The default column spelling and representation, before any override. */\nfunction defaultIdStorage(format: IdFormat, dialect: IdDialect): IdStorage {\n const width = idByteLength(format);\n if (width === undefined) {\n // `nanoid` and `cuid` keep the text column the dialect already gave them.\n switch (dialect) {\n case \"pg\":\n return { representation: \"text\", columnType: PG.STRING.TEXT.type };\n case \"mysql\":\n return { representation: \"text\", columnType: \"TEXT\" };\n default:\n return {\n representation: \"text\",\n columnType: SQLITE.STRING.TEXT.type,\n };\n }\n }\n switch (dialect) {\n case \"pg\":\n // A UUID gets PostgreSQL's own 16-byte type, which the wire spells as\n // canonical text. A ULID is never spelled `uuid`: its bytes are not a\n // UUID's and a database that formatted them as one would publish a\n // version nibble the value does not have.\n return format === \"uuid\" || format === \"uuidv7\"\n ? { representation: \"uuid\", columnType: PG.STRING.UUID.type }\n : { representation: \"bytes\", columnType: PG.BLOB.BYTEA.type };\n case \"mysql\":\n return {\n representation: \"bytes\",\n columnType: MYSQL.BLOB.BINARY(width).type,\n };\n default:\n return { representation: \"bytes\", columnType: SQLITE.BLOB.BLOB.type };\n }\n}\n\n/** Whether this dialect spells `type` as one of its text column types. */\nfunction isTextColumnType(type: string, dialect: IdDialect): boolean {\n switch (dialect) {\n case \"pg\":\n return PG_TEXT_FAMILY.test(type);\n case \"mysql\":\n return MYSQL_TEXT_FAMILY.test(type);\n default:\n return SQLITE_TEXT_FAMILY.test(type);\n }\n}\n\n/**\n * The representation a BINARY-family override names for this format, or\n * `undefined` when the override is not a binary column this domain fits.\n *\n * A sized MySQL column must be the format's exact width: `BINARY(16)` holds a\n * KSUID's first sixteen bytes and pads a ULID that was never short, and both\n * are silent corruptions rather than storage choices. `bytea` and `BLOB` carry\n * no declared width, so the codec's exact-width encoding is the only promise\n * they need.\n */\nfunction binaryRepresentation(\n type: string,\n format: IdFormat,\n dialect: IdDialect\n): IdRepresentation | undefined {\n const width = idByteLength(format);\n if (width === undefined) return undefined;\n if (dialect === \"pg\") {\n if (type === PG.BLOB.BYTEA.type) return \"bytes\";\n return type === PG.STRING.UUID.type &&\n (format === \"uuid\" || format === \"uuidv7\")\n ? \"uuid\"\n : undefined;\n }\n if (dialect === \"sqlite\") {\n return type === SQLITE.BLOB.BLOB.type ? \"bytes\" : undefined;\n }\n if (type === MYSQL.BLOB.BLOB.type) return \"bytes\";\n const sized = MYSQL_SIZED_BINARY.exec(type);\n return sized && Number(sized[1]) === width ? \"bytes\" : undefined;\n}\n\n/**\n * The column spelling and representation of one domain on one dialect.\n *\n * The ONE owner of that decision: the migration type mapping, the parameter\n * encoding, the read projection and the result decode all derive from this, so\n * a column cannot be created as one thing and written as another.\n *\n * The declaration is resolved for THIS dialect (`nativeTypeFor`): a tagged\n * native type for another dialect, or a map without this dialect's entry, is\n * not this dialect's column and is ignored exactly as every other scalar's\n * mapping ignores it. An override that IS this\n * dialect's and that this domain cannot live in returns `undefined` — the\n * schema boundary refuses it by name long before a query is built, and this\n * answering `undefined` rather than guessing is what keeps that refusal the\n * only place the question is decided.\n */\nexport function idStorageOf(\n domain: IdDomain,\n declaration: NativeTypeDeclaration | undefined,\n dialect: IdDialect\n): IdStorage | undefined {\n const nativeType = nativeTypeFor(declaration, dialect);\n if (nativeType === undefined) {\n return defaultIdStorage(domain.format, dialect);\n }\n const type = nativeType.type;\n if (isTextColumnType(type, dialect)) {\n // The opt-out for a column that already holds text: the domain is still\n // admitted and normalized, only its storage stays as it was.\n return { representation: \"text\", columnType: type };\n }\n const representation = binaryRepresentation(type, domain.format, dialect);\n return representation === undefined\n ? undefined\n : { representation, columnType: type };\n}\n\n/** The overrides this domain accepts on this dialect, for a refusal message. */\nexport function describeIdNativeTypes(\n format: IdFormat,\n dialect: IdDialect\n): string {\n const width = idByteLength(format);\n const text =\n dialect === \"pg\"\n ? \"text, citext, varchar(n)\"\n : dialect === \"mysql\"\n ? \"TEXT, TINYTEXT, MEDIUMTEXT, LONGTEXT, VARCHAR(n), CHAR(n)\"\n : \"TEXT\";\n if (width === undefined) return text;\n const binary =\n dialect === \"pg\"\n ? format === \"uuid\" || format === \"uuidv7\"\n ? \"uuid, bytea\"\n : \"bytea\"\n : dialect === \"mysql\"\n ? `BINARY(${width}), VARBINARY(${width}), BLOB`\n : \"BLOB\";\n return `${binary}, ${text}`;\n}\n","import type { DateTimePhysicalForm } from \"@validation/primitives/datetime-physical-codec\";\nimport { type NativeTypeDeclaration, nativeTypeFor } from \"../native-types\";\n\n/**\n * The physical vocabulary SQLite assigns to one DateTime native declaration.\n *\n * A missing declaration, a declaration that selects nothing on SQLite, and\n * explicit TEXT all use SQLite's default timestamp text. INTEGER is epoch milliseconds and\n * REAL is a Julian day. Schema validation, query lowering, result parsing, and\n * migration defaults consume this same interpretation.\n */\nexport function sqliteDateTimePhysicalForm(\n declaration: NativeTypeDeclaration | undefined\n): DateTimePhysicalForm {\n const nativeType = nativeTypeFor(declaration, \"sqlite\");\n if (nativeType === undefined) return \"text\";\n if (nativeType.type === \"INTEGER\") return \"epochMillis\";\n return nativeType.type === \"REAL\" ? \"julianDay\" : \"text\";\n}\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"physical-CjG29tya.mjs","names":[],"sources":["../src/schema/scalars/string/id-domain.ts","../src/schema/scalars/datetime/physical.ts"],"sourcesContent":["/**\n * Where a DECLARED identifier domain is read from, and how it becomes a column.\n *\n * There is no second declaration: `ScalarState.autoGenerate` — the same record\n * `.uuid()`, `.ulid()`, `.ksuid()`, `.nanoid()` and `.cuid()` already write —\n * IS the domain. This module only projects it into the shape the codec takes,\n * and answers the one storage question the projection cannot: which physical\n * representation and which column spelling this domain has on a given dialect,\n * with a native type override taken into account.\n *\n * Storage lives HERE rather than in the codec because it is the only part of\n * the identifier language that speaks a dialect's vocabulary. The codec below\n * it stays pure — it takes a representation, never a provider — so the\n * validation schemas, which run long before any adapter exists, can use it.\n */\n\nimport {\n type IdDomain,\n type IdFormat,\n type IdRepresentation,\n idByteLength,\n isIdFormat,\n} from \"@validation/primitives/id-codec\";\nimport type { AutoGenerate, ScalarState } from \"../common\";\nimport {\n MYSQL,\n type NativeDialect,\n type NativeTypeDeclaration,\n nativeTypeFor,\n PG,\n SQLITE,\n} from \"../native-types\";\n\n// =============================================================================\n// THE DECLARED DOMAIN\n// =============================================================================\n\nconst DOMAINS = new WeakMap<ScalarState, IdDomain>();\n\n/**\n * The identifier domain a scalar state declares, or `undefined`.\n *\n * Only a NAMED format declares one. `.id()` installs a ULID generator without\n * naming a format (see {@link AutoGenerate.implicit}), so a `.id()` key has no\n * domain: nothing admits its values and nothing narrows its storage.\n *\n * A LIST answers `undefined` deliberately, exactly as the decimal descriptor\n * lookup does: physical parameter encoding, projection, decode and DDL must\n * not bind a whole container as one compact identifier. List admission reads\n * the same declaration through idMemberDomainOfState instead.\n *\n * The projection is memoized per state so the hot write path compares and\n * encodes against one object instead of allocating a domain per value.\n */\nexport function idDomainOfState(\n state: ScalarState | undefined\n): IdDomain | undefined {\n return state?.array === true ? undefined : idMemberDomainOfState(state);\n}\n\n/** The named member domain, also used by lists with plain string storage. */\nexport function idMemberDomainOfState(\n state: ScalarState | undefined\n): IdDomain | undefined {\n if (state === undefined || state.type !== \"string\") return undefined;\n const existing = DOMAINS.get(state);\n if (existing) return existing;\n const generate = state.autoGenerate;\n if (generate === undefined || !isIdFormat(generate.kind)) return undefined;\n // A format the caller did not NAME is not a domain the caller asserted:\n // `.id()` declares a key and carries a generator for convenience, and its\n // values stay whatever a string column holds. `.ulid().id()` names the\n // format and gets the domain, the admission and the compact column.\n if (generate.implicit === true) return undefined;\n const domain: IdDomain = {\n format: generate.kind,\n prefix: generate.prefix,\n length: generate.length,\n };\n DOMAINS.set(state, domain);\n return domain;\n}\n\n// =============================================================================\n// PHYSICAL STORAGE\n// =============================================================================\n\n/** The three dialects a column spelling is asked for. */\nexport type IdDialect = NativeDialect;\n\n/** What one domain is physically, on one dialect. */\nexport interface IdStorage {\n readonly representation: IdRepresentation;\n /** The column type this dialect spells it with. */\n readonly columnType: string;\n}\n\n// `char(n)` is absent deliberately. PostgreSQL BLANK-PADS `character(n)` to its\n// full width, so a 36-character uuid in a `char(40)` column reads back with four\n// trailing spaces and no value of the domain is ever returned — the column is\n// unusable from the moment it is created, for every n wider than the format's\n// own public spelling. MySQL's `CHAR(n)` pads on the way in and STRIPS on the\n// way out, so it keeps its place in that dialect's list.\nconst PG_TEXT_FAMILY = /^(?:text|citext|varchar\\(\\d+\\))$/;\nconst MYSQL_TEXT_FAMILY =\n /^(?:TINYTEXT|TEXT|MEDIUMTEXT|LONGTEXT|VARCHAR\\(\\d+\\)|CHAR\\(\\d+\\))$/;\nconst SQLITE_TEXT_FAMILY = /^TEXT$/;\nconst MYSQL_SIZED_BINARY = /^(?:BINARY|VARBINARY)\\((\\d+)\\)$/;\n\n/** The default column spelling and representation, before any override. */\nfunction defaultIdStorage(format: IdFormat, dialect: IdDialect): IdStorage {\n const width = idByteLength(format);\n if (width === undefined) {\n // `nanoid` and `cuid` keep the text column the dialect already gave them.\n switch (dialect) {\n case \"pg\":\n return { representation: \"text\", columnType: PG.STRING.TEXT.type };\n case \"mysql\":\n return { representation: \"text\", columnType: \"TEXT\" };\n default:\n return {\n representation: \"text\",\n columnType: SQLITE.STRING.TEXT.type,\n };\n }\n }\n switch (dialect) {\n case \"pg\":\n // A UUID gets PostgreSQL's own 16-byte type, which the wire spells as\n // canonical text. A ULID is never spelled `uuid`: its bytes are not a\n // UUID's and a database that formatted them as one would publish a\n // version nibble the value does not have.\n return format === \"uuid\" || format === \"uuidv7\"\n ? { representation: \"uuid\", columnType: PG.STRING.UUID.type }\n : { representation: \"bytes\", columnType: PG.BLOB.BYTEA.type };\n case \"mysql\":\n return {\n representation: \"bytes\",\n columnType: MYSQL.BLOB.BINARY(width).type,\n };\n default:\n return { representation: \"bytes\", columnType: SQLITE.BLOB.BLOB.type };\n }\n}\n\n/** Whether this dialect spells `type` as one of its text column types. */\nfunction isTextColumnType(type: string, dialect: IdDialect): boolean {\n switch (dialect) {\n case \"pg\":\n return PG_TEXT_FAMILY.test(type);\n case \"mysql\":\n return MYSQL_TEXT_FAMILY.test(type);\n default:\n return SQLITE_TEXT_FAMILY.test(type);\n }\n}\n\n/**\n * The representation a BINARY-family override names for this format, or\n * `undefined` when the override is not a binary column this domain fits.\n *\n * A sized MySQL column must be the format's exact width: `BINARY(16)` holds a\n * KSUID's first sixteen bytes and pads a ULID that was never short, and both\n * are silent corruptions rather than storage choices. `bytea` and `BLOB` carry\n * no declared width, so the codec's exact-width encoding is the only promise\n * they need.\n */\nfunction binaryRepresentation(\n type: string,\n format: IdFormat,\n dialect: IdDialect\n): IdRepresentation | undefined {\n const width = idByteLength(format);\n if (width === undefined) return undefined;\n if (dialect === \"pg\") {\n if (type === PG.BLOB.BYTEA.type) return \"bytes\";\n return type === PG.STRING.UUID.type &&\n (format === \"uuid\" || format === \"uuidv7\")\n ? \"uuid\"\n : undefined;\n }\n if (dialect === \"sqlite\") {\n return type === SQLITE.BLOB.BLOB.type ? \"bytes\" : undefined;\n }\n if (type === MYSQL.BLOB.BLOB.type) return \"bytes\";\n const sized = MYSQL_SIZED_BINARY.exec(type);\n return sized && Number(sized[1]) === width ? \"bytes\" : undefined;\n}\n\n/**\n * The column spelling and representation of one domain on one dialect.\n *\n * The ONE owner of that decision: the migration type mapping, the parameter\n * encoding, the read projection and the result decode all derive from this, so\n * a column cannot be created as one thing and written as another.\n *\n * The declaration is resolved for THIS dialect (`nativeTypeFor`): a tagged\n * native type for another dialect, or a map without this dialect's entry, is\n * not this dialect's column and is ignored exactly as every other scalar's\n * mapping ignores it. An override that IS this\n * dialect's and that this domain cannot live in returns `undefined` — the\n * schema boundary refuses it by name long before a query is built, and this\n * answering `undefined` rather than guessing is what keeps that refusal the\n * only place the question is decided.\n */\nexport function idStorageOf(\n domain: IdDomain,\n declaration: NativeTypeDeclaration | undefined,\n dialect: IdDialect\n): IdStorage | undefined {\n const nativeType = nativeTypeFor(declaration, dialect);\n if (nativeType === undefined) {\n return defaultIdStorage(domain.format, dialect);\n }\n const type = nativeType.type;\n if (isTextColumnType(type, dialect)) {\n // The opt-out for a column that already holds text: the domain is still\n // admitted and normalized, only its storage stays as it was.\n return { representation: \"text\", columnType: type };\n }\n const representation = binaryRepresentation(type, domain.format, dialect);\n return representation === undefined\n ? undefined\n : { representation, columnType: type };\n}\n\n/** The overrides this domain accepts on this dialect, for a refusal message. */\nexport function describeIdNativeTypes(\n format: IdFormat,\n dialect: IdDialect\n): string {\n const width = idByteLength(format);\n const text =\n dialect === \"pg\"\n ? \"text, citext, varchar(n)\"\n : dialect === \"mysql\"\n ? \"TEXT, TINYTEXT, MEDIUMTEXT, LONGTEXT, VARCHAR(n), CHAR(n)\"\n : \"TEXT\";\n if (width === undefined) return text;\n const binary =\n dialect === \"pg\"\n ? format === \"uuid\" || format === \"uuidv7\"\n ? \"uuid, bytea\"\n : \"bytea\"\n : dialect === \"mysql\"\n ? `BINARY(${width}), VARBINARY(${width}), BLOB`\n : \"BLOB\";\n return `${binary}, ${text}`;\n}\n","import type { DateTimePhysicalForm } from \"@validation/primitives/datetime-physical-codec\";\nimport { type NativeTypeDeclaration, nativeTypeFor } from \"../native-types\";\n\n/**\n * The physical vocabulary SQLite assigns to one DateTime native declaration.\n *\n * A missing declaration, a declaration that selects nothing on SQLite, and\n * explicit TEXT all use SQLite's default timestamp text. INTEGER is epoch milliseconds and\n * REAL is a Julian day. Schema validation, query lowering, result parsing, and\n * migration defaults consume this same interpretation.\n */\nexport function sqliteDateTimePhysicalForm(\n declaration: NativeTypeDeclaration | undefined\n): DateTimePhysicalForm {\n const nativeType = nativeTypeFor(declaration, \"sqlite\");\n if (nativeType === undefined) return \"text\";\n if (nativeType.type === \"INTEGER\") return \"epochMillis\";\n return nativeType.type === \"REAL\" ? \"julianDay\" : \"text\";\n}\n"],"mappings":"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"}
|
package/dist/planetscale.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as Schema,
|
|
1
|
+
import { A as Schema, F as LinkedClientConfig, Ft as NoExtraDriverConfigKeys, It as VibORMClient, Nn as DriverTransactionOptions, Pn as TransactionOptionSupport, Rn as QueryExecutionContext, jt as DriverConfig, s as DatabaseAdapter, u as Driver, zn as QueryResult } from "./index-BlBkgxtx.mjs";
|
|
2
2
|
import { Client, Config, Connection } from "@planetscale/database";
|
|
3
3
|
|
|
4
4
|
//#region src/drivers/planetscale/index.d.ts
|
package/dist/planetscale.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{n as e}from"./chunk-BuuaeEvq.mjs";import{o as t}from"./value-guards-CK9guf2Z.mjs";import{a as n,o as r}from"./normalized-result-
|
|
1
|
+
import{n as e}from"./chunk-BuuaeEvq.mjs";import{o as t}from"./value-guards-CK9guf2Z.mjs";import{a as n,o as r}from"./normalized-result-ByvlIQqa.mjs";import{l as i}from"./execution-context-_oajgBi4.mjs";import{m as a,u as o}from"./error-mapping-D--MVRCY.mjs";import{d as s}from"./query-CTna5P9o.mjs";import{n as c}from"./client-BpQs13Fn.mjs";import{a as l,c as u,d,o as f,t as p}from"./driver-XlmOJFRH.mjs";import{t as m}from"./sql-statement-tokens-CV2qkIKN.mjs";import{t as h}from"./mysql-adapter-CWisQgdc.mjs";const g=/^(?:0|[1-9]\d*)$/,_=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,v=new Set([`ANALYZE`,`CALL`,`DESC`,`DESCRIBE`,`EXPLAIN`,`SELECT`,`SHOW`,`VALUES`]),y=new Set([`DELETE`,`INSERT`,`REPLACE`,`UPDATE`]),b=new Set([`ALTER`,`BEGIN`,`COMMIT`,`CREATE`,`DROP`,`LOCK`,`RELEASE`,`RENAME`,`ROLLBACK`,`SAVEPOINT`,`SET`,`TRUNCATE`,`UNLOCK`,`USE`]),x=new Set([...v,...y]),defaultFetch=async(e,t)=>globalThis.fetch(e,t);function isRecord(e){return typeof e==`object`&&!!e&&Object.prototype.toString.call(e)===`[object Object]`}function isExecuteEndpoint(e){try{return new URL(e).pathname===`/psdb.v1alpha1.Database/Execute`}catch{return!1}}function getRequestQuery(e){if(typeof e==`string`)try{let t=JSON.parse(e);return isRecord(t)&&typeof t.query==`string`?t.query:void 0}catch{return}}function classifyStatement(e){if(!e)return`unknown`;let t=m(e,{backslashEscapes:!0}),n=t?.[0];if(!(t&&n)||n.kind!==`word`)return`unknown`;let r=0;if(n.value===`WITH`&&(r=t.findIndex((e,t)=>t>0&&e.kind===`word`&&x.has(e.value)),r<0))return`unknown`;let i=t[r]?.value;return i?v.has(i)?`rows`:y.has(i)?t.slice(r+1).some(e=>e.kind===`word`&&e.value===`RETURNING`)?`rows`:`no-rows`:b.has(i)?`no-rows`:`unknown`:`unknown`}function malformedPlanetScaleResponse(e){return new s(`Driver "planetscale" returned a malformed successful response: ${e}.`,{meta:{driver:`planetscale`}})}function assertDenseArray(e){if(!Array.isArray(e))return!1;for(let t=0;t<e.length;t+=1)if(!Object.hasOwn(e,t))return!1;return!0}function validateFields(e){if(!assertDenseArray(e))throw malformedPlanetScaleResponse(`result.fields is not a dense array`);let t=[],n=new Set;for(let r of e){if(!isRecord(r)||typeof r.name!=`string`||r.name.length===0||r.type!==void 0&&typeof r.type!=`string`)throw malformedPlanetScaleResponse(`result.fields contains an invalid field descriptor`);if(r.name===`__proto__`||n.has(r.name))throw malformedPlanetScaleResponse(`result.fields contains an unsafe or duplicate field name`);n.add(r.name),t.push(r)}return t}function validateRows(e,t){if(!assertDenseArray(e))throw malformedPlanetScaleResponse(`result.rows is not a dense array`);if(e.length>0&&t.length===0)throw malformedPlanetScaleResponse(`non-empty result.rows has no matching field metadata`);for(let n of e){if(!(isRecord(n)&&assertDenseArray(n.lengths)))throw malformedPlanetScaleResponse(`result.rows contains a row that does not match result.fields`);let e=getExpectedRowByteLength(n.lengths,t.length),r=getBase64ByteLength(n.values);if(e===void 0||r!==e)throw malformedPlanetScaleResponse(`result.rows contains a row that does not match result.fields`)}}function getExpectedRowByteLength(e,t){if(e.length!==t)return;let n=0;for(let t of e){if(t===`-1`)continue;if(typeof t!=`string`||!g.test(t))return;let e=Number(t);if(!Number.isSafeInteger(e)||n>2**53-1-e)return;n+=e}return n}function getBase64ByteLength(e){if(e===void 0)return 0;if(!(typeof e!=`string`||!_.test(e)))try{let t=atob(e);return btoa(t)===e?t.length:void 0}catch{return}}function validateExecuteEnvelope(e,t){if(!isRecord(e))throw malformedPlanetScaleResponse(`the response body is not an object`);if(Object.hasOwn(e,`error`)&&e.error!=null)return;if(!Object.hasOwn(e,`result`))throw malformedPlanetScaleResponse(`the result member is absent`);let n=e.result;if(n===null){if(t===`no-rows`)return;throw malformedPlanetScaleResponse(`a row-producing or unknown statement has a null result member`)}if(!isRecord(n))throw malformedPlanetScaleResponse(`the result member is not an object or null`);let r=[];if(Object.hasOwn(n,`fields`)&&n.fields!==null&&(r=validateFields(n.fields)),t!==`no-rows`&&r.length===0)throw malformedPlanetScaleResponse(`a row-producing or unknown statement has no field metadata`);if(Object.hasOwn(n,`rows`)&&validateRows(n.rows,r),Object.hasOwn(n,`rowsAffected`)&&n.rowsAffected!==null&&(typeof n.rowsAffected!=`string`||!g.test(n.rowsAffected)))throw malformedPlanetScaleResponse(`result.rowsAffected is malformed`);if(Object.hasOwn(n,`insertId`)&&n.insertId!==null&&(typeof n.insertId!=`string`||!g.test(n.insertId)))throw malformedPlanetScaleResponse(`result.insertId is malformed`)}function wrapExecuteResponse(e,t){return new Proxy(e,{get(e,n){if(n===`json`)return async()=>{let n;try{n=await e.json()}catch{throw malformedPlanetScaleResponse(`the response body is not valid JSON`)}return validateExecuteEnvelope(n,t),n};if(n===`text`)return async()=>{let n=await e.text(),r;try{r=JSON.parse(n)}catch{throw malformedPlanetScaleResponse(`the response body is not valid JSON`)}return validateExecuteEnvelope(r,t),n};let r=Reflect.get(e,n,e);return typeof r==`function`?r.bind(e):r}})}function createValidatedPlanetScaleFetch(e){let t=e??defaultFetch;return async(e,n)=>{let r=classifyStatement(getRequestQuery(n?.body)),i=await t(e,n);return isExecuteEndpoint(e)&&i.ok?wrapExecuteResponse(i,r):i}}const S={client:!0,databaseUrl:!0,options:!0,namespace:!0};function toQueryResult(e,t){let i={provider:`planetscale`,operation:t},a=n(e.insertId,i);return{rows:e.rows,rowCount:r(e.rowsAffected,i),...a===void 0?{}:{insertId:a}}}var PlanetScaleDriver=class extends p{maxBindParametersPerStatement=65535;supportsTransactions=!0;driverOptions;constructor(e={}){let t=d(e);super(`mysql`,`planetscale`),this.driverOptions=e,f(this,`adapter`,new h(t))}async initClient(){let{Client:e}=await import(`@planetscale/database`),n=this.driverOptions.client;if(n){if(!t(n.config))return n;let r={...n.config};return r.fetch=createValidatedPlanetScaleFetch(r.fetch),new e(r)}let r={...this.driverOptions.options};return this.driverOptions.databaseUrl&&(r.url=this.driverOptions.databaseUrl),r.fetch=createValidatedPlanetScaleFetch(r.fetch),new e(r)}async closeClient(e){}async execute(e,t,n,r){let i=r?.operation??`execute`;return toQueryResult(await e.execute(t,n),i)}async executeRaw(e,t,n,r){let i=r?.operation??`executeRaw`;return toQueryResult(await e.execute(t,n),i)}transactionOptionSupport(){return{isolationLevel:`pre-begin`,timeout:!0,maxWait:`unsupported`,maxWaitReason:`each PlanetScale transaction gets its own HTTP connection created without waiting, so there is no acquisition maxWait could bound`}}async transaction(e,t,n,r){if(!(`transaction`in e))throw o(this.driverName);let s=`connection`in e?e.connection():e,c=r?.isolationLevel;return a({begin:async()=>{await s.execute(`SET transaction_mode = 'single'`),c&&await s.execute(l(c)),await s.execute(`BEGIN`)},callback:()=>t(s),commit:()=>s.execute(`COMMIT`),rollback:()=>s.execute(`ROLLBACK`),phases:i(n)})}transactionCleanupFailed(e){this.client&&`connection`in this.client||super.transactionCleanupFailed(e)}};function createClient(e){u(e,`planetscale`,S);let{client:t,databaseUrl:n,options:r}=e;return c(e,new PlanetScaleDriver({client:t,databaseUrl:n,options:r,namespace:d(e)}))}export{PlanetScaleDriver,createClient};
|
|
2
2
|
//# sourceMappingURL=planetscale.mjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Jn as AnyModel, Ki as DiagnosticDisclosure, Zi as DecimalDescriptor, l as AnyDriver, yn as DateTimePhysicalForm } from "./index-BlBkgxtx.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/drivers/execution-context.d.ts
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{n as e}from"./chunk-BuuaeEvq.mjs";import{b as t,n}from"./base-wlv81COV.mjs";import{t as r}from"./migrations-OE5D32qo.mjs";import{N as i,g as a,y as o,yt as s}from"./geo-point-codec-
|
|
1
|
+
import{n as e}from"./chunk-BuuaeEvq.mjs";import{b as t,n}from"./base-wlv81COV.mjs";import{t as r}from"./migrations-OE5D32qo.mjs";import{N as i,g as a,y as o,yt as s}from"./geo-point-codec-Ggv29hSH.mjs";import{s as c}from"./scalar-DNshDNz3.mjs";import{o as l}from"./native-types-CQH05hcr.mjs";import{a as u,r as d}from"./physical-CjG29tya.mjs";import{a as f}from"./datetime-physical-codec-Cdgq6sGs.mjs";import{B as p,J as m,M as h,O as g,P as _,b as v,g as y,m as b,ut as x,v as S,x as C,y as w,z as T}from"./client-BJuTpcYj.mjs";import{n as E,t as D}from"./array-literal-DfgmVxKI.mjs";import{a as ee,n as te}from"./identity-BtuwgqhS.mjs";import{P as O}from"./standard-sql-BtzSzrof.mjs";import{a as k,i as A,n as j,o as M,r as ne}from"./identifier-conversion-BVE8cfFA.mjs";const ie=/;\s*$/,ae=/-/g;function quoteIdentifier(e){return`"${e.replace(/"/g,`""`)}"`}function quoteLiteral(e){return`'${e.replace(/'/g,`''`)}'`}async function canonicalizeIndexPredicates(e,t,n,r,i){if(n.length===0)return[];let a=i??(async e=>{let t=[];for(let n of e)t.push(await r(n));return t}),deparse=async t=>{let n=[...t.keys()].filter(e=>t[e]!==void 0);if(n.length===0)return t.map(()=>void 0);let r=`viborm_index_predicate_${crypto.randomUUID().replace(ae,``)}_`,i=n.map(e=>`${r}${e}`),o=i.map(t=>`${quoteIdentifier(e)}.${quoteIdentifier(t)}`),s=await a([...n.map((e,n)=>`CREATE VIEW ${o[n]} AS ${t[e]}`),`SELECT c.relname AS name, pg_catalog.pg_get_viewdef(c.oid) AS definition FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = ${quoteLiteral(e)} AND c.relname IN (${i.map(quoteLiteral).join(`, `)})`,`DROP VIEW ${o.join(`, `)}`]),c=new Map(s[n.length]?.rows.map(e=>[e.name,e.definition]));return t.map((e,t)=>e===void 0?void 0:c.get(`${r}${t}`)??void 0)};return deparse((await deparse(n.map(e=>`SELECT 1 AS c FROM ${t} WHERE ${e}`))).map(e=>e?.replace(ie,``)))}const N=/::(?:"(?:[^"]|"")+"|[a-zA-Z_][\w$]*)(?:\.(?:"(?:[^"]|"")+"|[a-zA-Z_][\w$]*))?(?:\s+(?:varying|precision|with time zone|without time zone))?(?:\(\d+(?:,\s*\d+)?\))?(?:\[\])?$/,P=new Set([`pg_catalog`,`information_schema`]),F={supportsVector:[`vector`,`halfvec`,`sparsevec`],geoPoint:[`geometry`,`geography`]};function admittedExtensionTypes(e){let t=e?.adapter;return new Set([...t?.capabilities.supportsVector?F.supportsVector:[],...t?.geoPoint?F.geoPoint:[]])}const I=`
|
|
2
2
|
SELECT tables.table_name, tables.table_name AS name, relation.relkind AS relation_kind, relation.relispartition AS is_partition
|
|
3
3
|
FROM information_schema.tables tables
|
|
4
4
|
JOIN pg_catalog.pg_class relation
|
|
@@ -419,4 +419,4 @@ JOIN pg_catalog.pg_constraint con ON con.conrelid = c.oid AND con.contype = 'c'
|
|
|
419
419
|
WHERE n.nspname = $1 AND t.typtype = 'e' AND t.typname = ANY($2::text[])
|
|
420
420
|
AND EXISTS (SELECT 1 FROM pg_catalog.pg_attribute a WHERE a.attrelid = con.conrelid AND a.attnum = ANY(con.conkey) AND a.atttypid IN (t.oid, t.typarray))
|
|
421
421
|
ORDER BY t.typname, c.relname, con.conname`,[this.requireEstateNamespace(),D(e)])).rows.map(({type:e,...t})=>({...t,values:enumValuesNamed(t.definition,e)}))}generateDropEnumSQL(e){return`DROP TYPE IF EXISTS ${this.qualify(e)}`}generateAlterEnum(e,t){let i={...t,currentSchema:this.schemaAtOperation(t)},{enumName:a,addValues:o=[],removeValues:s,newValues:c,dependentColumns:l}=e,u=[],d=this.qualify(a),f=i.currentSchema?.enums?.find(e=>e.name===a)?.values??[],p=c!==void 0&&f.filter(e=>c.includes(e)).join(`\0`)!==c.filter(e=>f.includes(e)).join(`\0`),m=readsAddedValue(a,o,i.currentSchema?.tables??[],t.followingOperations??[]);if(!(s?.length||p||m)){let e=new Set(f);for(let t of o){let n=c?.slice(c.indexOf(t)+1).find(t=>e.has(t));u.push(`ALTER TYPE ${d} ADD VALUE ${this.escapeValue(t)}${n===void 0?``:` BEFORE ${this.escapeValue(n)}`}`),e.add(t)}return u}if(!c?.length)throw new r(`Cannot alter enum "${a}" without its full destination values`,n.MIGRATION_INVALID_STATE);let h=this.recreatedEnumChecks(e,t);for(let{tableName:e,name:t}of h)u.push(`ALTER TABLE ${this.qualify(e)} DROP CONSTRAINT ${this.escapeIdentifier(t)}`);for(let{tableName:e,columnName:t}of l??[]){let n=i.currentSchema?.tables.find(t=>t.name===e)?.columns.find(e=>e.name===t),r=`${this.qualify(e)} ALTER COLUMN ${this.escapeIdentifier(t)}`;n?.default!==void 0&&u.push(`ALTER TABLE ${r} DROP DEFAULT`);let a=n?.type.endsWith(`[]`)?`text[]`:`text`;u.push(`ALTER TABLE ${r} TYPE ${a} USING ${this.escapeIdentifier(t)}::${a}`)}u.push(...this.buildEnumReplacementUpdates(e,i)),u.push(`DROP TYPE ${d}`),u.push(`CREATE TYPE ${d} AS ENUM (${c.map(e=>this.escapeValue(e)).join(`, `)})`);for(let{tableName:e,columnName:t}of l??[]){let n=i.currentSchema?.tables.find(t=>t.name===e)?.columns.find(e=>e.name===t),r=`${this.qualify(e)} ALTER COLUMN ${this.escapeIdentifier(t)}`,o=n?.type.endsWith(`[]`)?`${d}[]`:d;u.push(`ALTER TABLE ${r} TYPE ${o} USING ${this.escapeIdentifier(t)}::${o}`),n?.default!==void 0&&!enumDefaultLabels(n,a).some(e=>e!==null&&s?.includes(e))&&u.push(`ALTER TABLE ${r} SET DEFAULT ${n.default}`)}for(let{tableName:e,name:t,definition:n}of h)u.push(`ALTER TABLE ${this.qualify(e)} ADD CONSTRAINT ${this.escapeIdentifier(t)} ${n}`);return u}recreatedEnumChecks(e,t){let i=e.dependentChecks??[];for(let a of i){let i=a.values.find(t=>e.removeValues?.includes(t));if(i!==void 0)throw new r(`CHECK constraint "${a.name}" on "${a.tableName}" names the value '${i}', which this change removes from enum "${e.enumName}", so it cannot be added back once the type is recreated. Drop the constraint or rewrite it without '${i}', then push again. No migration effects were executed.`,n.MIGRATION_INVALID_STATE,{meta:{table:a.tableName,constraint:a.name,enum:e.enumName,value:i}});if(t.precedingOperations?.some(e=>e.type===`renameTable`&&e.from===a.tableName||e.type===`renameColumn`&&e.tableName===a.tableName))throw new r(`CHECK constraint "${a.name}" on "${a.tableName}" must be dropped and added back around the recreation of enum "${e.enumName}", but this push renames "${a.tableName}" or one of its columns first, and the definition was read before that rename. Push the rename on its own, then the enum change. No migration effects were executed.`,n.MIGRATION_INVALID_STATE,{meta:{table:a.tableName,constraint:a.name,enum:e.enumName}})}return i}enumColumnReplacementUpdates(e,t,n,r){if(!(r.currentSchema?.tables.find(e=>e.name===t)?.columns.find(e=>e.name===n)?.type)?.endsWith(`[]`))return super.enumColumnReplacementUpdates(e,t,n,r);let i=this.enumReplacementCases(e,t,n);if(i.length===0)return[];let a=this.escapeIdentifier(n);return[`UPDATE ${this.qualify(t)} SET ${a} = ARRAY(SELECT CASE value ${i.join(` `)} ELSE value END FROM unnest(${a}) WITH ORDINALITY AS member(value, position) ORDER BY position) WHERE ${a} IS NOT NULL`]}};export{ye as t};
|
|
422
|
-
//# sourceMappingURL=postgres-
|
|
422
|
+
//# sourceMappingURL=postgres-C2uUUh0t.mjs.map
|