drizzle-orm 0.25.4 → 0.25.5-ee7217a

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/aws-data-api/pg/index.cjs +1 -1
  2. package/aws-data-api/pg/index.mjs +1 -1
  3. package/better-sqlite3/index.cjs +1 -1
  4. package/better-sqlite3/index.mjs +1 -1
  5. package/bun-sqlite/index.cjs +1 -1
  6. package/bun-sqlite/index.mjs +1 -1
  7. package/d1/index.cjs +1 -1
  8. package/d1/index.mjs +1 -1
  9. package/libsql/index.cjs +1 -1
  10. package/libsql/index.mjs +1 -1
  11. package/mysql-core/index.cjs +1 -1
  12. package/mysql-core/index.mjs +1 -1
  13. package/mysql2/index.cjs +1 -1
  14. package/mysql2/index.mjs +1 -1
  15. package/neon-serverless/index.cjs +1 -1
  16. package/neon-serverless/index.mjs +1 -1
  17. package/node-postgres/index.cjs +1 -1
  18. package/node-postgres/index.mjs +1 -1
  19. package/package.json +1 -1
  20. package/pg-core/index.cjs +1 -1
  21. package/pg-core/index.mjs +1 -1
  22. package/planetscale-serverless/index.cjs +1 -1
  23. package/planetscale-serverless/index.mjs +1 -1
  24. package/postgres-js/index.cjs +1 -1
  25. package/postgres-js/index.mjs +1 -1
  26. package/{session-ef1ef979.cjs → session-815af33e.cjs} +3 -3
  27. package/session-815af33e.cjs.map +1 -0
  28. package/session-a87f051d.mjs +8 -0
  29. package/session-a87f051d.mjs.map +1 -0
  30. package/{session-b6939bab.cjs → session-c9c5780f.cjs} +2 -2
  31. package/session-c9c5780f.cjs.map +1 -0
  32. package/{session-b977ce56.mjs → session-df989164.mjs} +3 -3
  33. package/session-df989164.mjs.map +1 -0
  34. package/session-e630c258.cjs +8 -0
  35. package/session-e630c258.cjs.map +1 -0
  36. package/{session-c891400d.mjs → session-fdec872e.mjs} +3 -3
  37. package/session-fdec872e.mjs.map +1 -0
  38. package/sql-js/index.cjs +1 -1
  39. package/sql-js/index.mjs +1 -1
  40. package/sqlite-core/index.cjs +1 -1
  41. package/sqlite-core/index.mjs +1 -1
  42. package/sqlite-proxy/index.cjs +1 -1
  43. package/sqlite-proxy/index.mjs +1 -1
  44. package/vercel-postgres/index.cjs +1 -1
  45. package/vercel-postgres/index.mjs +1 -1
  46. package/version.cjs +1 -1
  47. package/version.d.ts +1 -1
  48. package/version.mjs +1 -1
  49. package/version.mjs.map +1 -1
  50. package/session-8a621f09.mjs +0 -8
  51. package/session-8a621f09.mjs.map +0 -1
  52. package/session-b6939bab.cjs.map +0 -1
  53. package/session-b977ce56.mjs.map +0 -1
  54. package/session-c891400d.mjs.map +0 -1
  55. package/session-e6db6732.cjs +0 -8
  56. package/session-e6db6732.cjs.map +0 -1
  57. package/session-ef1ef979.cjs.map +0 -1
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("../../logger-04bad527.cjs"),t=require("../../session-ef1ef979.cjs"),s=require("@aws-sdk/client-rds-data"),r=require("../../index-59b7992d.cjs"),n=require("../../utils-9d882195.cjs");function i(e){return"date"===e?s.TypeHint.DATE:"decimal"===e?s.TypeHint.DECIMAL:"json"===e?s.TypeHint.JSON:"time"===e?s.TypeHint.TIME:"timestamp"===e?s.TypeHint.TIMESTAMP:"uuid"===e?s.TypeHint.UUID:void 0}function a(e,t){const s={value:{},typeHint:i(t)};if(null===e)s.value={isNull:!0};else if("string"==typeof e)s.value="DATE"===s.typeHint?{stringValue:e.split("T")[0]}:{stringValue:e};else if("number"==typeof e&&Number.isInteger(e))s.value={longValue:e};else if("number"!=typeof e||Number.isInteger(e))if("boolean"==typeof e)s.value={booleanValue:e};else{if(!(e instanceof Date))throw new Error(`Unknown type for ${e}`);s.value={stringValue:e.toISOString().replace("T"," ").replace("Z","")}}else s.value={doubleValue:e};return s}require("../../query-promise-2c5b43ab.cjs"),require("../../query-builder-2f2e8229.cjs"),require("../../column-builder-b48639f3.cjs");class o extends t.PreparedQuery{constructor(e,t,r,n,i,a,o){super(),this.client=e,this.params=r,this.typings=n,this.options=i,this.fields=a,this.transactionId=o,this.rawQuery=new s.ExecuteStatementCommand({sql:t,parameters:[],secretArn:i.secretArn,resourceArn:i.resourceArn,database:i.database,transactionId:o})}async execute(e={}){const t=r.fillPlaceholders(this.params,e);this.rawQuery.input.parameters=t.map(((e,t)=>({name:`${t+1}`,...a(e,this.typings[t])}))),this.options.logger?.logQuery(this.rawQuery.input.sql,this.rawQuery.input.parameters);const{fields:s,rawQuery:i,client:o,joinsNotNullableMap:l}=this;if(!s){return(await o.send(i)).records??[]}const u=await o.send(i);return u.records?.map((e=>{const t=e.map((e=>function(e){if(void 0!==e.stringValue)return e.stringValue;if(void 0!==e.booleanValue)return e.booleanValue;if(void 0!==e.doubleValue)return e.doubleValue;if(void 0!==e.isNull)return null;if(void 0!==e.longValue)return e.longValue;if(void 0!==e.blobValue)return e.blobValue;if(void 0!==e.arrayValue){if(void 0!==e.arrayValue.stringValues)return e.arrayValue.stringValues;throw new Error("Unknown array type")}throw new Error("Unknown type")}(e)));return n.mapResultRow(s,t,l)}))}all(e){return this.execute(e)}}class l extends t.PgSession{constructor(e,t,s,r){super(t),this.client=e,this.options=s,this.transactionId=r,this.rawQuery={secretArn:s.secretArn,resourceArn:s.resourceArn,database:s.database}}prepareQuery(e,t,s){return new o(this.client,e.sql,e.params,e.typings??[],this.options,t,s)}execute(e){return this.prepareQuery(this.dialect.sqlToQuery(e),void 0,this.transactionId).execute()}async transaction(e,t){const{transactionId:r}=await this.client.send(new s.BeginTransactionCommand(this.rawQuery)),n=new l(this.client,this.dialect,this.options,r),i=new u(this.dialect,n);t&&await i.setTransaction(t);try{const t=await e(i);return await this.client.send(new s.CommitTransactionCommand({...this.rawQuery,transactionId:r})),t}catch(e){throw await this.client.send(new s.RollbackTransactionCommand({...this.rawQuery,transactionId:r})),e}}}class u extends t.PgTransaction{transaction(e){const t=`sp${this.nestedIndex+1}`,s=new u(this.dialect,this.session,this.nestedIndex+1);this.session.execute(r.sql`savepoint ${t}`);try{const n=e(s);return this.session.execute(r.sql`release savepoint ${t}`),n}catch(e){throw this.session.execute(r.sql`rollback to savepoint ${t}`),e}}}class c{constructor(e,t,s){this.client=e,this.dialect=t,this.options=s}createSession(){return new l(this.client,this.dialect,this.options,void 0)}}class p extends t.PgDialect{escapeName(e){return`"${e}"`}escapeParam(e){return`:${e+1}`}}exports.AwsDataApiDriver=c,exports.AwsDataApiPreparedQuery=o,exports.AwsDataApiSession=l,exports.AwsDataApiTransaction=u,exports.AwsPgDialect=p,exports.drizzle=function(s,r){const n=new p;let i;!0===r.logger?i=new e.DefaultLogger:!1!==r.logger&&(i=r.logger);const a=new c(s,n,{...r,logger:i}).createSession();return new t.PgDatabase(n,a)};
1
+ "use strict";var e=require("../../logger-04bad527.cjs"),t=require("../../session-815af33e.cjs"),s=require("@aws-sdk/client-rds-data"),r=require("../../index-59b7992d.cjs"),n=require("../../utils-9d882195.cjs");function i(e){return"date"===e?s.TypeHint.DATE:"decimal"===e?s.TypeHint.DECIMAL:"json"===e?s.TypeHint.JSON:"time"===e?s.TypeHint.TIME:"timestamp"===e?s.TypeHint.TIMESTAMP:"uuid"===e?s.TypeHint.UUID:void 0}function a(e,t){const s={value:{},typeHint:i(t)};if(null===e)s.value={isNull:!0};else if("string"==typeof e)s.value="DATE"===s.typeHint?{stringValue:e.split("T")[0]}:{stringValue:e};else if("number"==typeof e&&Number.isInteger(e))s.value={longValue:e};else if("number"!=typeof e||Number.isInteger(e))if("boolean"==typeof e)s.value={booleanValue:e};else{if(!(e instanceof Date))throw new Error(`Unknown type for ${e}`);s.value={stringValue:e.toISOString().replace("T"," ").replace("Z","")}}else s.value={doubleValue:e};return s}require("../../query-promise-2c5b43ab.cjs"),require("../../query-builder-2f2e8229.cjs"),require("../../column-builder-b48639f3.cjs");class o extends t.PreparedQuery{constructor(e,t,r,n,i,a,o){super(),this.client=e,this.params=r,this.typings=n,this.options=i,this.fields=a,this.transactionId=o,this.rawQuery=new s.ExecuteStatementCommand({sql:t,parameters:[],secretArn:i.secretArn,resourceArn:i.resourceArn,database:i.database,transactionId:o})}async execute(e={}){const t=r.fillPlaceholders(this.params,e);this.rawQuery.input.parameters=t.map(((e,t)=>({name:`${t+1}`,...a(e,this.typings[t])}))),this.options.logger?.logQuery(this.rawQuery.input.sql,this.rawQuery.input.parameters);const{fields:s,rawQuery:i,client:o,joinsNotNullableMap:l}=this;if(!s){return(await o.send(i)).records??[]}const u=await o.send(i);return u.records?.map((e=>{const t=e.map((e=>function(e){if(void 0!==e.stringValue)return e.stringValue;if(void 0!==e.booleanValue)return e.booleanValue;if(void 0!==e.doubleValue)return e.doubleValue;if(void 0!==e.isNull)return null;if(void 0!==e.longValue)return e.longValue;if(void 0!==e.blobValue)return e.blobValue;if(void 0!==e.arrayValue){if(void 0!==e.arrayValue.stringValues)return e.arrayValue.stringValues;throw new Error("Unknown array type")}throw new Error("Unknown type")}(e)));return n.mapResultRow(s,t,l)}))}all(e){return this.execute(e)}}class l extends t.PgSession{constructor(e,t,s,r){super(t),this.client=e,this.options=s,this.transactionId=r,this.rawQuery={secretArn:s.secretArn,resourceArn:s.resourceArn,database:s.database}}prepareQuery(e,t,s){return new o(this.client,e.sql,e.params,e.typings??[],this.options,t,s)}execute(e){return this.prepareQuery(this.dialect.sqlToQuery(e),void 0,this.transactionId).execute()}async transaction(e,t){const{transactionId:r}=await this.client.send(new s.BeginTransactionCommand(this.rawQuery)),n=new l(this.client,this.dialect,this.options,r),i=new u(this.dialect,n);t&&await i.setTransaction(t);try{const t=await e(i);return await this.client.send(new s.CommitTransactionCommand({...this.rawQuery,transactionId:r})),t}catch(e){throw await this.client.send(new s.RollbackTransactionCommand({...this.rawQuery,transactionId:r})),e}}}class u extends t.PgTransaction{transaction(e){const t=`sp${this.nestedIndex+1}`,s=new u(this.dialect,this.session,this.nestedIndex+1);this.session.execute(r.sql`savepoint ${t}`);try{const n=e(s);return this.session.execute(r.sql`release savepoint ${t}`),n}catch(e){throw this.session.execute(r.sql`rollback to savepoint ${t}`),e}}}class c{constructor(e,t,s){this.client=e,this.dialect=t,this.options=s}createSession(){return new l(this.client,this.dialect,this.options,void 0)}}class p extends t.PgDialect{escapeName(e){return`"${e}"`}escapeParam(e){return`:${e+1}`}}exports.AwsDataApiDriver=c,exports.AwsDataApiPreparedQuery=o,exports.AwsDataApiSession=l,exports.AwsDataApiTransaction=u,exports.AwsPgDialect=p,exports.drizzle=function(s,r){const n=new p;let i;!0===r.logger?i=new e.DefaultLogger:!1!==r.logger&&(i=r.logger);const a=new c(s,n,{...r,logger:i}).createSession();return new t.PgDatabase(n,a)};
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1,2 +1,2 @@
1
- import{D as e}from"../../logger-2598bf05.mjs";import{P as t,a as s,b as r,c as n,d as i}from"../../session-c891400d.mjs";import{TypeHint as a,ExecuteStatementCommand as o,BeginTransactionCommand as l,CommitTransactionCommand as u,RollbackTransactionCommand as c}from"@aws-sdk/client-rds-data";import{k as d,s as p}from"../../index-b71998f1.mjs";import{m as h}from"../../utils-e6870670.mjs";import"../../query-promise-a65edd44.mjs";import"../../query-builder-2fcde2f0.mjs";import"../../column-builder-592f0191.mjs";function m(e){return"date"===e?a.DATE:"decimal"===e?a.DECIMAL:"json"===e?a.JSON:"time"===e?a.TIME:"timestamp"===e?a.TIMESTAMP:"uuid"===e?a.UUID:void 0}function w(e,t){const s={value:{},typeHint:m(t)};if(null===e)s.value={isNull:!0};else if("string"==typeof e)s.value="DATE"===s.typeHint?{stringValue:e.split("T")[0]}:{stringValue:e};else if("number"==typeof e&&Number.isInteger(e))s.value={longValue:e};else if("number"!=typeof e||Number.isInteger(e))if("boolean"==typeof e)s.value={booleanValue:e};else{if(!(e instanceof Date))throw new Error(`Unknown type for ${e}`);s.value={stringValue:e.toISOString().replace("T"," ").replace("Z","")}}else s.value={doubleValue:e};return s}class y extends t{constructor(e,t,s,r,n,i,a){super(),this.client=e,this.params=s,this.typings=r,this.options=n,this.fields=i,this.transactionId=a,this.rawQuery=new o({sql:t,parameters:[],secretArn:n.secretArn,resourceArn:n.resourceArn,database:n.database,transactionId:a})}async execute(e={}){const t=d(this.params,e);this.rawQuery.input.parameters=t.map(((e,t)=>({name:`${t+1}`,...w(e,this.typings[t])}))),this.options.logger?.logQuery(this.rawQuery.input.sql,this.rawQuery.input.parameters);const{fields:s,rawQuery:r,client:n,joinsNotNullableMap:i}=this;if(!s){return(await n.send(r)).records??[]}const a=await n.send(r);return a.records?.map((e=>{const t=e.map((e=>function(e){if(void 0!==e.stringValue)return e.stringValue;if(void 0!==e.booleanValue)return e.booleanValue;if(void 0!==e.doubleValue)return e.doubleValue;if(void 0!==e.isNull)return null;if(void 0!==e.longValue)return e.longValue;if(void 0!==e.blobValue)return e.blobValue;if(void 0!==e.arrayValue){if(void 0!==e.arrayValue.stringValues)return e.arrayValue.stringValues;throw new Error("Unknown array type")}throw new Error("Unknown type")}(e)));return h(s,t,i)}))}all(e){return this.execute(e)}}class f extends s{constructor(e,t,s,r){super(t),this.client=e,this.options=s,this.transactionId=r,this.rawQuery={secretArn:s.secretArn,resourceArn:s.resourceArn,database:s.database}}prepareQuery(e,t,s){return new y(this.client,e.sql,e.params,e.typings??[],this.options,t,s)}execute(e){return this.prepareQuery(this.dialect.sqlToQuery(e),void 0,this.transactionId).execute()}async transaction(e,t){const{transactionId:s}=await this.client.send(new l(this.rawQuery)),r=new f(this.client,this.dialect,this.options,s),n=new g(this.dialect,r);t&&await n.setTransaction(t);try{const t=await e(n);return await this.client.send(new u({...this.rawQuery,transactionId:s})),t}catch(e){throw await this.client.send(new c({...this.rawQuery,transactionId:s})),e}}}class g extends r{transaction(e){const t=`sp${this.nestedIndex+1}`,s=new g(this.dialect,this.session,this.nestedIndex+1);this.session.execute(p`savepoint ${t}`);try{const r=e(s);return this.session.execute(p`release savepoint ${t}`),r}catch(e){throw this.session.execute(p`rollback to savepoint ${t}`),e}}}class b{constructor(e,t,s){this.client=e,this.dialect=t,this.options=s}createSession(){return new f(this.client,this.dialect,this.options,void 0)}}class v extends n{escapeName(e){return`"${e}"`}escapeParam(e){return`:${e+1}`}}function V(t,s){const r=new v;let n;!0===s.logger?n=new e:!1!==s.logger&&(n=s.logger);const a=new b(t,r,{...s,logger:n}).createSession();return new i(r,a)}export{b as AwsDataApiDriver,y as AwsDataApiPreparedQuery,f as AwsDataApiSession,g as AwsDataApiTransaction,v as AwsPgDialect,V as drizzle};
1
+ import{D as e}from"../../logger-2598bf05.mjs";import{P as t,a as s,b as r,c as n,d as i}from"../../session-fdec872e.mjs";import{TypeHint as a,ExecuteStatementCommand as o,BeginTransactionCommand as l,CommitTransactionCommand as u,RollbackTransactionCommand as c}from"@aws-sdk/client-rds-data";import{k as d,s as p}from"../../index-b71998f1.mjs";import{m as h}from"../../utils-e6870670.mjs";import"../../query-promise-a65edd44.mjs";import"../../query-builder-2fcde2f0.mjs";import"../../column-builder-592f0191.mjs";function m(e){return"date"===e?a.DATE:"decimal"===e?a.DECIMAL:"json"===e?a.JSON:"time"===e?a.TIME:"timestamp"===e?a.TIMESTAMP:"uuid"===e?a.UUID:void 0}function w(e,t){const s={value:{},typeHint:m(t)};if(null===e)s.value={isNull:!0};else if("string"==typeof e)s.value="DATE"===s.typeHint?{stringValue:e.split("T")[0]}:{stringValue:e};else if("number"==typeof e&&Number.isInteger(e))s.value={longValue:e};else if("number"!=typeof e||Number.isInteger(e))if("boolean"==typeof e)s.value={booleanValue:e};else{if(!(e instanceof Date))throw new Error(`Unknown type for ${e}`);s.value={stringValue:e.toISOString().replace("T"," ").replace("Z","")}}else s.value={doubleValue:e};return s}class y extends t{constructor(e,t,s,r,n,i,a){super(),this.client=e,this.params=s,this.typings=r,this.options=n,this.fields=i,this.transactionId=a,this.rawQuery=new o({sql:t,parameters:[],secretArn:n.secretArn,resourceArn:n.resourceArn,database:n.database,transactionId:a})}async execute(e={}){const t=d(this.params,e);this.rawQuery.input.parameters=t.map(((e,t)=>({name:`${t+1}`,...w(e,this.typings[t])}))),this.options.logger?.logQuery(this.rawQuery.input.sql,this.rawQuery.input.parameters);const{fields:s,rawQuery:r,client:n,joinsNotNullableMap:i}=this;if(!s){return(await n.send(r)).records??[]}const a=await n.send(r);return a.records?.map((e=>{const t=e.map((e=>function(e){if(void 0!==e.stringValue)return e.stringValue;if(void 0!==e.booleanValue)return e.booleanValue;if(void 0!==e.doubleValue)return e.doubleValue;if(void 0!==e.isNull)return null;if(void 0!==e.longValue)return e.longValue;if(void 0!==e.blobValue)return e.blobValue;if(void 0!==e.arrayValue){if(void 0!==e.arrayValue.stringValues)return e.arrayValue.stringValues;throw new Error("Unknown array type")}throw new Error("Unknown type")}(e)));return h(s,t,i)}))}all(e){return this.execute(e)}}class f extends s{constructor(e,t,s,r){super(t),this.client=e,this.options=s,this.transactionId=r,this.rawQuery={secretArn:s.secretArn,resourceArn:s.resourceArn,database:s.database}}prepareQuery(e,t,s){return new y(this.client,e.sql,e.params,e.typings??[],this.options,t,s)}execute(e){return this.prepareQuery(this.dialect.sqlToQuery(e),void 0,this.transactionId).execute()}async transaction(e,t){const{transactionId:s}=await this.client.send(new l(this.rawQuery)),r=new f(this.client,this.dialect,this.options,s),n=new g(this.dialect,r);t&&await n.setTransaction(t);try{const t=await e(n);return await this.client.send(new u({...this.rawQuery,transactionId:s})),t}catch(e){throw await this.client.send(new c({...this.rawQuery,transactionId:s})),e}}}class g extends r{transaction(e){const t=`sp${this.nestedIndex+1}`,s=new g(this.dialect,this.session,this.nestedIndex+1);this.session.execute(p`savepoint ${t}`);try{const r=e(s);return this.session.execute(p`release savepoint ${t}`),r}catch(e){throw this.session.execute(p`rollback to savepoint ${t}`),e}}}class b{constructor(e,t,s){this.client=e,this.dialect=t,this.options=s}createSession(){return new f(this.client,this.dialect,this.options,void 0)}}class v extends n{escapeName(e){return`"${e}"`}escapeParam(e){return`:${e+1}`}}function V(t,s){const r=new v;let n;!0===s.logger?n=new e:!1!==s.logger&&(n=s.logger);const a=new b(t,r,{...s,logger:n}).createSession();return new i(r,a)}export{b as AwsDataApiDriver,y as AwsDataApiPreparedQuery,f as AwsDataApiSession,g as AwsDataApiTransaction,v as AwsPgDialect,V as drizzle};
2
2
  //# sourceMappingURL=index.mjs.map
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("../logger-04bad527.cjs"),s=require("../session-b6939bab.cjs"),t=require("../index-59b7992d.cjs"),r=require("../utils-9d882195.cjs");require("../query-builder-2f2e8229.cjs");class i extends s.SQLiteSession{constructor(s,t,r={}){super(t),this.client=s,this.logger=r.logger??new e.NoopLogger}prepareQuery(e,s){const t=this.client.prepare(e.sql);return new l(t,e.sql,e.params,this.logger,s)}transaction(e,s={}){const t=new n(this.dialect,this);return this.client.transaction(e)[s.behavior??"deferred"](t)}}class n extends s.SQLiteTransaction{transaction(e){const s=`sp${this.nestedIndex}`,r=new n(this.dialect,this.session,this.nestedIndex+1);this.session.run(t.sql.raw(`savepoint ${s}`));try{const i=e(r);return this.session.run(t.sql.raw(`release savepoint ${s}`)),i}catch(e){throw this.session.run(t.sql.raw(`rollback to savepoint ${s}`)),e}}}class l extends s.PreparedQuery{constructor(e,s,t,r,i){super(),this.stmt=e,this.queryString=s,this.params=t,this.logger=r,this.fields=i}run(e){const s=t.fillPlaceholders(this.params,e??{});return this.logger.logQuery(this.queryString,s),this.stmt.run(...s)}all(e){const{fields:s,joinsNotNullableMap:i,queryString:n,logger:l,stmt:o}=this;if(s)return this.values(e).map((e=>r.mapResultRow(s,e,i)));const a=t.fillPlaceholders(this.params,e??{});return l.logQuery(n,a),o.all(...a)}get(e){const s=t.fillPlaceholders(this.params,e??{});this.logger.logQuery(this.queryString,s);const{fields:i,stmt:n,joinsNotNullableMap:l}=this;if(!i)return n.get(...s);const o=n.raw().get(...s);return o?r.mapResultRow(i,o,l):void 0}values(e){const s=t.fillPlaceholders(this.params,e??{});return this.logger.logQuery(this.queryString,s),this.stmt.raw().all(...s)}}exports.BetterSQLiteSession=i,exports.BetterSQLiteTransaction=n,exports.PreparedQuery=l,exports.drizzle=function(t,r={}){const n=new s.SQLiteSyncDialect;let l;!0===r.logger?l=new e.DefaultLogger:!1!==r.logger&&(l=r.logger);const o=new i(t,n,{logger:l});return new s.BaseSQLiteDatabase(n,o)};
1
+ "use strict";var e=require("../logger-04bad527.cjs"),s=require("../session-c9c5780f.cjs"),t=require("../index-59b7992d.cjs"),r=require("../utils-9d882195.cjs");require("../query-builder-2f2e8229.cjs");class i extends s.SQLiteSession{constructor(s,t,r={}){super(t),this.client=s,this.logger=r.logger??new e.NoopLogger}prepareQuery(e,s){const t=this.client.prepare(e.sql);return new l(t,e.sql,e.params,this.logger,s)}transaction(e,s={}){const t=new n(this.dialect,this);return this.client.transaction(e)[s.behavior??"deferred"](t)}}class n extends s.SQLiteTransaction{transaction(e){const s=`sp${this.nestedIndex}`,r=new n(this.dialect,this.session,this.nestedIndex+1);this.session.run(t.sql.raw(`savepoint ${s}`));try{const i=e(r);return this.session.run(t.sql.raw(`release savepoint ${s}`)),i}catch(e){throw this.session.run(t.sql.raw(`rollback to savepoint ${s}`)),e}}}class l extends s.PreparedQuery{constructor(e,s,t,r,i){super(),this.stmt=e,this.queryString=s,this.params=t,this.logger=r,this.fields=i}run(e){const s=t.fillPlaceholders(this.params,e??{});return this.logger.logQuery(this.queryString,s),this.stmt.run(...s)}all(e){const{fields:s,joinsNotNullableMap:i,queryString:n,logger:l,stmt:o}=this;if(s)return this.values(e).map((e=>r.mapResultRow(s,e,i)));const a=t.fillPlaceholders(this.params,e??{});return l.logQuery(n,a),o.all(...a)}get(e){const s=t.fillPlaceholders(this.params,e??{});this.logger.logQuery(this.queryString,s);const{fields:i,stmt:n,joinsNotNullableMap:l}=this;if(!i)return n.get(...s);const o=n.raw().get(...s);return o?r.mapResultRow(i,o,l):void 0}values(e){const s=t.fillPlaceholders(this.params,e??{});return this.logger.logQuery(this.queryString,s),this.stmt.raw().all(...s)}}exports.BetterSQLiteSession=i,exports.BetterSQLiteTransaction=n,exports.PreparedQuery=l,exports.drizzle=function(t,r={}){const n=new s.SQLiteSyncDialect;let l;!0===r.logger?l=new e.DefaultLogger:!1!==r.logger&&(l=r.logger);const o=new i(t,n,{logger:l});return new s.BaseSQLiteDatabase(n,o)};
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1,2 +1,2 @@
1
- import{N as s,D as t}from"../logger-2598bf05.mjs";import{S as r,a as e,P as i,B as n,b as o}from"../session-b977ce56.mjs";import{s as a,k as l}from"../index-b71998f1.mjs";import{m as g}from"../utils-e6870670.mjs";import"../query-builder-2fcde2f0.mjs";class h extends r{constructor(t,r,e={}){super(r),this.client=t,this.logger=e.logger??new s}prepareQuery(s,t){const r=this.client.prepare(s.sql);return new c(r,s.sql,s.params,this.logger,t)}transaction(s,t={}){const r=new u(this.dialect,this);return this.client.transaction(s)[t.behavior??"deferred"](r)}}class u extends e{transaction(s){const t=`sp${this.nestedIndex}`,r=new u(this.dialect,this.session,this.nestedIndex+1);this.session.run(a.raw(`savepoint ${t}`));try{const e=s(r);return this.session.run(a.raw(`release savepoint ${t}`)),e}catch(s){throw this.session.run(a.raw(`rollback to savepoint ${t}`)),s}}}class c extends i{constructor(s,t,r,e,i){super(),this.stmt=s,this.queryString=t,this.params=r,this.logger=e,this.fields=i}run(s){const t=l(this.params,s??{});return this.logger.logQuery(this.queryString,t),this.stmt.run(...t)}all(s){const{fields:t,joinsNotNullableMap:r,queryString:e,logger:i,stmt:n}=this;if(t)return this.values(s).map((s=>g(t,s,r)));const o=l(this.params,s??{});return i.logQuery(e,o),n.all(...o)}get(s){const t=l(this.params,s??{});this.logger.logQuery(this.queryString,t);const{fields:r,stmt:e,joinsNotNullableMap:i}=this;if(!r)return e.get(...t);const n=e.raw().get(...t);return n?g(r,n,i):void 0}values(s){const t=l(this.params,s??{});return this.logger.logQuery(this.queryString,t),this.stmt.raw().all(...t)}}function m(s,r={}){const e=new o;let i;!0===r.logger?i=new t:!1!==r.logger&&(i=r.logger);const a=new h(s,e,{logger:i});return new n(e,a)}export{h as BetterSQLiteSession,u as BetterSQLiteTransaction,c as PreparedQuery,m as drizzle};
1
+ import{N as s,D as t}from"../logger-2598bf05.mjs";import{S as r,a as e,P as i,B as n,b as o}from"../session-df989164.mjs";import{s as a,k as l}from"../index-b71998f1.mjs";import{m as g}from"../utils-e6870670.mjs";import"../query-builder-2fcde2f0.mjs";class h extends r{constructor(t,r,e={}){super(r),this.client=t,this.logger=e.logger??new s}prepareQuery(s,t){const r=this.client.prepare(s.sql);return new c(r,s.sql,s.params,this.logger,t)}transaction(s,t={}){const r=new u(this.dialect,this);return this.client.transaction(s)[t.behavior??"deferred"](r)}}class u extends e{transaction(s){const t=`sp${this.nestedIndex}`,r=new u(this.dialect,this.session,this.nestedIndex+1);this.session.run(a.raw(`savepoint ${t}`));try{const e=s(r);return this.session.run(a.raw(`release savepoint ${t}`)),e}catch(s){throw this.session.run(a.raw(`rollback to savepoint ${t}`)),s}}}class c extends i{constructor(s,t,r,e,i){super(),this.stmt=s,this.queryString=t,this.params=r,this.logger=e,this.fields=i}run(s){const t=l(this.params,s??{});return this.logger.logQuery(this.queryString,t),this.stmt.run(...t)}all(s){const{fields:t,joinsNotNullableMap:r,queryString:e,logger:i,stmt:n}=this;if(t)return this.values(s).map((s=>g(t,s,r)));const o=l(this.params,s??{});return i.logQuery(e,o),n.all(...o)}get(s){const t=l(this.params,s??{});this.logger.logQuery(this.queryString,t);const{fields:r,stmt:e,joinsNotNullableMap:i}=this;if(!r)return e.get(...t);const n=e.raw().get(...t);return n?g(r,n,i):void 0}values(s){const t=l(this.params,s??{});return this.logger.logQuery(this.queryString,t),this.stmt.raw().all(...t)}}function m(s,r={}){const e=new o;let i;!0===r.logger?i=new t:!1!==r.logger&&(i=r.logger);const a=new h(s,e,{logger:i});return new n(e,a)}export{h as BetterSQLiteSession,u as BetterSQLiteTransaction,c as PreparedQuery,m as drizzle};
2
2
  //# sourceMappingURL=index.mjs.map
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("../logger-04bad527.cjs"),s=require("../session-b6939bab.cjs"),t=require("../index-59b7992d.cjs"),r=require("../utils-9d882195.cjs");require("../query-builder-2f2e8229.cjs");class i extends s.SQLiteSession{constructor(s,t,r={}){super(t),this.client=s,this.logger=r.logger??new e.NoopLogger}exec(e){this.client.exec(e)}prepareQuery(e,s){const t=this.client.prepare(e.sql);return new l(t,e.sql,e.params,this.logger,s)}transaction(e,s={}){const t=new n(this.dialect,this);let r;return this.client.transaction((()=>{r=e(t)}))[s.behavior??"deferred"](),r}}class n extends s.SQLiteTransaction{transaction(e){const s=`sp${this.nestedIndex}`,r=new n(this.dialect,this.session,this.nestedIndex+1);this.session.run(t.sql.raw(`savepoint ${s}`));try{const i=e(r);return this.session.run(t.sql.raw(`release savepoint ${s}`)),i}catch(e){throw this.session.run(t.sql.raw(`rollback to savepoint ${s}`)),e}}}class l extends s.PreparedQuery{constructor(e,s,t,r,i){super(),this.stmt=e,this.queryString=s,this.params=t,this.logger=r,this.fields=i}run(e){const s=t.fillPlaceholders(this.params,e??{});return this.logger.logQuery(this.queryString,s),this.stmt.run(...s)}all(e){const{fields:s,queryString:i,logger:n,joinsNotNullableMap:l,stmt:o}=this;if(s)return this.values(e).map((e=>r.mapResultRow(s,e,l)));const a=t.fillPlaceholders(this.params,e??{});return n.logQuery(i,a),o.all(...a)}get(e){const s=t.fillPlaceholders(this.params,e??{});this.logger.logQuery(this.queryString,s);const i=this.stmt.get(...s);if(!i)return;const{fields:n,joinsNotNullableMap:l}=this;return n?r.mapResultRow(n,i,l):i}values(e){const s=t.fillPlaceholders(this.params,e??{});return this.logger.logQuery(this.queryString,s),this.stmt.values(...s)}}exports.PreparedQuery=l,exports.SQLiteBunSession=i,exports.SQLiteBunTransaction=n,exports.drizzle=function(t,r={}){const n=new s.SQLiteSyncDialect;let l;!0===r.logger?l=new e.DefaultLogger:!1!==r.logger&&(l=r.logger);const o=new i(t,n,{logger:l});return new s.BaseSQLiteDatabase(n,o)};
1
+ "use strict";var e=require("../logger-04bad527.cjs"),s=require("../session-c9c5780f.cjs"),t=require("../index-59b7992d.cjs"),r=require("../utils-9d882195.cjs");require("../query-builder-2f2e8229.cjs");class i extends s.SQLiteSession{constructor(s,t,r={}){super(t),this.client=s,this.logger=r.logger??new e.NoopLogger}exec(e){this.client.exec(e)}prepareQuery(e,s){const t=this.client.prepare(e.sql);return new l(t,e.sql,e.params,this.logger,s)}transaction(e,s={}){const t=new n(this.dialect,this);let r;return this.client.transaction((()=>{r=e(t)}))[s.behavior??"deferred"](),r}}class n extends s.SQLiteTransaction{transaction(e){const s=`sp${this.nestedIndex}`,r=new n(this.dialect,this.session,this.nestedIndex+1);this.session.run(t.sql.raw(`savepoint ${s}`));try{const i=e(r);return this.session.run(t.sql.raw(`release savepoint ${s}`)),i}catch(e){throw this.session.run(t.sql.raw(`rollback to savepoint ${s}`)),e}}}class l extends s.PreparedQuery{constructor(e,s,t,r,i){super(),this.stmt=e,this.queryString=s,this.params=t,this.logger=r,this.fields=i}run(e){const s=t.fillPlaceholders(this.params,e??{});return this.logger.logQuery(this.queryString,s),this.stmt.run(...s)}all(e){const{fields:s,queryString:i,logger:n,joinsNotNullableMap:l,stmt:o}=this;if(s)return this.values(e).map((e=>r.mapResultRow(s,e,l)));const a=t.fillPlaceholders(this.params,e??{});return n.logQuery(i,a),o.all(...a)}get(e){const s=t.fillPlaceholders(this.params,e??{});this.logger.logQuery(this.queryString,s);const i=this.stmt.get(...s);if(!i)return;const{fields:n,joinsNotNullableMap:l}=this;return n?r.mapResultRow(n,i,l):i}values(e){const s=t.fillPlaceholders(this.params,e??{});return this.logger.logQuery(this.queryString,s),this.stmt.values(...s)}}exports.PreparedQuery=l,exports.SQLiteBunSession=i,exports.SQLiteBunTransaction=n,exports.drizzle=function(t,r={}){const n=new s.SQLiteSyncDialect;let l;!0===r.logger?l=new e.DefaultLogger:!1!==r.logger&&(l=r.logger);const o=new i(t,n,{logger:l});return new s.BaseSQLiteDatabase(n,o)};
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1,2 +1,2 @@
1
- import{N as s,D as t}from"../logger-2598bf05.mjs";import{S as e,a as r,P as i,B as n,b as o}from"../session-b977ce56.mjs";import{s as a,k as l}from"../index-b71998f1.mjs";import{m as h}from"../utils-e6870670.mjs";import"../query-builder-2fcde2f0.mjs";class u extends e{constructor(t,e,r={}){super(e),this.client=t,this.logger=r.logger??new s}exec(s){this.client.exec(s)}prepareQuery(s,t){const e=this.client.prepare(s.sql);return new c(e,s.sql,s.params,this.logger,t)}transaction(s,t={}){const e=new g(this.dialect,this);let r;return this.client.transaction((()=>{r=s(e)}))[t.behavior??"deferred"](),r}}class g extends r{transaction(s){const t=`sp${this.nestedIndex}`,e=new g(this.dialect,this.session,this.nestedIndex+1);this.session.run(a.raw(`savepoint ${t}`));try{const r=s(e);return this.session.run(a.raw(`release savepoint ${t}`)),r}catch(s){throw this.session.run(a.raw(`rollback to savepoint ${t}`)),s}}}class c extends i{constructor(s,t,e,r,i){super(),this.stmt=s,this.queryString=t,this.params=e,this.logger=r,this.fields=i}run(s){const t=l(this.params,s??{});return this.logger.logQuery(this.queryString,t),this.stmt.run(...t)}all(s){const{fields:t,queryString:e,logger:r,joinsNotNullableMap:i,stmt:n}=this;if(t)return this.values(s).map((s=>h(t,s,i)));const o=l(this.params,s??{});return r.logQuery(e,o),n.all(...o)}get(s){const t=l(this.params,s??{});this.logger.logQuery(this.queryString,t);const e=this.stmt.get(...t);if(!e)return;const{fields:r,joinsNotNullableMap:i}=this;return r?h(r,e,i):e}values(s){const t=l(this.params,s??{});return this.logger.logQuery(this.queryString,t),this.stmt.values(...t)}}function m(s,e={}){const r=new o;let i;!0===e.logger?i=new t:!1!==e.logger&&(i=e.logger);const a=new u(s,r,{logger:i});return new n(r,a)}export{c as PreparedQuery,u as SQLiteBunSession,g as SQLiteBunTransaction,m as drizzle};
1
+ import{N as s,D as t}from"../logger-2598bf05.mjs";import{S as e,a as r,P as i,B as n,b as o}from"../session-df989164.mjs";import{s as a,k as l}from"../index-b71998f1.mjs";import{m as h}from"../utils-e6870670.mjs";import"../query-builder-2fcde2f0.mjs";class u extends e{constructor(t,e,r={}){super(e),this.client=t,this.logger=r.logger??new s}exec(s){this.client.exec(s)}prepareQuery(s,t){const e=this.client.prepare(s.sql);return new c(e,s.sql,s.params,this.logger,t)}transaction(s,t={}){const e=new g(this.dialect,this);let r;return this.client.transaction((()=>{r=s(e)}))[t.behavior??"deferred"](),r}}class g extends r{transaction(s){const t=`sp${this.nestedIndex}`,e=new g(this.dialect,this.session,this.nestedIndex+1);this.session.run(a.raw(`savepoint ${t}`));try{const r=s(e);return this.session.run(a.raw(`release savepoint ${t}`)),r}catch(s){throw this.session.run(a.raw(`rollback to savepoint ${t}`)),s}}}class c extends i{constructor(s,t,e,r,i){super(),this.stmt=s,this.queryString=t,this.params=e,this.logger=r,this.fields=i}run(s){const t=l(this.params,s??{});return this.logger.logQuery(this.queryString,t),this.stmt.run(...t)}all(s){const{fields:t,queryString:e,logger:r,joinsNotNullableMap:i,stmt:n}=this;if(t)return this.values(s).map((s=>h(t,s,i)));const o=l(this.params,s??{});return r.logQuery(e,o),n.all(...o)}get(s){const t=l(this.params,s??{});this.logger.logQuery(this.queryString,t);const e=this.stmt.get(...t);if(!e)return;const{fields:r,joinsNotNullableMap:i}=this;return r?h(r,e,i):e}values(s){const t=l(this.params,s??{});return this.logger.logQuery(this.queryString,t),this.stmt.values(...t)}}function m(s,e={}){const r=new o;let i;!0===e.logger?i=new t:!1!==e.logger&&(i=e.logger);const a=new u(s,r,{logger:i});return new n(r,a)}export{c as PreparedQuery,u as SQLiteBunSession,g as SQLiteBunTransaction,m as drizzle};
2
2
  //# sourceMappingURL=index.mjs.map
package/d1/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var s=require("../logger-04bad527.cjs"),e=require("../session-b6939bab.cjs"),t=require("../index-59b7992d.cjs"),r=require("../utils-9d882195.cjs");require("../query-builder-2f2e8229.cjs");class i extends e.SQLiteSession{constructor(e,t,r={}){super(t),this.client=e,this.logger=r.logger??new s.NoopLogger}prepareQuery(s,e){const t=this.client.prepare(s.sql);return new a(t,s.sql,s.params,this.logger,e)}async transaction(s,e){const r=new n(this.dialect,this);await this.run(t.sql.raw("begin"+(e?.behavior?" "+e.behavior:"")));try{const e=await s(r);return await this.run(t.sql`commit`),e}catch(s){throw await this.run(t.sql`rollback`),s}}}class n extends e.SQLiteTransaction{async transaction(s){const e=`sp${this.nestedIndex}`,r=new n(this.dialect,this.session,this.nestedIndex+1);await this.session.run(t.sql.raw(`savepoint ${e}`));try{const i=await s(r);return await this.session.run(t.sql.raw(`release savepoint ${e}`)),i}catch(s){throw await this.session.run(t.sql.raw(`rollback to savepoint ${e}`)),s}}}class a extends e.PreparedQuery{constructor(s,e,t,r,i){super(),this.stmt=s,this.queryString=e,this.params=t,this.logger=r,this.fields=i}run(s){const e=t.fillPlaceholders(this.params,s??{});return this.logger.logQuery(this.queryString,e),this.stmt.bind(...e).run()}all(s){const{fields:e,joinsNotNullableMap:i,queryString:n,logger:a,stmt:l}=this;if(e)return this.values(s).then((s=>s.map((s=>r.mapResultRow(e,s,i)))));const o=t.fillPlaceholders(this.params,s??{});return a.logQuery(n,o),l.bind(...o).all().then((({results:s})=>s))}get(s){return this.all(s).then((s=>s[0]))}values(s){const e=t.fillPlaceholders(this.params,s??{});return this.logger.logQuery(this.queryString,e),this.stmt.bind(...e).raw()}}exports.D1Transaction=n,exports.PreparedQuery=a,exports.SQLiteD1Session=i,exports.drizzle=function(t,r={}){const n=new e.SQLiteAsyncDialect;let a;!0===r.logger?a=new s.DefaultLogger:!1!==r.logger&&(a=r.logger);const l=new i(t,n,{logger:a});return new e.BaseSQLiteDatabase(n,l)};
1
+ "use strict";var s=require("../logger-04bad527.cjs"),e=require("../session-c9c5780f.cjs"),t=require("../index-59b7992d.cjs"),r=require("../utils-9d882195.cjs");require("../query-builder-2f2e8229.cjs");class i extends e.SQLiteSession{constructor(e,t,r={}){super(t),this.client=e,this.logger=r.logger??new s.NoopLogger}prepareQuery(s,e){const t=this.client.prepare(s.sql);return new a(t,s.sql,s.params,this.logger,e)}async transaction(s,e){const r=new n(this.dialect,this);await this.run(t.sql.raw("begin"+(e?.behavior?" "+e.behavior:"")));try{const e=await s(r);return await this.run(t.sql`commit`),e}catch(s){throw await this.run(t.sql`rollback`),s}}}class n extends e.SQLiteTransaction{async transaction(s){const e=`sp${this.nestedIndex}`,r=new n(this.dialect,this.session,this.nestedIndex+1);await this.session.run(t.sql.raw(`savepoint ${e}`));try{const i=await s(r);return await this.session.run(t.sql.raw(`release savepoint ${e}`)),i}catch(s){throw await this.session.run(t.sql.raw(`rollback to savepoint ${e}`)),s}}}class a extends e.PreparedQuery{constructor(s,e,t,r,i){super(),this.stmt=s,this.queryString=e,this.params=t,this.logger=r,this.fields=i}run(s){const e=t.fillPlaceholders(this.params,s??{});return this.logger.logQuery(this.queryString,e),this.stmt.bind(...e).run()}all(s){const{fields:e,joinsNotNullableMap:i,queryString:n,logger:a,stmt:l}=this;if(e)return this.values(s).then((s=>s.map((s=>r.mapResultRow(e,s,i)))));const o=t.fillPlaceholders(this.params,s??{});return a.logQuery(n,o),l.bind(...o).all().then((({results:s})=>s))}get(s){return this.all(s).then((s=>s[0]))}values(s){const e=t.fillPlaceholders(this.params,s??{});return this.logger.logQuery(this.queryString,e),this.stmt.bind(...e).raw()}}exports.D1Transaction=n,exports.PreparedQuery=a,exports.SQLiteD1Session=i,exports.drizzle=function(t,r={}){const n=new e.SQLiteAsyncDialect;let a;!0===r.logger?a=new s.DefaultLogger:!1!==r.logger&&(a=r.logger);const l=new i(t,n,{logger:a});return new e.BaseSQLiteDatabase(n,l)};
2
2
  //# sourceMappingURL=index.cjs.map
package/d1/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import{N as s,D as t}from"../logger-2598bf05.mjs";import{S as r,a as e,P as i,B as n,c as a}from"../session-b977ce56.mjs";import{s as o,k as l}from"../index-b71998f1.mjs";import{m as h}from"../utils-e6870670.mjs";import"../query-builder-2fcde2f0.mjs";class u extends r{constructor(t,r,e={}){super(r),this.client=t,this.logger=e.logger??new s}prepareQuery(s,t){const r=this.client.prepare(s.sql);return new g(r,s.sql,s.params,this.logger,t)}async transaction(s,t){const r=new c(this.dialect,this);await this.run(o.raw("begin"+(t?.behavior?" "+t.behavior:"")));try{const t=await s(r);return await this.run(o`commit`),t}catch(s){throw await this.run(o`rollback`),s}}}class c extends e{async transaction(s){const t=`sp${this.nestedIndex}`,r=new c(this.dialect,this.session,this.nestedIndex+1);await this.session.run(o.raw(`savepoint ${t}`));try{const e=await s(r);return await this.session.run(o.raw(`release savepoint ${t}`)),e}catch(s){throw await this.session.run(o.raw(`rollback to savepoint ${t}`)),s}}}class g extends i{constructor(s,t,r,e,i){super(),this.stmt=s,this.queryString=t,this.params=r,this.logger=e,this.fields=i}run(s){const t=l(this.params,s??{});return this.logger.logQuery(this.queryString,t),this.stmt.bind(...t).run()}all(s){const{fields:t,joinsNotNullableMap:r,queryString:e,logger:i,stmt:n}=this;if(t)return this.values(s).then((s=>s.map((s=>h(t,s,r)))));const a=l(this.params,s??{});return i.logQuery(e,a),n.bind(...a).all().then((({results:s})=>s))}get(s){return this.all(s).then((s=>s[0]))}values(s){const t=l(this.params,s??{});return this.logger.logQuery(this.queryString,t),this.stmt.bind(...t).raw()}}function m(s,r={}){const e=new a;let i;!0===r.logger?i=new t:!1!==r.logger&&(i=r.logger);const o=new u(s,e,{logger:i});return new n(e,o)}export{c as D1Transaction,g as PreparedQuery,u as SQLiteD1Session,m as drizzle};
1
+ import{N as s,D as t}from"../logger-2598bf05.mjs";import{S as r,a as e,P as i,B as n,c as a}from"../session-df989164.mjs";import{s as o,k as l}from"../index-b71998f1.mjs";import{m as h}from"../utils-e6870670.mjs";import"../query-builder-2fcde2f0.mjs";class u extends r{constructor(t,r,e={}){super(r),this.client=t,this.logger=e.logger??new s}prepareQuery(s,t){const r=this.client.prepare(s.sql);return new g(r,s.sql,s.params,this.logger,t)}async transaction(s,t){const r=new c(this.dialect,this);await this.run(o.raw("begin"+(t?.behavior?" "+t.behavior:"")));try{const t=await s(r);return await this.run(o`commit`),t}catch(s){throw await this.run(o`rollback`),s}}}class c extends e{async transaction(s){const t=`sp${this.nestedIndex}`,r=new c(this.dialect,this.session,this.nestedIndex+1);await this.session.run(o.raw(`savepoint ${t}`));try{const e=await s(r);return await this.session.run(o.raw(`release savepoint ${t}`)),e}catch(s){throw await this.session.run(o.raw(`rollback to savepoint ${t}`)),s}}}class g extends i{constructor(s,t,r,e,i){super(),this.stmt=s,this.queryString=t,this.params=r,this.logger=e,this.fields=i}run(s){const t=l(this.params,s??{});return this.logger.logQuery(this.queryString,t),this.stmt.bind(...t).run()}all(s){const{fields:t,joinsNotNullableMap:r,queryString:e,logger:i,stmt:n}=this;if(t)return this.values(s).then((s=>s.map((s=>h(t,s,r)))));const a=l(this.params,s??{});return i.logQuery(e,a),n.bind(...a).all().then((({results:s})=>s))}get(s){return this.all(s).then((s=>s[0]))}values(s){const t=l(this.params,s??{});return this.logger.logQuery(this.queryString,t),this.stmt.bind(...t).raw()}}function m(s,r={}){const e=new a;let i;!0===r.logger?i=new t:!1!==r.logger&&(i=r.logger);const o=new u(s,e,{logger:i});return new n(e,o)}export{c as D1Transaction,g as PreparedQuery,u as SQLiteD1Session,m as drizzle};
2
2
  //# sourceMappingURL=index.mjs.map
package/libsql/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("../logger-04bad527.cjs"),t=require("../session-b6939bab.cjs"),s=require("../index-59b7992d.cjs"),r=require("../utils-9d882195.cjs");require("../query-builder-2f2e8229.cjs");class i extends t.SQLiteSession{constructor(t,s,r,i){super(s),this.client=t,this.options=r,this.tx=i,this.logger=r.logger??new e.NoopLogger}prepareQuery(e,t){return new a(this.client,e.sql,e.params,this.logger,t,this.tx)}batch(e){const t=e.map((e=>{const t=this.dialect.sqlToQuery(e);return{sql:t.sql,args:t.params}}));return this.client.batch(t)}async transaction(e,t){const s=await this.client.transaction(),r=new i(this.client,this.dialect,this.options,s),a=new n(this.dialect,r);try{const t=await e(a);return await s.commit(),t}catch(e){throw await s.rollback(),e}}}class n extends t.SQLiteTransaction{async transaction(e){const t=`sp${this.nestedIndex}`,r=new n(this.dialect,this.session,this.nestedIndex+1);await this.session.run(s.sql.raw(`savepoint ${t}`));try{const i=await e(r);return await this.session.run(s.sql.raw(`release savepoint ${t}`)),i}catch(e){throw await this.session.run(s.sql.raw(`rollback to savepoint ${t}`)),e}}}class a extends t.PreparedQuery{constructor(e,t,s,r,i,n){super(),this.client=e,this.queryString=t,this.params=s,this.logger=r,this.fields=i,this.tx=n}run(e){const t=s.fillPlaceholders(this.params,e??{});this.logger.logQuery(this.queryString,t);const r={sql:this.queryString,args:t};return this.tx?this.tx.execute(r):this.client.execute(r)}all(e){const{fields:t,joinsNotNullableMap:i,logger:n,queryString:a,tx:o,client:l}=this;if(t){return this.values(e).then((e=>e.map((e=>r.mapResultRow(t,Array.prototype.slice.call(e).map((e=>function(e){if(e instanceof ArrayBuffer){if("undefined"!=typeof Buffer)return e instanceof Buffer?e:Buffer.from(e);if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);throw new Error("TextDecoder is not available. Please provide either Buffer or TextDecoder polyfill.")}return e}(e))),i)))))}const c=s.fillPlaceholders(this.params,e??{});n.logQuery(a,c);const u={sql:a,args:c};return(o?o.execute(u):l.execute(u)).then((({rows:e})=>e.map((e=>{return t=e,Object.keys(t).reduce(((e,s)=>(Object.prototype.propertyIsEnumerable.call(t,s)&&(e[s]=t[s]),e)),{});var t}))))}get(e){return this.all(e).then((e=>e[0]))}values(e){const t=s.fillPlaceholders(this.params,e??{});this.logger.logQuery(this.queryString,t);const r={sql:this.queryString,args:t};return(this.tx?this.tx.execute(r):this.client.execute(r)).then((({rows:e})=>e))}}exports.LibSQLSession=i,exports.LibSQLTransaction=n,exports.PreparedQuery=a,exports.drizzle=function(s,r={}){const n=new t.SQLiteAsyncDialect;let a;!0===r.logger?a=new e.DefaultLogger:!1!==r.logger&&(a=r.logger);const o=new i(s,n,{logger:a},void 0);return new t.BaseSQLiteDatabase(n,o)};
1
+ "use strict";var e=require("../logger-04bad527.cjs"),t=require("../session-c9c5780f.cjs"),s=require("../index-59b7992d.cjs"),r=require("../utils-9d882195.cjs");require("../query-builder-2f2e8229.cjs");class i extends t.SQLiteSession{constructor(t,s,r,i){super(s),this.client=t,this.options=r,this.tx=i,this.logger=r.logger??new e.NoopLogger}prepareQuery(e,t){return new a(this.client,e.sql,e.params,this.logger,t,this.tx)}batch(e){const t=e.map((e=>{const t=this.dialect.sqlToQuery(e);return{sql:t.sql,args:t.params}}));return this.client.batch(t)}async transaction(e,t){const s=await this.client.transaction(),r=new i(this.client,this.dialect,this.options,s),a=new n(this.dialect,r);try{const t=await e(a);return await s.commit(),t}catch(e){throw await s.rollback(),e}}}class n extends t.SQLiteTransaction{async transaction(e){const t=`sp${this.nestedIndex}`,r=new n(this.dialect,this.session,this.nestedIndex+1);await this.session.run(s.sql.raw(`savepoint ${t}`));try{const i=await e(r);return await this.session.run(s.sql.raw(`release savepoint ${t}`)),i}catch(e){throw await this.session.run(s.sql.raw(`rollback to savepoint ${t}`)),e}}}class a extends t.PreparedQuery{constructor(e,t,s,r,i,n){super(),this.client=e,this.queryString=t,this.params=s,this.logger=r,this.fields=i,this.tx=n}run(e){const t=s.fillPlaceholders(this.params,e??{});this.logger.logQuery(this.queryString,t);const r={sql:this.queryString,args:t};return this.tx?this.tx.execute(r):this.client.execute(r)}all(e){const{fields:t,joinsNotNullableMap:i,logger:n,queryString:a,tx:o,client:l}=this;if(t){return this.values(e).then((e=>e.map((e=>r.mapResultRow(t,Array.prototype.slice.call(e).map((e=>function(e){if(e instanceof ArrayBuffer){if("undefined"!=typeof Buffer)return e instanceof Buffer?e:Buffer.from(e);if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);throw new Error("TextDecoder is not available. Please provide either Buffer or TextDecoder polyfill.")}return e}(e))),i)))))}const c=s.fillPlaceholders(this.params,e??{});n.logQuery(a,c);const u={sql:a,args:c};return(o?o.execute(u):l.execute(u)).then((({rows:e})=>e.map((e=>{return t=e,Object.keys(t).reduce(((e,s)=>(Object.prototype.propertyIsEnumerable.call(t,s)&&(e[s]=t[s]),e)),{});var t}))))}get(e){return this.all(e).then((e=>e[0]))}values(e){const t=s.fillPlaceholders(this.params,e??{});this.logger.logQuery(this.queryString,t);const r={sql:this.queryString,args:t};return(this.tx?this.tx.execute(r):this.client.execute(r)).then((({rows:e})=>e))}}exports.LibSQLSession=i,exports.LibSQLTransaction=n,exports.PreparedQuery=a,exports.drizzle=function(s,r={}){const n=new t.SQLiteAsyncDialect;let a;!0===r.logger?a=new e.DefaultLogger:!1!==r.logger&&(a=r.logger);const o=new i(s,n,{logger:a},void 0);return new t.BaseSQLiteDatabase(n,o)};
2
2
  //# sourceMappingURL=index.cjs.map
package/libsql/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import{N as t,D as e}from"../logger-2598bf05.mjs";import{S as s,a as r,P as i,B as n,c as a}from"../session-b977ce56.mjs";import{s as o,k as c}from"../index-b71998f1.mjs";import{m as l}from"../utils-e6870670.mjs";import"../query-builder-2fcde2f0.mjs";class h extends s{constructor(e,s,r,i){super(s),this.client=e,this.options=r,this.tx=i,this.logger=r.logger??new t}prepareQuery(t,e){return new g(this.client,t.sql,t.params,this.logger,e,this.tx)}batch(t){const e=t.map((t=>{const e=this.dialect.sqlToQuery(t);return{sql:e.sql,args:e.params}}));return this.client.batch(e)}async transaction(t,e){const s=await this.client.transaction(),r=new h(this.client,this.dialect,this.options,s),i=new u(this.dialect,r);try{const e=await t(i);return await s.commit(),e}catch(t){throw await s.rollback(),t}}}class u extends r{async transaction(t){const e=`sp${this.nestedIndex}`,s=new u(this.dialect,this.session,this.nestedIndex+1);await this.session.run(o.raw(`savepoint ${e}`));try{const r=await t(s);return await this.session.run(o.raw(`release savepoint ${e}`)),r}catch(t){throw await this.session.run(o.raw(`rollback to savepoint ${e}`)),t}}}class g extends i{constructor(t,e,s,r,i,n){super(),this.client=t,this.queryString=e,this.params=s,this.logger=r,this.fields=i,this.tx=n}run(t){const e=c(this.params,t??{});this.logger.logQuery(this.queryString,e);const s={sql:this.queryString,args:e};return this.tx?this.tx.execute(s):this.client.execute(s)}all(t){const{fields:e,joinsNotNullableMap:s,logger:r,queryString:i,tx:n,client:a}=this;if(e){return this.values(t).then((t=>t.map((t=>l(e,Array.prototype.slice.call(t).map((t=>function(t){if(t instanceof ArrayBuffer){if("undefined"!=typeof Buffer)return t instanceof Buffer?t:Buffer.from(t);if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(t);throw new Error("TextDecoder is not available. Please provide either Buffer or TextDecoder polyfill.")}return t}(t))),s)))))}const o=c(this.params,t??{});r.logQuery(i,o);const h={sql:i,args:o};return(n?n.execute(h):a.execute(h)).then((({rows:t})=>t.map((t=>{return e=t,Object.keys(e).reduce(((t,s)=>(Object.prototype.propertyIsEnumerable.call(e,s)&&(t[s]=e[s]),t)),{});var e}))))}get(t){return this.all(t).then((t=>t[0]))}values(t){const e=c(this.params,t??{});this.logger.logQuery(this.queryString,e);const s={sql:this.queryString,args:e};return(this.tx?this.tx.execute(s):this.client.execute(s)).then((({rows:t})=>t))}}function p(t,s={}){const r=new a;let i;!0===s.logger?i=new e:!1!==s.logger&&(i=s.logger);const o=new h(t,r,{logger:i},void 0);return new n(r,o)}export{h as LibSQLSession,u as LibSQLTransaction,g as PreparedQuery,p as drizzle};
1
+ import{N as t,D as e}from"../logger-2598bf05.mjs";import{S as s,a as r,P as i,B as n,c as a}from"../session-df989164.mjs";import{s as o,k as c}from"../index-b71998f1.mjs";import{m as l}from"../utils-e6870670.mjs";import"../query-builder-2fcde2f0.mjs";class h extends s{constructor(e,s,r,i){super(s),this.client=e,this.options=r,this.tx=i,this.logger=r.logger??new t}prepareQuery(t,e){return new g(this.client,t.sql,t.params,this.logger,e,this.tx)}batch(t){const e=t.map((t=>{const e=this.dialect.sqlToQuery(t);return{sql:e.sql,args:e.params}}));return this.client.batch(e)}async transaction(t,e){const s=await this.client.transaction(),r=new h(this.client,this.dialect,this.options,s),i=new u(this.dialect,r);try{const e=await t(i);return await s.commit(),e}catch(t){throw await s.rollback(),t}}}class u extends r{async transaction(t){const e=`sp${this.nestedIndex}`,s=new u(this.dialect,this.session,this.nestedIndex+1);await this.session.run(o.raw(`savepoint ${e}`));try{const r=await t(s);return await this.session.run(o.raw(`release savepoint ${e}`)),r}catch(t){throw await this.session.run(o.raw(`rollback to savepoint ${e}`)),t}}}class g extends i{constructor(t,e,s,r,i,n){super(),this.client=t,this.queryString=e,this.params=s,this.logger=r,this.fields=i,this.tx=n}run(t){const e=c(this.params,t??{});this.logger.logQuery(this.queryString,e);const s={sql:this.queryString,args:e};return this.tx?this.tx.execute(s):this.client.execute(s)}all(t){const{fields:e,joinsNotNullableMap:s,logger:r,queryString:i,tx:n,client:a}=this;if(e){return this.values(t).then((t=>t.map((t=>l(e,Array.prototype.slice.call(t).map((t=>function(t){if(t instanceof ArrayBuffer){if("undefined"!=typeof Buffer)return t instanceof Buffer?t:Buffer.from(t);if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(t);throw new Error("TextDecoder is not available. Please provide either Buffer or TextDecoder polyfill.")}return t}(t))),s)))))}const o=c(this.params,t??{});r.logQuery(i,o);const h={sql:i,args:o};return(n?n.execute(h):a.execute(h)).then((({rows:t})=>t.map((t=>{return e=t,Object.keys(e).reduce(((t,s)=>(Object.prototype.propertyIsEnumerable.call(e,s)&&(t[s]=e[s]),t)),{});var e}))))}get(t){return this.all(t).then((t=>t[0]))}values(t){const e=c(this.params,t??{});this.logger.logQuery(this.queryString,e);const s={sql:this.queryString,args:e};return(this.tx?this.tx.execute(s):this.client.execute(s)).then((({rows:t})=>t))}}function p(t,s={}){const r=new a;let i;!0===s.logger?i=new e:!1!==s.logger&&(i=s.logger);const o=new h(t,r,{logger:i},void 0);return new n(r,o)}export{h as LibSQLSession,u as LibSQLTransaction,g as PreparedQuery,p as drizzle};
2
2
  //# sourceMappingURL=index.mjs.map
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("../index-59b7992d.cjs"),t=require("../session-e6db6732.cjs");require("../utils-9d882195.cjs"),require("../query-promise-2c5b43ab.cjs"),require("../column-builder-b48639f3.cjs"),require("../query-builder-2f2e8229.cjs");class r{constructor(e,t){this.name=e,this.value=t}build(e){return new n(e,this)}}class n{constructor(e,t){this.table=e,this.name=t.name,this.value=t.value}}class s extends t.MySqlColumnBuilderWithAutoIncrement{build(e){return new i(e,this.config)}}class i extends t.MySqlColumnWithAutoIncrement{getSQLType(){return"bigint"}mapFromDriverValue(e){return"number"==typeof e?e:Number(e)}}class o extends t.MySqlColumnBuilderWithAutoIncrement{build(e){return new l(e,this.config)}}class l extends t.MySqlColumnWithAutoIncrement{getSQLType(){return"bigint"}mapFromDriverValue(e){return BigInt(e)}}class u extends t.MySqlColumnBuilder{constructor(e,t){super(e),this.config.length=t}build(e){return new c(e,this.config)}}class c extends t.MySqlColumn{constructor(){super(...arguments),this.length=this.config.length}getSQLType(){return void 0===this.length?"binary":`binary(${this.length})`}}class a extends t.MySqlColumnBuilder{build(e){return new p(e,this.config)}}class p extends t.MySqlColumn{getSQLType(){return"boolean"}mapFromDriverValue(e){return"boolean"==typeof e?e:1===e}}class m extends t.MySqlColumnBuilder{constructor(e,t){super(e),this.config.length=t.length,this.config.enum=t.enum}build(e){return new y(e,this.config)}}class y extends t.MySqlColumn{constructor(){super(...arguments),this.length=this.config.length,this.enumValues=this.config.enum??[]}getSQLType(){return void 0===this.length?"char":`char(${this.length})`}}class h extends t.MySqlColumnBuilder{constructor(e,t,r){super(e),this.config.fieldConfig=t,this.config.customTypeParams=r}build(e){return new d(e,this.config)}}class d extends t.MySqlColumn{constructor(e,t){super(e,t),this.sqlName=t.customTypeParams.dataType(t.fieldConfig),this.mapTo=t.customTypeParams.toDriver,this.mapFrom=t.customTypeParams.fromDriver}getSQLType(){return this.sqlName}mapFromDriverValue(e){return"function"==typeof this.mapFrom?this.mapFrom(e):e}mapToDriverValue(e){return"function"==typeof this.mapTo?this.mapTo(e):e}}class S extends t.MySqlColumnBuilder{build(e){return new x(e,this.config)}}class x extends t.MySqlColumn{constructor(e,t){super(e,t)}getSQLType(){return"date"}mapFromDriverValue(e){return new Date(e)}}class f extends t.MySqlColumnBuilder{build(e){return new q(e,this.config)}}class q extends t.MySqlColumn{constructor(e,t){super(e,t)}getSQLType(){return"date"}}class g extends t.MySqlColumnBuilder{constructor(e,t){super(e),this.config.fsp=t?.fsp}build(e){return new M(e,this.config)}}class M extends t.MySqlColumn{constructor(e,t){super(e,t),this.fsp=t.fsp}getSQLType(){return`datetime${void 0===this.fsp?"":`(${this.fsp})`}`}mapFromDriverValue(e){return new Date(e)}}class b extends t.MySqlColumnBuilder{constructor(e,t){super(e),this.config.fsp=t?.fsp}build(e){return new w(e,this.config)}}class w extends t.MySqlColumn{constructor(e,t){super(e,t),this.fsp=t.fsp}getSQLType(){return`datetime${void 0===this.fsp?"":`(${this.fsp})`}`}}class B extends t.MySqlColumnBuilderWithAutoIncrement{constructor(e,t,r){super(e),this.config.precision=t,this.config.scale=r}build(e){return new C(e,this.config)}}class C extends t.MySqlColumnWithAutoIncrement{constructor(){super(...arguments),this.precision=this.config.precision,this.scale=this.config.scale}getSQLType(){return void 0!==this.precision&&void 0!==this.scale?`decimal(${this.precision},${this.scale})`:void 0===this.precision?"decimal":`decimal(${this.precision})`}}class T extends t.MySqlColumnBuilderWithAutoIncrement{constructor(e,t){super(e),this.config.precision=t?.precision,this.config.scale=t?.scale}build(e){return new v(e,this.config)}}class v extends t.MySqlColumnWithAutoIncrement{constructor(){super(...arguments),this.precision=this.config.precision,this.scale=this.config.scale}getSQLType(){return void 0!==this.precision&&void 0!==this.scale?`double(${this.precision},${this.scale})`:void 0===this.precision?"double":`double(${this.precision})`}}class I extends t.MySqlColumnBuilder{constructor(e,t){super(e),this.config.enumValues=t}build(e){return new V(e,this.config)}}class V extends t.MySqlColumn{constructor(){super(...arguments),this.enumValues=this.config.enumValues}getSQLType(){return`enum(${this.enumValues.map((e=>`'${e}'`)).join(",")})`}}class D extends t.MySqlColumnBuilderWithAutoIncrement{build(e){return new Q(e,this.config)}}class Q extends t.MySqlColumnWithAutoIncrement{getSQLType(){return"float"}}class W extends t.MySqlColumnBuilderWithAutoIncrement{build(e){return new L(e,this.config)}}class L extends t.MySqlColumnWithAutoIncrement{getSQLType(){return"int"}mapFromDriverValue(e){return"string"==typeof e?Number(e):e}}class $ extends t.MySqlColumnBuilder{build(e){return new A(e,this.config)}}class A extends t.MySqlColumn{getSQLType(){return"json"}mapToDriverValue(e){return JSON.stringify(e)}}class F extends t.MySqlColumnBuilderWithAutoIncrement{build(e){return new N(e,this.config)}}class N extends t.MySqlColumnWithAutoIncrement{getSQLType(){return"mediumint"}mapFromDriverValue(e){return"string"==typeof e?Number(e):e}}class K extends t.MySqlColumnBuilderWithAutoIncrement{constructor(e,t){super(e),this.config.precision=t?.precision,this.config.scale=t?.scale}build(e){return new j(e,this.config)}}class j extends t.MySqlColumnWithAutoIncrement{constructor(){super(...arguments),this.precision=this.config.precision,this.scale=this.config.scale}getSQLType(){return void 0!==this.precision&&void 0!==this.scale?`real(${this.precision}, ${this.scale})`:void 0===this.precision?"real":`real(${this.precision})`}}class P extends t.MySqlColumnBuilderWithAutoIncrement{constructor(e){super(e),this.config.hasDefault=!0,this.config.autoIncrement=!0}build(e){return new O(e,this.config)}}class O extends t.MySqlColumnWithAutoIncrement{getSQLType(){return"serial"}mapFromDriverValue(e){return"string"==typeof e?Number(e):e}}class U extends t.MySqlColumnBuilderWithAutoIncrement{build(e){return new k(e,this.config)}}class k extends t.MySqlColumnWithAutoIncrement{getSQLType(){return"smallint"}mapFromDriverValue(e){return"string"==typeof e?Number(e):e}}class E extends t.MySqlColumnBuilder{constructor(e,t,r){super(e),this.config.textType=t,this.config.enumValues=r.enum}build(e){return new J(e,this.config)}}class J extends t.MySqlColumn{constructor(){super(...arguments),this.textType=this.config.textType,this.enumValues=this.config.enumValues??[]}getSQLType(){return this.textType}}class Y extends t.MySqlColumnBuilder{constructor(e,t){super(e),this.config.fsp=t?.fsp}build(e){return new _(e,this.config)}}class _ extends t.MySqlColumn{constructor(){super(...arguments),this.fsp=this.config.fsp}getSQLType(){return`time${void 0===this.fsp?"":`(${this.fsp})`}`}}class R extends t.MySqlColumnBuilder{defaultNow(){return this.default(e.sql`(now())`)}onUpdateNow(){return this.config.hasOnUpdateNow=!0,this.config.hasDefault=!0,this}}class H extends t.MySqlColumn{constructor(){super(...arguments),this.hasOnUpdateNow=this.config.hasOnUpdateNow}}class z extends R{constructor(e,t){super(e),this.config.fsp=t?.fsp}build(e){return new G(e,this.config)}}class G extends H{constructor(){super(...arguments),this.fsp=this.config.fsp}getSQLType(){return`timestamp${void 0===this.fsp?"":`(${this.fsp})`}`}mapFromDriverValue(e){return new Date(e+"+0000")}mapToDriverValue(e){return e.toISOString().slice(0,19).replace("T"," ")}}class X extends R{constructor(e,t){super(e),this.config.fsp=t?.fsp}build(e){return new Z(e,this.config)}}class Z extends H{constructor(){super(...arguments),this.fsp=this.config.fsp}getSQLType(){return`timestamp${void 0===this.fsp?"":`(${this.fsp})`}`}}class ee extends t.MySqlColumnBuilderWithAutoIncrement{build(e){return new te(e,this.config)}}class te extends t.MySqlColumnWithAutoIncrement{getSQLType(){return"tinyint"}mapFromDriverValue(e){return"string"==typeof e?Number(e):e}}class re extends t.MySqlColumnBuilder{constructor(e,t){super(e),this.config.length=t?.length}build(e){return new ne(e,this.config)}}class ne extends t.MySqlColumn{constructor(){super(...arguments),this.length=this.config.length}getSQLType(){return void 0===this.length?"varbinary":`varbinary(${this.length})`}}class se extends t.MySqlColumnBuilder{constructor(e,t){super(e),this.config.length=t.length,this.config.enum=t.enum}build(e){return new ie(e,this.config)}}class ie extends t.MySqlColumn{constructor(){super(...arguments),this.length=this.config.length,this.enumValues=this.config.enum??[]}getSQLType(){return void 0===this.length?"varchar":`varchar(${this.length})`}}class oe extends t.MySqlColumnBuilder{build(e){return new le(e,this.config)}}class le extends t.MySqlColumn{getSQLType(){return"year"}}class ue{constructor(e,t){this.name=e,this.unique=t}on(...e){return new ce(this.name,e,this.unique)}}class ce{constructor(e,t,r){this.config={name:e,columns:t,unique:r}}using(e){return this.config.using=e,this}algorythm(e){return this.config.algorythm=e,this}lock(e){return this.config.lock=e,this}build(e){return new ae(this.config,e)}}class ae{constructor(e,t){this.config={...e,table:t}}}class pe{constructor(e){this.columns=e}build(e){return new me(e,this.columns)}}class me{constructor(e,t){this.table=e,this.columns=t}getName(){return`${this.table[t.MySqlTable.Symbol.Name]}_${this.columns.map((e=>e.name)).join("_")}_pk`}}class ye{constructor(e){this.schemaName=e,this.table=(e,r,n)=>t.mysqlTableWithSchema(e,r,n,this.schemaName),this.view=(e,r)=>t.mysqlViewWithSchema(e,r,this.schemaName)}}function he(e){return new ye(e)}const de=he;exports.ExtraConfigBuilder=t.ExtraConfigBuilder,exports.ForeignKey=t.ForeignKey,exports.ForeignKeyBuilder=t.ForeignKeyBuilder,exports.InlineForeignKeys=t.InlineForeignKeys,exports.ManualViewBuilder=t.ManualViewBuilder,exports.MySqlColumn=t.MySqlColumn,exports.MySqlColumnBuilder=t.MySqlColumnBuilder,exports.MySqlColumnBuilderWithAutoIncrement=t.MySqlColumnBuilderWithAutoIncrement,exports.MySqlColumnWithAutoIncrement=t.MySqlColumnWithAutoIncrement,exports.MySqlDatabase=t.MySqlDatabase,exports.MySqlDelete=t.MySqlDelete,exports.MySqlDialect=t.MySqlDialect,exports.MySqlInsert=t.MySqlInsert,exports.MySqlInsertBuilder=t.MySqlInsertBuilder,exports.MySqlSelect=t.MySqlSelect,exports.MySqlSelectBuilder=t.MySqlSelectBuilder,exports.MySqlSelectQueryBuilder=t.MySqlSelectQueryBuilder,exports.MySqlSession=t.MySqlSession,exports.MySqlTable=t.MySqlTable,exports.MySqlTransaction=t.MySqlTransaction,exports.MySqlUpdate=t.MySqlUpdate,exports.MySqlUpdateBuilder=t.MySqlUpdateBuilder,exports.MySqlView=t.MySqlView,exports.MySqlViewBase=t.MySqlViewBase,exports.MySqlViewConfig=t.MySqlViewConfig,exports.PreparedQuery=t.PreparedQuery,exports.QueryBuilder=t.QueryBuilder,exports.ViewBuilder=t.ViewBuilder,exports.ViewBuilderCore=t.ViewBuilderCore,exports.foreignKey=t.foreignKey,exports.mysqlTable=t.mysqlTable,exports.mysqlTableCreator=t.mysqlTableCreator,exports.mysqlTableWithSchema=t.mysqlTableWithSchema,exports.mysqlView=t.mysqlView,exports.mysqlViewWithSchema=t.mysqlViewWithSchema,exports.Check=n,exports.CheckBuilder=r,exports.Index=ae,exports.IndexBuilder=ce,exports.IndexBuilderOn=ue,exports.MySqlBigInt53=i,exports.MySqlBigInt53Builder=s,exports.MySqlBigInt64=l,exports.MySqlBigInt64Builder=o,exports.MySqlBinary=c,exports.MySqlBinaryBuilder=u,exports.MySqlBoolean=p,exports.MySqlBooleanBuilder=a,exports.MySqlChar=y,exports.MySqlCharBuilder=m,exports.MySqlCustomColumn=d,exports.MySqlCustomColumnBuilder=h,exports.MySqlDate=x,exports.MySqlDateBuilder=S,exports.MySqlDateString=q,exports.MySqlDateStringBuilder=f,exports.MySqlDateTime=M,exports.MySqlDateTimeBuilder=g,exports.MySqlDateTimeString=w,exports.MySqlDateTimeStringBuilder=b,exports.MySqlDecimal=C,exports.MySqlDecimalBuilder=B,exports.MySqlDouble=v,exports.MySqlDoubleBuilder=T,exports.MySqlEnumColumn=V,exports.MySqlEnumColumnBuilder=I,exports.MySqlFloat=Q,exports.MySqlFloatBuilder=D,exports.MySqlInt=L,exports.MySqlIntBuilder=W,exports.MySqlJson=A,exports.MySqlJsonBuilder=$,exports.MySqlMediumInt=N,exports.MySqlMediumIntBuilder=F,exports.MySqlReal=j,exports.MySqlRealBuilder=K,exports.MySqlSchema=ye,exports.MySqlSerial=O,exports.MySqlSerialBuilder=P,exports.MySqlSmallInt=k,exports.MySqlSmallIntBuilder=U,exports.MySqlText=J,exports.MySqlTextBuilder=E,exports.MySqlTime=_,exports.MySqlTimeBuilder=Y,exports.MySqlTimestamp=G,exports.MySqlTimestampBuilder=z,exports.MySqlTimestampString=Z,exports.MySqlTimestampStringBuilder=X,exports.MySqlTinyInt=te,exports.MySqlTinyIntBuilder=ee,exports.MySqlVarBinary=ne,exports.MySqlVarBinaryBuilder=re,exports.MySqlVarChar=ie,exports.MySqlVarCharBuilder=se,exports.MySqlYear=le,exports.MySqlYearBuilder=oe,exports.PrimaryKey=me,exports.PrimaryKeyBuilder=pe,exports.alias=function(t,r){return new Proxy(t,new e.TableAliasProxyHandler(r,!1))},exports.bigint=function(e,t){return"number"===t.mode?new s(e):new o(e)},exports.binary=function(e,t={}){return new u(e,t.length)},exports.boolean=function(e){return new a(e)},exports.char=function(e,t={}){return new m(e,t)},exports.check=function(e,t){return new r(e,t)},exports.customType=function(e){return(t,r)=>new h(t,r,e)},exports.date=function(e,t={}){return"string"===t.mode?new f(e):new S(e)},exports.datetime=function(e,t={}){return"string"===t.mode?new b(e,t):new g(e,t)},exports.decimal=function(e,t={}){return new B(e,t.precision,t.scale)},exports.double=function(e,t){return new T(e,t)},exports.float=function(e){return new D(e)},exports.getTableConfig=function(n){const s=Object.values(n[t.MySqlTable.Symbol.Columns]),i=[],o=[],l=[],u=Object.values(n[t.MySqlTable.Symbol.InlineForeignKeys]),c=n[e.Table.Symbol.Name],a=n[e.Table.Symbol.Schema],p=n[e.Table.Symbol.BaseName],m=n[t.MySqlTable.Symbol.ExtraConfigBuilder];if(void 0!==m){const e=m(n[t.MySqlTable.Symbol.Columns]);for(const s of Object.values(e))s instanceof ce?i.push(s.build(n)):s instanceof r?o.push(s.build(n)):s instanceof pe?l.push(s.build(n)):s instanceof t.ForeignKeyBuilder&&u.push(s.build(n))}return{columns:s,indexes:i,foreignKeys:u,checks:o,primaryKeys:l,name:c,schema:a,baseName:p}},exports.getViewConfig=function(r){return{...r[e.ViewBaseConfig],...r[t.MySqlViewConfig]}},exports.index=function(e){return new ue(e,!1)},exports.int=function(e){return new W(e)},exports.isMySqlSchema=function(e){return e instanceof ye},exports.json=function(e){return new $(e)},exports.longtext=function(e,t={}){return new E(e,"longtext",t)},exports.mediumint=function(e){return new F(e)},exports.mediumtext=function(e,t={}){return new E(e,"mediumtext",t)},exports.mysqlDatabase=he,exports.mysqlEnum=function(e,t){if(0===t.length)throw new Error(`You have an empty array for "${e}" enum values`);return new I(e,t)},exports.mysqlSchema=de,exports.primaryKey=function(...e){return new pe(e)},exports.real=function(e,t={}){return new K(e,t)},exports.serial=function(e){return new P(e)},exports.smallint=function(e){return new U(e)},exports.text=function(e,t={}){return new E(e,"text",t)},exports.time=function(e,t){return new Y(e,t)},exports.timestamp=function(e,t={}){return"string"===t.mode?new X(e,t):new z(e,t)},exports.tinyint=function(e){return new ee(e)},exports.tinytext=function(e,t={}){return new E(e,"tinytext",t)},exports.uniqueIndex=function(e){return new ue(e,!0)},exports.varbinary=function(e,t){return new re(e,t)},exports.varchar=function(e,t){return new se(e,t)},exports.year=function(e){return new oe(e)};
1
+ "use strict";var e=require("../index-59b7992d.cjs"),t=require("../session-e630c258.cjs");require("../utils-9d882195.cjs"),require("../query-promise-2c5b43ab.cjs"),require("../column-builder-b48639f3.cjs"),require("../query-builder-2f2e8229.cjs");class r{constructor(e,t){this.name=e,this.value=t}build(e){return new n(e,this)}}class n{constructor(e,t){this.table=e,this.name=t.name,this.value=t.value}}class s extends t.MySqlColumnBuilderWithAutoIncrement{build(e){return new i(e,this.config)}}class i extends t.MySqlColumnWithAutoIncrement{getSQLType(){return"bigint"}mapFromDriverValue(e){return"number"==typeof e?e:Number(e)}}class o extends t.MySqlColumnBuilderWithAutoIncrement{build(e){return new l(e,this.config)}}class l extends t.MySqlColumnWithAutoIncrement{getSQLType(){return"bigint"}mapFromDriverValue(e){return BigInt(e)}}class u extends t.MySqlColumnBuilder{constructor(e,t){super(e),this.config.length=t}build(e){return new c(e,this.config)}}class c extends t.MySqlColumn{constructor(){super(...arguments),this.length=this.config.length}getSQLType(){return void 0===this.length?"binary":`binary(${this.length})`}}class a extends t.MySqlColumnBuilder{build(e){return new p(e,this.config)}}class p extends t.MySqlColumn{getSQLType(){return"boolean"}mapFromDriverValue(e){return"boolean"==typeof e?e:1===e}}class m extends t.MySqlColumnBuilder{constructor(e,t){super(e),this.config.length=t.length,this.config.enum=t.enum}build(e){return new y(e,this.config)}}class y extends t.MySqlColumn{constructor(){super(...arguments),this.length=this.config.length,this.enumValues=this.config.enum??[]}getSQLType(){return void 0===this.length?"char":`char(${this.length})`}}class h extends t.MySqlColumnBuilder{constructor(e,t,r){super(e),this.config.fieldConfig=t,this.config.customTypeParams=r}build(e){return new d(e,this.config)}}class d extends t.MySqlColumn{constructor(e,t){super(e,t),this.sqlName=t.customTypeParams.dataType(t.fieldConfig),this.mapTo=t.customTypeParams.toDriver,this.mapFrom=t.customTypeParams.fromDriver}getSQLType(){return this.sqlName}mapFromDriverValue(e){return"function"==typeof this.mapFrom?this.mapFrom(e):e}mapToDriverValue(e){return"function"==typeof this.mapTo?this.mapTo(e):e}}class S extends t.MySqlColumnBuilder{build(e){return new x(e,this.config)}}class x extends t.MySqlColumn{constructor(e,t){super(e,t)}getSQLType(){return"date"}mapFromDriverValue(e){return new Date(e)}}class f extends t.MySqlColumnBuilder{build(e){return new q(e,this.config)}}class q extends t.MySqlColumn{constructor(e,t){super(e,t)}getSQLType(){return"date"}}class g extends t.MySqlColumnBuilder{constructor(e,t){super(e),this.config.fsp=t?.fsp}build(e){return new M(e,this.config)}}class M extends t.MySqlColumn{constructor(e,t){super(e,t),this.fsp=t.fsp}getSQLType(){return`datetime${void 0===this.fsp?"":`(${this.fsp})`}`}mapFromDriverValue(e){return new Date(e)}}class b extends t.MySqlColumnBuilder{constructor(e,t){super(e),this.config.fsp=t?.fsp}build(e){return new w(e,this.config)}}class w extends t.MySqlColumn{constructor(e,t){super(e,t),this.fsp=t.fsp}getSQLType(){return`datetime${void 0===this.fsp?"":`(${this.fsp})`}`}}class B extends t.MySqlColumnBuilderWithAutoIncrement{constructor(e,t,r){super(e),this.config.precision=t,this.config.scale=r}build(e){return new C(e,this.config)}}class C extends t.MySqlColumnWithAutoIncrement{constructor(){super(...arguments),this.precision=this.config.precision,this.scale=this.config.scale}getSQLType(){return void 0!==this.precision&&void 0!==this.scale?`decimal(${this.precision},${this.scale})`:void 0===this.precision?"decimal":`decimal(${this.precision})`}}class T extends t.MySqlColumnBuilderWithAutoIncrement{constructor(e,t){super(e),this.config.precision=t?.precision,this.config.scale=t?.scale}build(e){return new v(e,this.config)}}class v extends t.MySqlColumnWithAutoIncrement{constructor(){super(...arguments),this.precision=this.config.precision,this.scale=this.config.scale}getSQLType(){return void 0!==this.precision&&void 0!==this.scale?`double(${this.precision},${this.scale})`:void 0===this.precision?"double":`double(${this.precision})`}}class I extends t.MySqlColumnBuilder{constructor(e,t){super(e),this.config.enumValues=t}build(e){return new V(e,this.config)}}class V extends t.MySqlColumn{constructor(){super(...arguments),this.enumValues=this.config.enumValues}getSQLType(){return`enum(${this.enumValues.map((e=>`'${e}'`)).join(",")})`}}class D extends t.MySqlColumnBuilderWithAutoIncrement{build(e){return new Q(e,this.config)}}class Q extends t.MySqlColumnWithAutoIncrement{getSQLType(){return"float"}}class W extends t.MySqlColumnBuilderWithAutoIncrement{build(e){return new L(e,this.config)}}class L extends t.MySqlColumnWithAutoIncrement{getSQLType(){return"int"}mapFromDriverValue(e){return"string"==typeof e?Number(e):e}}class $ extends t.MySqlColumnBuilder{build(e){return new A(e,this.config)}}class A extends t.MySqlColumn{getSQLType(){return"json"}mapToDriverValue(e){return JSON.stringify(e)}}class F extends t.MySqlColumnBuilderWithAutoIncrement{build(e){return new N(e,this.config)}}class N extends t.MySqlColumnWithAutoIncrement{getSQLType(){return"mediumint"}mapFromDriverValue(e){return"string"==typeof e?Number(e):e}}class K extends t.MySqlColumnBuilderWithAutoIncrement{constructor(e,t){super(e),this.config.precision=t?.precision,this.config.scale=t?.scale}build(e){return new j(e,this.config)}}class j extends t.MySqlColumnWithAutoIncrement{constructor(){super(...arguments),this.precision=this.config.precision,this.scale=this.config.scale}getSQLType(){return void 0!==this.precision&&void 0!==this.scale?`real(${this.precision}, ${this.scale})`:void 0===this.precision?"real":`real(${this.precision})`}}class P extends t.MySqlColumnBuilderWithAutoIncrement{constructor(e){super(e),this.config.hasDefault=!0,this.config.autoIncrement=!0}build(e){return new O(e,this.config)}}class O extends t.MySqlColumnWithAutoIncrement{getSQLType(){return"serial"}mapFromDriverValue(e){return"string"==typeof e?Number(e):e}}class U extends t.MySqlColumnBuilderWithAutoIncrement{build(e){return new k(e,this.config)}}class k extends t.MySqlColumnWithAutoIncrement{getSQLType(){return"smallint"}mapFromDriverValue(e){return"string"==typeof e?Number(e):e}}class E extends t.MySqlColumnBuilder{constructor(e,t,r){super(e),this.config.textType=t,this.config.enumValues=r.enum}build(e){return new J(e,this.config)}}class J extends t.MySqlColumn{constructor(){super(...arguments),this.textType=this.config.textType,this.enumValues=this.config.enumValues??[]}getSQLType(){return this.textType}}class Y extends t.MySqlColumnBuilder{constructor(e,t){super(e),this.config.fsp=t?.fsp}build(e){return new _(e,this.config)}}class _ extends t.MySqlColumn{constructor(){super(...arguments),this.fsp=this.config.fsp}getSQLType(){return`time${void 0===this.fsp?"":`(${this.fsp})`}`}}class R extends t.MySqlColumnBuilder{defaultNow(){return this.default(e.sql`(now())`)}onUpdateNow(){return this.config.hasOnUpdateNow=!0,this.config.hasDefault=!0,this}}class H extends t.MySqlColumn{constructor(){super(...arguments),this.hasOnUpdateNow=this.config.hasOnUpdateNow}}class z extends R{constructor(e,t){super(e),this.config.fsp=t?.fsp}build(e){return new G(e,this.config)}}class G extends H{constructor(){super(...arguments),this.fsp=this.config.fsp}getSQLType(){return`timestamp${void 0===this.fsp?"":`(${this.fsp})`}`}mapFromDriverValue(e){return new Date(e+"+0000")}mapToDriverValue(e){return e.toISOString().slice(0,19).replace("T"," ")}}class X extends R{constructor(e,t){super(e),this.config.fsp=t?.fsp}build(e){return new Z(e,this.config)}}class Z extends H{constructor(){super(...arguments),this.fsp=this.config.fsp}getSQLType(){return`timestamp${void 0===this.fsp?"":`(${this.fsp})`}`}}class ee extends t.MySqlColumnBuilderWithAutoIncrement{build(e){return new te(e,this.config)}}class te extends t.MySqlColumnWithAutoIncrement{getSQLType(){return"tinyint"}mapFromDriverValue(e){return"string"==typeof e?Number(e):e}}class re extends t.MySqlColumnBuilder{constructor(e,t){super(e),this.config.length=t?.length}build(e){return new ne(e,this.config)}}class ne extends t.MySqlColumn{constructor(){super(...arguments),this.length=this.config.length}getSQLType(){return void 0===this.length?"varbinary":`varbinary(${this.length})`}}class se extends t.MySqlColumnBuilder{constructor(e,t){super(e),this.config.length=t.length,this.config.enum=t.enum}build(e){return new ie(e,this.config)}}class ie extends t.MySqlColumn{constructor(){super(...arguments),this.length=this.config.length,this.enumValues=this.config.enum??[]}getSQLType(){return void 0===this.length?"varchar":`varchar(${this.length})`}}class oe extends t.MySqlColumnBuilder{build(e){return new le(e,this.config)}}class le extends t.MySqlColumn{getSQLType(){return"year"}}class ue{constructor(e,t){this.name=e,this.unique=t}on(...e){return new ce(this.name,e,this.unique)}}class ce{constructor(e,t,r){this.config={name:e,columns:t,unique:r}}using(e){return this.config.using=e,this}algorythm(e){return this.config.algorythm=e,this}lock(e){return this.config.lock=e,this}build(e){return new ae(this.config,e)}}class ae{constructor(e,t){this.config={...e,table:t}}}class pe{constructor(e){this.columns=e}build(e){return new me(e,this.columns)}}class me{constructor(e,t){this.table=e,this.columns=t}getName(){return`${this.table[t.MySqlTable.Symbol.Name]}_${this.columns.map((e=>e.name)).join("_")}_pk`}}class ye{constructor(e){this.schemaName=e,this.table=(e,r,n)=>t.mysqlTableWithSchema(e,r,n,this.schemaName),this.view=(e,r)=>t.mysqlViewWithSchema(e,r,this.schemaName)}}function he(e){return new ye(e)}const de=he;exports.ExtraConfigBuilder=t.ExtraConfigBuilder,exports.ForeignKey=t.ForeignKey,exports.ForeignKeyBuilder=t.ForeignKeyBuilder,exports.InlineForeignKeys=t.InlineForeignKeys,exports.ManualViewBuilder=t.ManualViewBuilder,exports.MySqlColumn=t.MySqlColumn,exports.MySqlColumnBuilder=t.MySqlColumnBuilder,exports.MySqlColumnBuilderWithAutoIncrement=t.MySqlColumnBuilderWithAutoIncrement,exports.MySqlColumnWithAutoIncrement=t.MySqlColumnWithAutoIncrement,exports.MySqlDatabase=t.MySqlDatabase,exports.MySqlDelete=t.MySqlDelete,exports.MySqlDialect=t.MySqlDialect,exports.MySqlInsert=t.MySqlInsert,exports.MySqlInsertBuilder=t.MySqlInsertBuilder,exports.MySqlSelect=t.MySqlSelect,exports.MySqlSelectBuilder=t.MySqlSelectBuilder,exports.MySqlSelectQueryBuilder=t.MySqlSelectQueryBuilder,exports.MySqlSession=t.MySqlSession,exports.MySqlTable=t.MySqlTable,exports.MySqlTransaction=t.MySqlTransaction,exports.MySqlUpdate=t.MySqlUpdate,exports.MySqlUpdateBuilder=t.MySqlUpdateBuilder,exports.MySqlView=t.MySqlView,exports.MySqlViewBase=t.MySqlViewBase,exports.MySqlViewConfig=t.MySqlViewConfig,exports.PreparedQuery=t.PreparedQuery,exports.QueryBuilder=t.QueryBuilder,exports.ViewBuilder=t.ViewBuilder,exports.ViewBuilderCore=t.ViewBuilderCore,exports.foreignKey=t.foreignKey,exports.mysqlTable=t.mysqlTable,exports.mysqlTableCreator=t.mysqlTableCreator,exports.mysqlTableWithSchema=t.mysqlTableWithSchema,exports.mysqlView=t.mysqlView,exports.mysqlViewWithSchema=t.mysqlViewWithSchema,exports.Check=n,exports.CheckBuilder=r,exports.Index=ae,exports.IndexBuilder=ce,exports.IndexBuilderOn=ue,exports.MySqlBigInt53=i,exports.MySqlBigInt53Builder=s,exports.MySqlBigInt64=l,exports.MySqlBigInt64Builder=o,exports.MySqlBinary=c,exports.MySqlBinaryBuilder=u,exports.MySqlBoolean=p,exports.MySqlBooleanBuilder=a,exports.MySqlChar=y,exports.MySqlCharBuilder=m,exports.MySqlCustomColumn=d,exports.MySqlCustomColumnBuilder=h,exports.MySqlDate=x,exports.MySqlDateBuilder=S,exports.MySqlDateString=q,exports.MySqlDateStringBuilder=f,exports.MySqlDateTime=M,exports.MySqlDateTimeBuilder=g,exports.MySqlDateTimeString=w,exports.MySqlDateTimeStringBuilder=b,exports.MySqlDecimal=C,exports.MySqlDecimalBuilder=B,exports.MySqlDouble=v,exports.MySqlDoubleBuilder=T,exports.MySqlEnumColumn=V,exports.MySqlEnumColumnBuilder=I,exports.MySqlFloat=Q,exports.MySqlFloatBuilder=D,exports.MySqlInt=L,exports.MySqlIntBuilder=W,exports.MySqlJson=A,exports.MySqlJsonBuilder=$,exports.MySqlMediumInt=N,exports.MySqlMediumIntBuilder=F,exports.MySqlReal=j,exports.MySqlRealBuilder=K,exports.MySqlSchema=ye,exports.MySqlSerial=O,exports.MySqlSerialBuilder=P,exports.MySqlSmallInt=k,exports.MySqlSmallIntBuilder=U,exports.MySqlText=J,exports.MySqlTextBuilder=E,exports.MySqlTime=_,exports.MySqlTimeBuilder=Y,exports.MySqlTimestamp=G,exports.MySqlTimestampBuilder=z,exports.MySqlTimestampString=Z,exports.MySqlTimestampStringBuilder=X,exports.MySqlTinyInt=te,exports.MySqlTinyIntBuilder=ee,exports.MySqlVarBinary=ne,exports.MySqlVarBinaryBuilder=re,exports.MySqlVarChar=ie,exports.MySqlVarCharBuilder=se,exports.MySqlYear=le,exports.MySqlYearBuilder=oe,exports.PrimaryKey=me,exports.PrimaryKeyBuilder=pe,exports.alias=function(t,r){return new Proxy(t,new e.TableAliasProxyHandler(r,!1))},exports.bigint=function(e,t){return"number"===t.mode?new s(e):new o(e)},exports.binary=function(e,t={}){return new u(e,t.length)},exports.boolean=function(e){return new a(e)},exports.char=function(e,t={}){return new m(e,t)},exports.check=function(e,t){return new r(e,t)},exports.customType=function(e){return(t,r)=>new h(t,r,e)},exports.date=function(e,t={}){return"string"===t.mode?new f(e):new S(e)},exports.datetime=function(e,t={}){return"string"===t.mode?new b(e,t):new g(e,t)},exports.decimal=function(e,t={}){return new B(e,t.precision,t.scale)},exports.double=function(e,t){return new T(e,t)},exports.float=function(e){return new D(e)},exports.getTableConfig=function(n){const s=Object.values(n[t.MySqlTable.Symbol.Columns]),i=[],o=[],l=[],u=Object.values(n[t.MySqlTable.Symbol.InlineForeignKeys]),c=n[e.Table.Symbol.Name],a=n[e.Table.Symbol.Schema],p=n[e.Table.Symbol.BaseName],m=n[t.MySqlTable.Symbol.ExtraConfigBuilder];if(void 0!==m){const e=m(n[t.MySqlTable.Symbol.Columns]);for(const s of Object.values(e))s instanceof ce?i.push(s.build(n)):s instanceof r?o.push(s.build(n)):s instanceof pe?l.push(s.build(n)):s instanceof t.ForeignKeyBuilder&&u.push(s.build(n))}return{columns:s,indexes:i,foreignKeys:u,checks:o,primaryKeys:l,name:c,schema:a,baseName:p}},exports.getViewConfig=function(r){return{...r[e.ViewBaseConfig],...r[t.MySqlViewConfig]}},exports.index=function(e){return new ue(e,!1)},exports.int=function(e){return new W(e)},exports.isMySqlSchema=function(e){return e instanceof ye},exports.json=function(e){return new $(e)},exports.longtext=function(e,t={}){return new E(e,"longtext",t)},exports.mediumint=function(e){return new F(e)},exports.mediumtext=function(e,t={}){return new E(e,"mediumtext",t)},exports.mysqlDatabase=he,exports.mysqlEnum=function(e,t){if(0===t.length)throw new Error(`You have an empty array for "${e}" enum values`);return new I(e,t)},exports.mysqlSchema=de,exports.primaryKey=function(...e){return new pe(e)},exports.real=function(e,t={}){return new K(e,t)},exports.serial=function(e){return new P(e)},exports.smallint=function(e){return new U(e)},exports.text=function(e,t={}){return new E(e,"text",t)},exports.time=function(e,t){return new Y(e,t)},exports.timestamp=function(e,t={}){return"string"===t.mode?new X(e,t):new z(e,t)},exports.tinyint=function(e){return new ee(e)},exports.tinytext=function(e,t={}){return new E(e,"tinytext",t)},exports.uniqueIndex=function(e){return new ue(e,!0)},exports.varbinary=function(e,t){return new re(e,t)},exports.varchar=function(e,t){return new se(e,t)},exports.year=function(e){return new oe(e)};
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1,2 +1,2 @@
1
- import{d as e,s as c,T as a,v as f}from"../index-b71998f1.mjs";import{M as m,a as d,b,c as S,d as T,m as L,e as $,F as D,f as N}from"../session-8a621f09.mjs";export{E as ExtraConfigBuilder,i as ForeignKey,I as InlineForeignKeys,y as ManualViewBuilder,g as MySqlDatabase,k as MySqlDelete,h as MySqlDialect,n as MySqlInsert,l as MySqlInsertBuilder,q as MySqlSelect,o as MySqlSelectBuilder,p as MySqlSelectQueryBuilder,t as MySqlSession,u as MySqlTransaction,s as MySqlUpdate,r as MySqlUpdateBuilder,A as MySqlView,z as MySqlViewBase,P as PreparedQuery,Q as QueryBuilder,x as ViewBuilder,V as ViewBuilderCore,j as foreignKey,v as mysqlTable,w as mysqlTableCreator,B as mysqlView}from"../session-8a621f09.mjs";import"../utils-e6870670.mjs";import"../query-promise-a65edd44.mjs";import"../column-builder-592f0191.mjs";import"../query-builder-2fcde2f0.mjs";function F(s,t){return new Proxy(s,new e(t,!1))}class M{constructor(e,s){this.name=e,this.value=s}build(e){return new C(e,this)}}class C{constructor(e,s){this.table=e,this.name=s.name,this.value=s.value}}function O(e,s){return new M(e,s)}class K extends m{build(e){return new U(e,this.config)}}class U extends d{getSQLType(){return"bigint"}mapFromDriverValue(e){return"number"==typeof e?e:Number(e)}}class _ extends m{build(e){return new J(e,this.config)}}class J extends d{getSQLType(){return"bigint"}mapFromDriverValue(e){return BigInt(e)}}function Y(e,s){return"number"===s.mode?new K(e):new _(e)}class G extends b{constructor(e,s){super(e),this.config.length=s}build(e){return new H(e,this.config)}}class H extends S{constructor(){super(...arguments),this.length=this.config.length}getSQLType(){return void 0===this.length?"binary":`binary(${this.length})`}}function R(e,s={}){return new G(e,s.length)}class W extends b{build(e){return new X(e,this.config)}}class X extends S{getSQLType(){return"boolean"}mapFromDriverValue(e){return"boolean"==typeof e?e:1===e}}function Z(e){return new W(e)}class ee extends b{constructor(e,s){super(e),this.config.length=s.length,this.config.enum=s.enum}build(e){return new se(e,this.config)}}class se extends S{constructor(){super(...arguments),this.length=this.config.length,this.enumValues=this.config.enum??[]}getSQLType(){return void 0===this.length?"char":`char(${this.length})`}}function te(e,s={}){return new ee(e,s)}class ne extends b{constructor(e,s,t){super(e),this.config.fieldConfig=s,this.config.customTypeParams=t}build(e){return new re(e,this.config)}}class re extends S{constructor(e,s){super(e,s),this.sqlName=s.customTypeParams.dataType(s.fieldConfig),this.mapTo=s.customTypeParams.toDriver,this.mapFrom=s.customTypeParams.fromDriver}getSQLType(){return this.sqlName}mapFromDriverValue(e){return"function"==typeof this.mapFrom?this.mapFrom(e):e}mapToDriverValue(e){return"function"==typeof this.mapTo?this.mapTo(e):e}}function ie(e){return(s,t)=>new ne(s,t,e)}class ue extends b{build(e){return new oe(e,this.config)}}class oe extends S{constructor(e,s){super(e,s)}getSQLType(){return"date"}mapFromDriverValue(e){return new Date(e)}}class ce extends b{build(e){return new ae(e,this.config)}}class ae extends S{constructor(e,s){super(e,s)}getSQLType(){return"date"}}function le(e,s={}){return"string"===s.mode?new ce(e):new ue(e)}class he extends b{constructor(e,s){super(e),this.config.fsp=s?.fsp}build(e){return new fe(e,this.config)}}class fe extends S{constructor(e,s){super(e,s),this.fsp=s.fsp}getSQLType(){return`datetime${void 0===this.fsp?"":`(${this.fsp})`}`}mapFromDriverValue(e){return new Date(e)}}class pe extends b{constructor(e,s){super(e),this.config.fsp=s?.fsp}build(e){return new ge(e,this.config)}}class ge extends S{constructor(e,s){super(e,s),this.fsp=s.fsp}getSQLType(){return`datetime${void 0===this.fsp?"":`(${this.fsp})`}`}}function me(e,s={}){return"string"===s.mode?new pe(e,s):new he(e,s)}class de extends m{constructor(e,s,t){super(e),this.config.precision=s,this.config.scale=t}build(e){return new ye(e,this.config)}}class ye extends d{constructor(){super(...arguments),this.precision=this.config.precision,this.scale=this.config.scale}getSQLType(){return void 0!==this.precision&&void 0!==this.scale?`decimal(${this.precision},${this.scale})`:void 0===this.precision?"decimal":`decimal(${this.precision})`}}function we(e,s={}){return new de(e,s.precision,s.scale)}class be extends m{constructor(e,s){super(e),this.config.precision=s?.precision,this.config.scale=s?.scale}build(e){return new xe(e,this.config)}}class xe extends d{constructor(){super(...arguments),this.precision=this.config.precision,this.scale=this.config.scale}getSQLType(){return void 0!==this.precision&&void 0!==this.scale?`double(${this.precision},${this.scale})`:void 0===this.precision?"double":`double(${this.precision})`}}function Se(e,s){return new be(e,s)}class ve extends b{constructor(e,s){super(e),this.config.enumValues=s}build(e){return new Te(e,this.config)}}class Te extends S{constructor(){super(...arguments),this.enumValues=this.config.enumValues}getSQLType(){return`enum(${this.enumValues.map((e=>`'${e}'`)).join(",")})`}}function Qe(e,s){if(0===s.length)throw new Error(`You have an empty array for "${e}" enum values`);return new ve(e,s)}class Ve extends m{build(e){return new Le(e,this.config)}}class Le extends d{getSQLType(){return"float"}}function $e(e){return new Ve(e)}class qe extends m{build(e){return new De(e,this.config)}}class De extends d{getSQLType(){return"int"}mapFromDriverValue(e){return"string"==typeof e?Number(e):e}}function Ne(e){return new qe(e)}class Fe extends b{build(e){return new Me(e,this.config)}}class Me extends S{getSQLType(){return"json"}mapToDriverValue(e){return JSON.stringify(e)}}function je(e){return new Fe(e)}class Be extends m{build(e){return new Ce(e,this.config)}}class Ce extends d{getSQLType(){return"mediumint"}mapFromDriverValue(e){return"string"==typeof e?Number(e):e}}function Ie(e){return new Be(e)}class Oe extends m{constructor(e,s){super(e),this.config.precision=s?.precision,this.config.scale=s?.scale}build(e){return new Pe(e,this.config)}}class Pe extends d{constructor(){super(...arguments),this.precision=this.config.precision,this.scale=this.config.scale}getSQLType(){return void 0!==this.precision&&void 0!==this.scale?`real(${this.precision}, ${this.scale})`:void 0===this.precision?"real":`real(${this.precision})`}}function Ke(e,s={}){return new Oe(e,s)}class Ue extends m{constructor(e){super(e),this.config.hasDefault=!0,this.config.autoIncrement=!0}build(e){return new ke(e,this.config)}}class ke extends d{getSQLType(){return"serial"}mapFromDriverValue(e){return"string"==typeof e?Number(e):e}}function Ee(e){return new Ue(e)}class _e extends m{build(e){return new ze(e,this.config)}}class ze extends d{getSQLType(){return"smallint"}mapFromDriverValue(e){return"string"==typeof e?Number(e):e}}function Ae(e){return new _e(e)}class Je extends b{constructor(e,s,t){super(e),this.config.textType=s,this.config.enumValues=t.enum}build(e){return new Ye(e,this.config)}}class Ye extends S{constructor(){super(...arguments),this.textType=this.config.textType,this.enumValues=this.config.enumValues??[]}getSQLType(){return this.textType}}function Ge(e,s={}){return new Je(e,"text",s)}function He(e,s={}){return new Je(e,"tinytext",s)}function Re(e,s={}){return new Je(e,"mediumtext",s)}function We(e,s={}){return new Je(e,"longtext",s)}class Xe extends b{constructor(e,s){super(e),this.config.fsp=s?.fsp}build(e){return new Ze(e,this.config)}}class Ze extends S{constructor(){super(...arguments),this.fsp=this.config.fsp}getSQLType(){return`time${void 0===this.fsp?"":`(${this.fsp})`}`}}function es(e,s){return new Xe(e,s)}class ss extends b{defaultNow(){return this.default(c`(now())`)}onUpdateNow(){return this.config.hasOnUpdateNow=!0,this.config.hasDefault=!0,this}}class ts extends S{constructor(){super(...arguments),this.hasOnUpdateNow=this.config.hasOnUpdateNow}}class ns extends ss{constructor(e,s){super(e),this.config.fsp=s?.fsp}build(e){return new rs(e,this.config)}}class rs extends ts{constructor(){super(...arguments),this.fsp=this.config.fsp}getSQLType(){return`timestamp${void 0===this.fsp?"":`(${this.fsp})`}`}mapFromDriverValue(e){return new Date(e+"+0000")}mapToDriverValue(e){return e.toISOString().slice(0,19).replace("T"," ")}}class is extends ss{constructor(e,s){super(e),this.config.fsp=s?.fsp}build(e){return new us(e,this.config)}}class us extends ts{constructor(){super(...arguments),this.fsp=this.config.fsp}getSQLType(){return`timestamp${void 0===this.fsp?"":`(${this.fsp})`}`}}function os(e,s={}){return"string"===s.mode?new is(e,s):new ns(e,s)}class cs extends m{build(e){return new as(e,this.config)}}class as extends d{getSQLType(){return"tinyint"}mapFromDriverValue(e){return"string"==typeof e?Number(e):e}}function ls(e){return new cs(e)}class hs extends b{constructor(e,s){super(e),this.config.length=s?.length}build(e){return new fs(e,this.config)}}class fs extends S{constructor(){super(...arguments),this.length=this.config.length}getSQLType(){return void 0===this.length?"varbinary":`varbinary(${this.length})`}}function ps(e,s){return new hs(e,s)}class gs extends b{constructor(e,s){super(e),this.config.length=s.length,this.config.enum=s.enum}build(e){return new ms(e,this.config)}}class ms extends S{constructor(){super(...arguments),this.length=this.config.length,this.enumValues=this.config.enum??[]}getSQLType(){return void 0===this.length?"varchar":`varchar(${this.length})`}}function ds(e,s){return new gs(e,s)}class ys extends b{build(e){return new ws(e,this.config)}}class ws extends S{getSQLType(){return"year"}}function bs(e){return new ys(e)}class xs{constructor(e,s){this.name=e,this.unique=s}on(...e){return new Ss(this.name,e,this.unique)}}class Ss{constructor(e,s,t){this.config={name:e,columns:s,unique:t}}using(e){return this.config.using=e,this}algorythm(e){return this.config.algorythm=e,this}lock(e){return this.config.lock=e,this}build(e){return new vs(this.config,e)}}class vs{constructor(e,s){this.config={...e,table:s}}}function Ts(e){return new xs(e,!1)}function Qs(e){return new xs(e,!0)}function Vs(...e){return new Ls(e)}class Ls{constructor(e){this.columns=e}build(e){return new $s(e,this.columns)}}class $s{constructor(e,s){this.table=e,this.columns=s}getName(){return`${this.table[T.Symbol.Name]}_${this.columns.map((e=>e.name)).join("_")}_pk`}}class qs{constructor(e){this.schemaName=e,this.table=(e,s,t)=>L(e,s,t,this.schemaName),this.view=(e,s)=>$(e,s,this.schemaName)}}function Ds(e){return e instanceof qs}function Ns(e){return new qs(e)}const Fs=Ns;function Ms(e){const s=Object.values(e[T.Symbol.Columns]),t=[],n=[],r=[],i=Object.values(e[T.Symbol.InlineForeignKeys]),u=e[a.Symbol.Name],o=e[a.Symbol.Schema],c=e[a.Symbol.BaseName],l=e[T.Symbol.ExtraConfigBuilder];if(void 0!==l){const s=l(e[T.Symbol.Columns]);for(const u of Object.values(s))u instanceof Ss?t.push(u.build(e)):u instanceof M?n.push(u.build(e)):u instanceof Ls?r.push(u.build(e)):u instanceof D&&i.push(u.build(e))}return{columns:s,indexes:t,foreignKeys:i,checks:n,primaryKeys:r,name:u,schema:o,baseName:c}}function js(e){return{...e[f],...e[N]}}export{C as Check,M as CheckBuilder,D as ForeignKeyBuilder,vs as Index,Ss as IndexBuilder,xs as IndexBuilderOn,U as MySqlBigInt53,K as MySqlBigInt53Builder,J as MySqlBigInt64,_ as MySqlBigInt64Builder,H as MySqlBinary,G as MySqlBinaryBuilder,X as MySqlBoolean,W as MySqlBooleanBuilder,se as MySqlChar,ee as MySqlCharBuilder,S as MySqlColumn,b as MySqlColumnBuilder,m as MySqlColumnBuilderWithAutoIncrement,d as MySqlColumnWithAutoIncrement,re as MySqlCustomColumn,ne as MySqlCustomColumnBuilder,oe as MySqlDate,ue as MySqlDateBuilder,ae as MySqlDateString,ce as MySqlDateStringBuilder,fe as MySqlDateTime,he as MySqlDateTimeBuilder,ge as MySqlDateTimeString,pe as MySqlDateTimeStringBuilder,ye as MySqlDecimal,de as MySqlDecimalBuilder,xe as MySqlDouble,be as MySqlDoubleBuilder,Te as MySqlEnumColumn,ve as MySqlEnumColumnBuilder,Le as MySqlFloat,Ve as MySqlFloatBuilder,De as MySqlInt,qe as MySqlIntBuilder,Me as MySqlJson,Fe as MySqlJsonBuilder,Ce as MySqlMediumInt,Be as MySqlMediumIntBuilder,Pe as MySqlReal,Oe as MySqlRealBuilder,qs as MySqlSchema,ke as MySqlSerial,Ue as MySqlSerialBuilder,ze as MySqlSmallInt,_e as MySqlSmallIntBuilder,T as MySqlTable,Ye as MySqlText,Je as MySqlTextBuilder,Ze as MySqlTime,Xe as MySqlTimeBuilder,rs as MySqlTimestamp,ns as MySqlTimestampBuilder,us as MySqlTimestampString,is as MySqlTimestampStringBuilder,as as MySqlTinyInt,cs as MySqlTinyIntBuilder,fs as MySqlVarBinary,hs as MySqlVarBinaryBuilder,ms as MySqlVarChar,gs as MySqlVarCharBuilder,N as MySqlViewConfig,ws as MySqlYear,ys as MySqlYearBuilder,$s as PrimaryKey,Ls as PrimaryKeyBuilder,F as alias,Y as bigint,R as binary,Z as boolean,te as char,O as check,ie as customType,le as date,me as datetime,we as decimal,Se as double,$e as float,Ms as getTableConfig,js as getViewConfig,Ts as index,Ne as int,Ds as isMySqlSchema,je as json,We as longtext,Ie as mediumint,Re as mediumtext,Ns as mysqlDatabase,Qe as mysqlEnum,Fs as mysqlSchema,L as mysqlTableWithSchema,$ as mysqlViewWithSchema,Vs as primaryKey,Ke as real,Ee as serial,Ae as smallint,Ge as text,es as time,os as timestamp,ls as tinyint,He as tinytext,Qs as uniqueIndex,ps as varbinary,ds as varchar,bs as year};
1
+ import{d as e,s as c,T as a,v as f}from"../index-b71998f1.mjs";import{M as m,a as d,b,c as S,d as T,m as L,e as $,F as D,f as N}from"../session-a87f051d.mjs";export{E as ExtraConfigBuilder,i as ForeignKey,I as InlineForeignKeys,y as ManualViewBuilder,g as MySqlDatabase,k as MySqlDelete,h as MySqlDialect,n as MySqlInsert,l as MySqlInsertBuilder,q as MySqlSelect,o as MySqlSelectBuilder,p as MySqlSelectQueryBuilder,t as MySqlSession,u as MySqlTransaction,s as MySqlUpdate,r as MySqlUpdateBuilder,A as MySqlView,z as MySqlViewBase,P as PreparedQuery,Q as QueryBuilder,x as ViewBuilder,V as ViewBuilderCore,j as foreignKey,v as mysqlTable,w as mysqlTableCreator,B as mysqlView}from"../session-a87f051d.mjs";import"../utils-e6870670.mjs";import"../query-promise-a65edd44.mjs";import"../column-builder-592f0191.mjs";import"../query-builder-2fcde2f0.mjs";function F(s,t){return new Proxy(s,new e(t,!1))}class M{constructor(e,s){this.name=e,this.value=s}build(e){return new C(e,this)}}class C{constructor(e,s){this.table=e,this.name=s.name,this.value=s.value}}function O(e,s){return new M(e,s)}class K extends m{build(e){return new U(e,this.config)}}class U extends d{getSQLType(){return"bigint"}mapFromDriverValue(e){return"number"==typeof e?e:Number(e)}}class _ extends m{build(e){return new J(e,this.config)}}class J extends d{getSQLType(){return"bigint"}mapFromDriverValue(e){return BigInt(e)}}function Y(e,s){return"number"===s.mode?new K(e):new _(e)}class G extends b{constructor(e,s){super(e),this.config.length=s}build(e){return new H(e,this.config)}}class H extends S{constructor(){super(...arguments),this.length=this.config.length}getSQLType(){return void 0===this.length?"binary":`binary(${this.length})`}}function R(e,s={}){return new G(e,s.length)}class W extends b{build(e){return new X(e,this.config)}}class X extends S{getSQLType(){return"boolean"}mapFromDriverValue(e){return"boolean"==typeof e?e:1===e}}function Z(e){return new W(e)}class ee extends b{constructor(e,s){super(e),this.config.length=s.length,this.config.enum=s.enum}build(e){return new se(e,this.config)}}class se extends S{constructor(){super(...arguments),this.length=this.config.length,this.enumValues=this.config.enum??[]}getSQLType(){return void 0===this.length?"char":`char(${this.length})`}}function te(e,s={}){return new ee(e,s)}class ne extends b{constructor(e,s,t){super(e),this.config.fieldConfig=s,this.config.customTypeParams=t}build(e){return new re(e,this.config)}}class re extends S{constructor(e,s){super(e,s),this.sqlName=s.customTypeParams.dataType(s.fieldConfig),this.mapTo=s.customTypeParams.toDriver,this.mapFrom=s.customTypeParams.fromDriver}getSQLType(){return this.sqlName}mapFromDriverValue(e){return"function"==typeof this.mapFrom?this.mapFrom(e):e}mapToDriverValue(e){return"function"==typeof this.mapTo?this.mapTo(e):e}}function ie(e){return(s,t)=>new ne(s,t,e)}class ue extends b{build(e){return new oe(e,this.config)}}class oe extends S{constructor(e,s){super(e,s)}getSQLType(){return"date"}mapFromDriverValue(e){return new Date(e)}}class ce extends b{build(e){return new ae(e,this.config)}}class ae extends S{constructor(e,s){super(e,s)}getSQLType(){return"date"}}function le(e,s={}){return"string"===s.mode?new ce(e):new ue(e)}class he extends b{constructor(e,s){super(e),this.config.fsp=s?.fsp}build(e){return new fe(e,this.config)}}class fe extends S{constructor(e,s){super(e,s),this.fsp=s.fsp}getSQLType(){return`datetime${void 0===this.fsp?"":`(${this.fsp})`}`}mapFromDriverValue(e){return new Date(e)}}class pe extends b{constructor(e,s){super(e),this.config.fsp=s?.fsp}build(e){return new ge(e,this.config)}}class ge extends S{constructor(e,s){super(e,s),this.fsp=s.fsp}getSQLType(){return`datetime${void 0===this.fsp?"":`(${this.fsp})`}`}}function me(e,s={}){return"string"===s.mode?new pe(e,s):new he(e,s)}class de extends m{constructor(e,s,t){super(e),this.config.precision=s,this.config.scale=t}build(e){return new ye(e,this.config)}}class ye extends d{constructor(){super(...arguments),this.precision=this.config.precision,this.scale=this.config.scale}getSQLType(){return void 0!==this.precision&&void 0!==this.scale?`decimal(${this.precision},${this.scale})`:void 0===this.precision?"decimal":`decimal(${this.precision})`}}function we(e,s={}){return new de(e,s.precision,s.scale)}class be extends m{constructor(e,s){super(e),this.config.precision=s?.precision,this.config.scale=s?.scale}build(e){return new xe(e,this.config)}}class xe extends d{constructor(){super(...arguments),this.precision=this.config.precision,this.scale=this.config.scale}getSQLType(){return void 0!==this.precision&&void 0!==this.scale?`double(${this.precision},${this.scale})`:void 0===this.precision?"double":`double(${this.precision})`}}function Se(e,s){return new be(e,s)}class ve extends b{constructor(e,s){super(e),this.config.enumValues=s}build(e){return new Te(e,this.config)}}class Te extends S{constructor(){super(...arguments),this.enumValues=this.config.enumValues}getSQLType(){return`enum(${this.enumValues.map((e=>`'${e}'`)).join(",")})`}}function Qe(e,s){if(0===s.length)throw new Error(`You have an empty array for "${e}" enum values`);return new ve(e,s)}class Ve extends m{build(e){return new Le(e,this.config)}}class Le extends d{getSQLType(){return"float"}}function $e(e){return new Ve(e)}class qe extends m{build(e){return new De(e,this.config)}}class De extends d{getSQLType(){return"int"}mapFromDriverValue(e){return"string"==typeof e?Number(e):e}}function Ne(e){return new qe(e)}class Fe extends b{build(e){return new Me(e,this.config)}}class Me extends S{getSQLType(){return"json"}mapToDriverValue(e){return JSON.stringify(e)}}function je(e){return new Fe(e)}class Be extends m{build(e){return new Ce(e,this.config)}}class Ce extends d{getSQLType(){return"mediumint"}mapFromDriverValue(e){return"string"==typeof e?Number(e):e}}function Ie(e){return new Be(e)}class Oe extends m{constructor(e,s){super(e),this.config.precision=s?.precision,this.config.scale=s?.scale}build(e){return new Pe(e,this.config)}}class Pe extends d{constructor(){super(...arguments),this.precision=this.config.precision,this.scale=this.config.scale}getSQLType(){return void 0!==this.precision&&void 0!==this.scale?`real(${this.precision}, ${this.scale})`:void 0===this.precision?"real":`real(${this.precision})`}}function Ke(e,s={}){return new Oe(e,s)}class Ue extends m{constructor(e){super(e),this.config.hasDefault=!0,this.config.autoIncrement=!0}build(e){return new ke(e,this.config)}}class ke extends d{getSQLType(){return"serial"}mapFromDriverValue(e){return"string"==typeof e?Number(e):e}}function Ee(e){return new Ue(e)}class _e extends m{build(e){return new ze(e,this.config)}}class ze extends d{getSQLType(){return"smallint"}mapFromDriverValue(e){return"string"==typeof e?Number(e):e}}function Ae(e){return new _e(e)}class Je extends b{constructor(e,s,t){super(e),this.config.textType=s,this.config.enumValues=t.enum}build(e){return new Ye(e,this.config)}}class Ye extends S{constructor(){super(...arguments),this.textType=this.config.textType,this.enumValues=this.config.enumValues??[]}getSQLType(){return this.textType}}function Ge(e,s={}){return new Je(e,"text",s)}function He(e,s={}){return new Je(e,"tinytext",s)}function Re(e,s={}){return new Je(e,"mediumtext",s)}function We(e,s={}){return new Je(e,"longtext",s)}class Xe extends b{constructor(e,s){super(e),this.config.fsp=s?.fsp}build(e){return new Ze(e,this.config)}}class Ze extends S{constructor(){super(...arguments),this.fsp=this.config.fsp}getSQLType(){return`time${void 0===this.fsp?"":`(${this.fsp})`}`}}function es(e,s){return new Xe(e,s)}class ss extends b{defaultNow(){return this.default(c`(now())`)}onUpdateNow(){return this.config.hasOnUpdateNow=!0,this.config.hasDefault=!0,this}}class ts extends S{constructor(){super(...arguments),this.hasOnUpdateNow=this.config.hasOnUpdateNow}}class ns extends ss{constructor(e,s){super(e),this.config.fsp=s?.fsp}build(e){return new rs(e,this.config)}}class rs extends ts{constructor(){super(...arguments),this.fsp=this.config.fsp}getSQLType(){return`timestamp${void 0===this.fsp?"":`(${this.fsp})`}`}mapFromDriverValue(e){return new Date(e+"+0000")}mapToDriverValue(e){return e.toISOString().slice(0,19).replace("T"," ")}}class is extends ss{constructor(e,s){super(e),this.config.fsp=s?.fsp}build(e){return new us(e,this.config)}}class us extends ts{constructor(){super(...arguments),this.fsp=this.config.fsp}getSQLType(){return`timestamp${void 0===this.fsp?"":`(${this.fsp})`}`}}function os(e,s={}){return"string"===s.mode?new is(e,s):new ns(e,s)}class cs extends m{build(e){return new as(e,this.config)}}class as extends d{getSQLType(){return"tinyint"}mapFromDriverValue(e){return"string"==typeof e?Number(e):e}}function ls(e){return new cs(e)}class hs extends b{constructor(e,s){super(e),this.config.length=s?.length}build(e){return new fs(e,this.config)}}class fs extends S{constructor(){super(...arguments),this.length=this.config.length}getSQLType(){return void 0===this.length?"varbinary":`varbinary(${this.length})`}}function ps(e,s){return new hs(e,s)}class gs extends b{constructor(e,s){super(e),this.config.length=s.length,this.config.enum=s.enum}build(e){return new ms(e,this.config)}}class ms extends S{constructor(){super(...arguments),this.length=this.config.length,this.enumValues=this.config.enum??[]}getSQLType(){return void 0===this.length?"varchar":`varchar(${this.length})`}}function ds(e,s){return new gs(e,s)}class ys extends b{build(e){return new ws(e,this.config)}}class ws extends S{getSQLType(){return"year"}}function bs(e){return new ys(e)}class xs{constructor(e,s){this.name=e,this.unique=s}on(...e){return new Ss(this.name,e,this.unique)}}class Ss{constructor(e,s,t){this.config={name:e,columns:s,unique:t}}using(e){return this.config.using=e,this}algorythm(e){return this.config.algorythm=e,this}lock(e){return this.config.lock=e,this}build(e){return new vs(this.config,e)}}class vs{constructor(e,s){this.config={...e,table:s}}}function Ts(e){return new xs(e,!1)}function Qs(e){return new xs(e,!0)}function Vs(...e){return new Ls(e)}class Ls{constructor(e){this.columns=e}build(e){return new $s(e,this.columns)}}class $s{constructor(e,s){this.table=e,this.columns=s}getName(){return`${this.table[T.Symbol.Name]}_${this.columns.map((e=>e.name)).join("_")}_pk`}}class qs{constructor(e){this.schemaName=e,this.table=(e,s,t)=>L(e,s,t,this.schemaName),this.view=(e,s)=>$(e,s,this.schemaName)}}function Ds(e){return e instanceof qs}function Ns(e){return new qs(e)}const Fs=Ns;function Ms(e){const s=Object.values(e[T.Symbol.Columns]),t=[],n=[],r=[],i=Object.values(e[T.Symbol.InlineForeignKeys]),u=e[a.Symbol.Name],o=e[a.Symbol.Schema],c=e[a.Symbol.BaseName],l=e[T.Symbol.ExtraConfigBuilder];if(void 0!==l){const s=l(e[T.Symbol.Columns]);for(const u of Object.values(s))u instanceof Ss?t.push(u.build(e)):u instanceof M?n.push(u.build(e)):u instanceof Ls?r.push(u.build(e)):u instanceof D&&i.push(u.build(e))}return{columns:s,indexes:t,foreignKeys:i,checks:n,primaryKeys:r,name:u,schema:o,baseName:c}}function js(e){return{...e[f],...e[N]}}export{C as Check,M as CheckBuilder,D as ForeignKeyBuilder,vs as Index,Ss as IndexBuilder,xs as IndexBuilderOn,U as MySqlBigInt53,K as MySqlBigInt53Builder,J as MySqlBigInt64,_ as MySqlBigInt64Builder,H as MySqlBinary,G as MySqlBinaryBuilder,X as MySqlBoolean,W as MySqlBooleanBuilder,se as MySqlChar,ee as MySqlCharBuilder,S as MySqlColumn,b as MySqlColumnBuilder,m as MySqlColumnBuilderWithAutoIncrement,d as MySqlColumnWithAutoIncrement,re as MySqlCustomColumn,ne as MySqlCustomColumnBuilder,oe as MySqlDate,ue as MySqlDateBuilder,ae as MySqlDateString,ce as MySqlDateStringBuilder,fe as MySqlDateTime,he as MySqlDateTimeBuilder,ge as MySqlDateTimeString,pe as MySqlDateTimeStringBuilder,ye as MySqlDecimal,de as MySqlDecimalBuilder,xe as MySqlDouble,be as MySqlDoubleBuilder,Te as MySqlEnumColumn,ve as MySqlEnumColumnBuilder,Le as MySqlFloat,Ve as MySqlFloatBuilder,De as MySqlInt,qe as MySqlIntBuilder,Me as MySqlJson,Fe as MySqlJsonBuilder,Ce as MySqlMediumInt,Be as MySqlMediumIntBuilder,Pe as MySqlReal,Oe as MySqlRealBuilder,qs as MySqlSchema,ke as MySqlSerial,Ue as MySqlSerialBuilder,ze as MySqlSmallInt,_e as MySqlSmallIntBuilder,T as MySqlTable,Ye as MySqlText,Je as MySqlTextBuilder,Ze as MySqlTime,Xe as MySqlTimeBuilder,rs as MySqlTimestamp,ns as MySqlTimestampBuilder,us as MySqlTimestampString,is as MySqlTimestampStringBuilder,as as MySqlTinyInt,cs as MySqlTinyIntBuilder,fs as MySqlVarBinary,hs as MySqlVarBinaryBuilder,ms as MySqlVarChar,gs as MySqlVarCharBuilder,N as MySqlViewConfig,ws as MySqlYear,ys as MySqlYearBuilder,$s as PrimaryKey,Ls as PrimaryKeyBuilder,F as alias,Y as bigint,R as binary,Z as boolean,te as char,O as check,ie as customType,le as date,me as datetime,we as decimal,Se as double,$e as float,Ms as getTableConfig,js as getViewConfig,Ts as index,Ne as int,Ds as isMySqlSchema,je as json,We as longtext,Ie as mediumint,Re as mediumtext,Ns as mysqlDatabase,Qe as mysqlEnum,Fs as mysqlSchema,L as mysqlTableWithSchema,$ as mysqlViewWithSchema,Vs as primaryKey,Ke as real,Ee as serial,Ae as smallint,Ge as text,es as time,os as timestamp,ls as tinyint,He as tinytext,Qs as uniqueIndex,ps as varbinary,ds as varchar,bs as year};
2
2
  //# sourceMappingURL=index.mjs.map
package/mysql2/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("../logger-04bad527.cjs"),t=require("../session-e6db6732.cjs"),s=require("node:events"),r=require("../index-59b7992d.cjs"),i=require("../utils-9d882195.cjs");require("../query-promise-2c5b43ab.cjs"),require("../column-builder-b48639f3.cjs"),require("../query-builder-2f2e8229.cjs");class n extends t.PreparedQuery{constructor(e,t,s,r,i){super(),this.client=e,this.params=s,this.logger=r,this.fields=i,this.rawQuery={sql:t,typeCast:function(e,t){return"TIMESTAMP"===e.type||"DATETIME"===e.type||"DATE"===e.type?e.string():t()}},this.query={sql:t,rowsAsArray:!0,typeCast:function(e,t){return"TIMESTAMP"===e.type||"DATETIME"===e.type||"DATE"===e.type?e.string():t()}}}async execute(e={}){const t=r.fillPlaceholders(this.params,e);this.logger.logQuery(this.rawQuery.sql,t);const{fields:s,client:n,rawQuery:a,query:o,joinsNotNullableMap:l}=this;if(!s)return n.query(a,t);return n.query(o,t).then((e=>e[0].map((e=>i.mapResultRow(s,e,l)))))}async*iterator(e={}){const t=r.fillPlaceholders(this.params,e),n=(l(this.client)?await this.client.getConnection():this.client).connection,{fields:a,query:o,rawQuery:c,joinsNotNullableMap:u,client:y}=this,h=(a?n.query(o,t):n.query(c,t)).stream();function p(){h.pause()}h.on("data",p);try{const e=s.once(h,"end"),t=s.once(h,"error");for(;;){h.resume();const s=await Promise.race([e,t,new Promise((e=>h.once("data",e)))]);if(void 0===s||Array.isArray(s)&&0===s.length)break;if(s instanceof Error)throw s;yield a?i.mapResultRow(a,s,u):s}}finally{h.off("data",p),l(y)&&n.end()}}}class a extends t.MySqlSession{constructor(t,s,r={}){super(s),this.client=t,this.options=r,this.logger=r.logger??new e.NoopLogger}prepareQuery(e,t){return new n(this.client,e.sql,e.params,this.logger,t)}async query(e,t){this.logger.logQuery(e,t);return await this.client.query({sql:e,values:t,rowsAsArray:!0,typeCast:function(e,t){return"TIMESTAMP"===e.type||"DATETIME"===e.type||"DATE"===e.type?e.string():t()}})}all(e){const t=this.dialect.sqlToQuery(e);return this.logger.logQuery(t.sql,t.params),this.client.execute(t.sql,t.params).then((e=>e[0]))}async transaction(e,t){const s=l(this.client)?new a(await this.client.getConnection(),this.dialect,this.options):this,i=new o(this.dialect,s);if(t){const e=this.getSetTransactionSQL(t);e&&await i.execute(e);const s=this.getStartTransactionSQL(t);await(s?i.execute(s):i.execute(r.sql`begin`))}else await i.execute(r.sql`begin`);try{const t=await e(i);return await i.execute(r.sql`commit`),t}catch(e){throw await i.execute(r.sql`rollback`),e}finally{l(this.client)&&s.client.release()}}}class o extends t.MySqlTransaction{async transaction(e){const t=`sp${this.nestedIndex+1}`,s=new o(this.dialect,this.session,this.nestedIndex+1);await s.execute(r.sql.raw(`savepoint ${t}`));try{const i=await e(s);return await s.execute(r.sql.raw(`release savepoint ${t}`)),i}catch(e){throw await s.execute(r.sql.raw(`rollback to savepoint ${t}`)),e}}}function l(e){return"getConnection"in e}class c{constructor(e,t,s={}){this.client=e,this.dialect=t,this.options=s}createSession(){return new a(this.client,this.dialect,{logger:this.options.logger})}}exports.MySqlDatabase=t.MySqlDatabase,exports.MySql2Driver=c,exports.MySql2PreparedQuery=n,exports.MySql2Session=a,exports.MySql2Transaction=o,exports.drizzle=function(s,r={}){const i=new t.MySqlDialect;let n;!0===r.logger?n=new e.DefaultLogger:!1!==r.logger&&(n=r.logger),function(e){return"function"==typeof e.promise}(s)&&(s=s.promise());const a=new c(s,i,{logger:n}).createSession();return new t.MySqlDatabase(i,a)};
1
+ "use strict";var e=require("../logger-04bad527.cjs"),t=require("../session-e630c258.cjs"),s=require("node:events"),r=require("../index-59b7992d.cjs"),i=require("../utils-9d882195.cjs");require("../query-promise-2c5b43ab.cjs"),require("../column-builder-b48639f3.cjs"),require("../query-builder-2f2e8229.cjs");class n extends t.PreparedQuery{constructor(e,t,s,r,i){super(),this.client=e,this.params=s,this.logger=r,this.fields=i,this.rawQuery={sql:t,typeCast:function(e,t){return"TIMESTAMP"===e.type||"DATETIME"===e.type||"DATE"===e.type?e.string():t()}},this.query={sql:t,rowsAsArray:!0,typeCast:function(e,t){return"TIMESTAMP"===e.type||"DATETIME"===e.type||"DATE"===e.type?e.string():t()}}}async execute(e={}){const t=r.fillPlaceholders(this.params,e);this.logger.logQuery(this.rawQuery.sql,t);const{fields:s,client:n,rawQuery:a,query:o,joinsNotNullableMap:l}=this;if(!s)return n.query(a,t);return n.query(o,t).then((e=>e[0].map((e=>i.mapResultRow(s,e,l)))))}async*iterator(e={}){const t=r.fillPlaceholders(this.params,e),n=(l(this.client)?await this.client.getConnection():this.client).connection,{fields:a,query:o,rawQuery:c,joinsNotNullableMap:u,client:y}=this,h=(a?n.query(o,t):n.query(c,t)).stream();function p(){h.pause()}h.on("data",p);try{const e=s.once(h,"end"),t=s.once(h,"error");for(;;){h.resume();const s=await Promise.race([e,t,new Promise((e=>h.once("data",e)))]);if(void 0===s||Array.isArray(s)&&0===s.length)break;if(s instanceof Error)throw s;yield a?i.mapResultRow(a,s,u):s}}finally{h.off("data",p),l(y)&&n.end()}}}class a extends t.MySqlSession{constructor(t,s,r={}){super(s),this.client=t,this.options=r,this.logger=r.logger??new e.NoopLogger}prepareQuery(e,t){return new n(this.client,e.sql,e.params,this.logger,t)}async query(e,t){this.logger.logQuery(e,t);return await this.client.query({sql:e,values:t,rowsAsArray:!0,typeCast:function(e,t){return"TIMESTAMP"===e.type||"DATETIME"===e.type||"DATE"===e.type?e.string():t()}})}all(e){const t=this.dialect.sqlToQuery(e);return this.logger.logQuery(t.sql,t.params),this.client.execute(t.sql,t.params).then((e=>e[0]))}async transaction(e,t){const s=l(this.client)?new a(await this.client.getConnection(),this.dialect,this.options):this,i=new o(this.dialect,s);if(t){const e=this.getSetTransactionSQL(t);e&&await i.execute(e);const s=this.getStartTransactionSQL(t);await(s?i.execute(s):i.execute(r.sql`begin`))}else await i.execute(r.sql`begin`);try{const t=await e(i);return await i.execute(r.sql`commit`),t}catch(e){throw await i.execute(r.sql`rollback`),e}finally{l(this.client)&&s.client.release()}}}class o extends t.MySqlTransaction{async transaction(e){const t=`sp${this.nestedIndex+1}`,s=new o(this.dialect,this.session,this.nestedIndex+1);await s.execute(r.sql.raw(`savepoint ${t}`));try{const i=await e(s);return await s.execute(r.sql.raw(`release savepoint ${t}`)),i}catch(e){throw await s.execute(r.sql.raw(`rollback to savepoint ${t}`)),e}}}function l(e){return"getConnection"in e}class c{constructor(e,t,s={}){this.client=e,this.dialect=t,this.options=s}createSession(){return new a(this.client,this.dialect,{logger:this.options.logger})}}exports.MySqlDatabase=t.MySqlDatabase,exports.MySql2Driver=c,exports.MySql2PreparedQuery=n,exports.MySql2Session=a,exports.MySql2Transaction=o,exports.drizzle=function(s,r={}){const i=new t.MySqlDialect;let n;!0===r.logger?n=new e.DefaultLogger:!1!==r.logger&&(n=r.logger),function(e){return"function"==typeof e.promise}(s)&&(s=s.promise());const a=new c(s,i,{logger:n}).createSession();return new t.MySqlDatabase(i,a)};
2
2
  //# sourceMappingURL=index.cjs.map
package/mysql2/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import{N as t,D as e}from"../logger-2598bf05.mjs";import{P as s,t as r,u as i,g as n,h as a}from"../session-8a621f09.mjs";import{once as o}from"node:events";import{k as c,s as l}from"../index-b71998f1.mjs";import{m as u}from"../utils-e6870670.mjs";import"../query-promise-a65edd44.mjs";import"../column-builder-592f0191.mjs";import"../query-builder-2fcde2f0.mjs";class h extends s{constructor(t,e,s,r,i){super(),this.client=t,this.params=s,this.logger=r,this.fields=i,this.rawQuery={sql:e,typeCast:function(t,e){return"TIMESTAMP"===t.type||"DATETIME"===t.type||"DATE"===t.type?t.string():e()}},this.query={sql:e,rowsAsArray:!0,typeCast:function(t,e){return"TIMESTAMP"===t.type||"DATETIME"===t.type||"DATE"===t.type?t.string():e()}}}async execute(t={}){const e=c(this.params,t);this.logger.logQuery(this.rawQuery.sql,e);const{fields:s,client:r,rawQuery:i,query:n,joinsNotNullableMap:a}=this;if(!s)return r.query(i,e);return r.query(n,e).then((t=>t[0].map((t=>u(s,t,a)))))}async*iterator(t={}){const e=c(this.params,t),s=(g(this.client)?await this.client.getConnection():this.client).connection,{fields:r,query:i,rawQuery:n,joinsNotNullableMap:a,client:l}=this,h=(r?s.query(i,e):s.query(n,e)).stream();function y(){h.pause()}h.on("data",y);try{const t=o(h,"end"),e=o(h,"error");for(;;){h.resume();const s=await Promise.race([t,e,new Promise((t=>h.once("data",t)))]);if(void 0===s||Array.isArray(s)&&0===s.length)break;if(s instanceof Error)throw s;yield r?u(r,s,a):s}}finally{h.off("data",y),g(l)&&s.end()}}}class y extends r{constructor(e,s,r={}){super(s),this.client=e,this.options=r,this.logger=r.logger??new t}prepareQuery(t,e){return new h(this.client,t.sql,t.params,this.logger,e)}async query(t,e){this.logger.logQuery(t,e);return await this.client.query({sql:t,values:e,rowsAsArray:!0,typeCast:function(t,e){return"TIMESTAMP"===t.type||"DATETIME"===t.type||"DATE"===t.type?t.string():e()}})}all(t){const e=this.dialect.sqlToQuery(t);return this.logger.logQuery(e.sql,e.params),this.client.execute(e.sql,e.params).then((t=>t[0]))}async transaction(t,e){const s=g(this.client)?new y(await this.client.getConnection(),this.dialect,this.options):this,r=new p(this.dialect,s);if(e){const t=this.getSetTransactionSQL(e);t&&await r.execute(t);const s=this.getStartTransactionSQL(e);await(s?r.execute(s):r.execute(l`begin`))}else await r.execute(l`begin`);try{const e=await t(r);return await r.execute(l`commit`),e}catch(t){throw await r.execute(l`rollback`),t}finally{g(this.client)&&s.client.release()}}}class p extends i{async transaction(t){const e=`sp${this.nestedIndex+1}`,s=new p(this.dialect,this.session,this.nestedIndex+1);await s.execute(l.raw(`savepoint ${e}`));try{const r=await t(s);return await s.execute(l.raw(`release savepoint ${e}`)),r}catch(t){throw await s.execute(l.raw(`rollback to savepoint ${e}`)),t}}}function g(t){return"getConnection"in t}class m{constructor(t,e,s={}){this.client=t,this.dialect=e,this.options=s}createSession(){return new y(this.client,this.dialect,{logger:this.options.logger})}}function w(t,s={}){const r=new a;let i;!0===s.logger?i=new e:!1!==s.logger&&(i=s.logger),function(t){return"function"==typeof t.promise}(t)&&(t=t.promise());const o=new m(t,r,{logger:i}).createSession();return new n(r,o)}export{m as MySql2Driver,h as MySql2PreparedQuery,y as MySql2Session,p as MySql2Transaction,n as MySqlDatabase,w as drizzle};
1
+ import{N as t,D as e}from"../logger-2598bf05.mjs";import{P as s,t as r,u as i,g as n,h as a}from"../session-a87f051d.mjs";import{once as o}from"node:events";import{k as c,s as l}from"../index-b71998f1.mjs";import{m as u}from"../utils-e6870670.mjs";import"../query-promise-a65edd44.mjs";import"../column-builder-592f0191.mjs";import"../query-builder-2fcde2f0.mjs";class h extends s{constructor(t,e,s,r,i){super(),this.client=t,this.params=s,this.logger=r,this.fields=i,this.rawQuery={sql:e,typeCast:function(t,e){return"TIMESTAMP"===t.type||"DATETIME"===t.type||"DATE"===t.type?t.string():e()}},this.query={sql:e,rowsAsArray:!0,typeCast:function(t,e){return"TIMESTAMP"===t.type||"DATETIME"===t.type||"DATE"===t.type?t.string():e()}}}async execute(t={}){const e=c(this.params,t);this.logger.logQuery(this.rawQuery.sql,e);const{fields:s,client:r,rawQuery:i,query:n,joinsNotNullableMap:a}=this;if(!s)return r.query(i,e);return r.query(n,e).then((t=>t[0].map((t=>u(s,t,a)))))}async*iterator(t={}){const e=c(this.params,t),s=(g(this.client)?await this.client.getConnection():this.client).connection,{fields:r,query:i,rawQuery:n,joinsNotNullableMap:a,client:l}=this,h=(r?s.query(i,e):s.query(n,e)).stream();function y(){h.pause()}h.on("data",y);try{const t=o(h,"end"),e=o(h,"error");for(;;){h.resume();const s=await Promise.race([t,e,new Promise((t=>h.once("data",t)))]);if(void 0===s||Array.isArray(s)&&0===s.length)break;if(s instanceof Error)throw s;yield r?u(r,s,a):s}}finally{h.off("data",y),g(l)&&s.end()}}}class y extends r{constructor(e,s,r={}){super(s),this.client=e,this.options=r,this.logger=r.logger??new t}prepareQuery(t,e){return new h(this.client,t.sql,t.params,this.logger,e)}async query(t,e){this.logger.logQuery(t,e);return await this.client.query({sql:t,values:e,rowsAsArray:!0,typeCast:function(t,e){return"TIMESTAMP"===t.type||"DATETIME"===t.type||"DATE"===t.type?t.string():e()}})}all(t){const e=this.dialect.sqlToQuery(t);return this.logger.logQuery(e.sql,e.params),this.client.execute(e.sql,e.params).then((t=>t[0]))}async transaction(t,e){const s=g(this.client)?new y(await this.client.getConnection(),this.dialect,this.options):this,r=new p(this.dialect,s);if(e){const t=this.getSetTransactionSQL(e);t&&await r.execute(t);const s=this.getStartTransactionSQL(e);await(s?r.execute(s):r.execute(l`begin`))}else await r.execute(l`begin`);try{const e=await t(r);return await r.execute(l`commit`),e}catch(t){throw await r.execute(l`rollback`),t}finally{g(this.client)&&s.client.release()}}}class p extends i{async transaction(t){const e=`sp${this.nestedIndex+1}`,s=new p(this.dialect,this.session,this.nestedIndex+1);await s.execute(l.raw(`savepoint ${e}`));try{const r=await t(s);return await s.execute(l.raw(`release savepoint ${e}`)),r}catch(t){throw await s.execute(l.raw(`rollback to savepoint ${e}`)),t}}}function g(t){return"getConnection"in t}class m{constructor(t,e,s={}){this.client=t,this.dialect=e,this.options=s}createSession(){return new y(this.client,this.dialect,{logger:this.options.logger})}}function w(t,s={}){const r=new a;let i;!0===s.logger?i=new e:!1!==s.logger&&(i=s.logger),function(t){return"function"==typeof t.promise}(t)&&(t=t.promise());const o=new m(t,r,{logger:i}).createSession();return new n(r,o)}export{m as MySql2Driver,h as MySql2PreparedQuery,y as MySql2Session,p as MySql2Transaction,n as MySqlDatabase,w as drizzle};
2
2
  //# sourceMappingURL=index.mjs.map
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("@neondatabase/serverless"),t=require("../logger-04bad527.cjs"),s=require("../session-ef1ef979.cjs"),r=require("../index-59b7992d.cjs"),i=require("../utils-9d882195.cjs");require("../query-promise-2c5b43ab.cjs"),require("../query-builder-2f2e8229.cjs"),require("../column-builder-b48639f3.cjs");class n extends s.PreparedQuery{constructor(e,t,s,r,i,n){super(),this.client=e,this.params=s,this.logger=r,this.fields=i,this.rawQuery={name:n,text:t},this.query={name:n,text:t,rowMode:"array"}}execute(e={}){const t=r.fillPlaceholders(this.params,e);this.logger.logQuery(this.rawQuery.text,t);const{fields:s,client:n,rawQuery:a,query:o,joinsNotNullableMap:l}=this;if(!s)return n.query(a,t);return n.query(o,t).then((e=>e.rows.map((e=>i.mapResultRow(s,e,l)))))}all(e={}){const t=r.fillPlaceholders(this.params,e);return this.logger.logQuery(this.rawQuery.text,t),this.client.query(this.rawQuery,t).then((e=>e.rows))}values(e={}){const t=r.fillPlaceholders(this.params,e);return this.logger.logQuery(this.rawQuery.text,t),this.client.query(this.query,t).then((e=>e.rows))}}class a extends s.PgSession{constructor(e,s,r={}){super(s),this.client=e,this.options=r,this.logger=r.logger??new t.NoopLogger}prepareQuery(e,t,s){return new n(this.client,e.sql,e.params,this.logger,t,s)}async query(e,t){this.logger.logQuery(e,t);return await this.client.query({rowMode:"array",text:e,values:t})}async queryObjects(e,t){return this.client.query(e,t)}async transaction(t,s={}){const i=this.client instanceof e.Pool?new a(await this.client.connect(),this.dialect,this.options):this,n=new o(this.dialect,i);await n.execute(r.sql`begin ${n.getTransactionConfigSQL(s)}`);try{const e=await t(n);return await n.execute(r.sql`commit`),e}catch(e){throw await n.execute(r.sql`rollback`),e}finally{this.client instanceof e.Pool&&i.client.release()}}}class o extends s.PgTransaction{async transaction(e){const t=`sp${this.nestedIndex+1}`,s=new o(this.dialect,this.session,this.nestedIndex+1);await s.execute(r.sql.raw(`savepoint ${t}`));try{const i=await e(s);return await s.execute(r.sql.raw(`release savepoint ${t}`)),i}catch(e){throw await s.execute(r.sql.raw(`rollback to savepoint ${t}`)),e}}}class l{constructor(e,t,s={}){this.client=e,this.dialect=t,this.options=s,this.initMappers()}createSession(){return new a(this.client,this.dialect,{logger:this.options.logger})}initMappers(){e.types.setTypeParser(e.types.builtins.TIMESTAMPTZ,(e=>e)),e.types.setTypeParser(e.types.builtins.TIMESTAMP,(e=>e)),e.types.setTypeParser(e.types.builtins.DATE,(e=>e))}}exports.NeonDriver=l,exports.NeonPreparedQuery=n,exports.NeonSession=a,exports.NeonTransaction=o,exports.drizzle=function(e,r={}){const i=new s.PgDialect;let n;!0===r.logger?n=new t.DefaultLogger:!1!==r.logger&&(n=r.logger);const a=new l(e,i,{logger:n}).createSession();return new s.PgDatabase(i,a)};
1
+ "use strict";var e=require("@neondatabase/serverless"),t=require("../logger-04bad527.cjs"),s=require("../session-815af33e.cjs"),r=require("../index-59b7992d.cjs"),i=require("../utils-9d882195.cjs");require("../query-promise-2c5b43ab.cjs"),require("../query-builder-2f2e8229.cjs"),require("../column-builder-b48639f3.cjs");class n extends s.PreparedQuery{constructor(e,t,s,r,i,n){super(),this.client=e,this.params=s,this.logger=r,this.fields=i,this.rawQuery={name:n,text:t},this.query={name:n,text:t,rowMode:"array"}}execute(e={}){const t=r.fillPlaceholders(this.params,e);this.logger.logQuery(this.rawQuery.text,t);const{fields:s,client:n,rawQuery:a,query:o,joinsNotNullableMap:l}=this;if(!s)return n.query(a,t);return n.query(o,t).then((e=>e.rows.map((e=>i.mapResultRow(s,e,l)))))}all(e={}){const t=r.fillPlaceholders(this.params,e);return this.logger.logQuery(this.rawQuery.text,t),this.client.query(this.rawQuery,t).then((e=>e.rows))}values(e={}){const t=r.fillPlaceholders(this.params,e);return this.logger.logQuery(this.rawQuery.text,t),this.client.query(this.query,t).then((e=>e.rows))}}class a extends s.PgSession{constructor(e,s,r={}){super(s),this.client=e,this.options=r,this.logger=r.logger??new t.NoopLogger}prepareQuery(e,t,s){return new n(this.client,e.sql,e.params,this.logger,t,s)}async query(e,t){this.logger.logQuery(e,t);return await this.client.query({rowMode:"array",text:e,values:t})}async queryObjects(e,t){return this.client.query(e,t)}async transaction(t,s={}){const i=this.client instanceof e.Pool?new a(await this.client.connect(),this.dialect,this.options):this,n=new o(this.dialect,i);await n.execute(r.sql`begin ${n.getTransactionConfigSQL(s)}`);try{const e=await t(n);return await n.execute(r.sql`commit`),e}catch(e){throw await n.execute(r.sql`rollback`),e}finally{this.client instanceof e.Pool&&i.client.release()}}}class o extends s.PgTransaction{async transaction(e){const t=`sp${this.nestedIndex+1}`,s=new o(this.dialect,this.session,this.nestedIndex+1);await s.execute(r.sql.raw(`savepoint ${t}`));try{const i=await e(s);return await s.execute(r.sql.raw(`release savepoint ${t}`)),i}catch(e){throw await s.execute(r.sql.raw(`rollback to savepoint ${t}`)),e}}}class l{constructor(e,t,s={}){this.client=e,this.dialect=t,this.options=s,this.initMappers()}createSession(){return new a(this.client,this.dialect,{logger:this.options.logger})}initMappers(){e.types.setTypeParser(e.types.builtins.TIMESTAMPTZ,(e=>e)),e.types.setTypeParser(e.types.builtins.TIMESTAMP,(e=>e)),e.types.setTypeParser(e.types.builtins.DATE,(e=>e))}}exports.NeonDriver=l,exports.NeonPreparedQuery=n,exports.NeonSession=a,exports.NeonTransaction=o,exports.drizzle=function(e,r={}){const i=new s.PgDialect;let n;!0===r.logger?n=new t.DefaultLogger:!1!==r.logger&&(n=r.logger);const a=new l(e,i,{logger:n}).createSession();return new s.PgDatabase(i,a)};
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1,2 +1,2 @@
1
- import{Pool as e,types as t}from"@neondatabase/serverless";import{N as s,D as r}from"../logger-2598bf05.mjs";import{P as i,a,b as n,d as o,c}from"../session-c891400d.mjs";import{k as l,s as u}from"../index-b71998f1.mjs";import{m as h}from"../utils-e6870670.mjs";import"../query-promise-a65edd44.mjs";import"../query-builder-2fcde2f0.mjs";import"../column-builder-592f0191.mjs";class g extends i{constructor(e,t,s,r,i,a){super(),this.client=e,this.params=s,this.logger=r,this.fields=i,this.rawQuery={name:a,text:t},this.query={name:a,text:t,rowMode:"array"}}execute(e={}){const t=l(this.params,e);this.logger.logQuery(this.rawQuery.text,t);const{fields:s,client:r,rawQuery:i,query:a,joinsNotNullableMap:n}=this;if(!s)return r.query(i,t);return r.query(a,t).then((e=>e.rows.map((e=>h(s,e,n)))))}all(e={}){const t=l(this.params,e);return this.logger.logQuery(this.rawQuery.text,t),this.client.query(this.rawQuery,t).then((e=>e.rows))}values(e={}){const t=l(this.params,e);return this.logger.logQuery(this.rawQuery.text,t),this.client.query(this.query,t).then((e=>e.rows))}}class p extends a{constructor(e,t,r={}){super(t),this.client=e,this.options=r,this.logger=r.logger??new s}prepareQuery(e,t,s){return new g(this.client,e.sql,e.params,this.logger,t,s)}async query(e,t){this.logger.logQuery(e,t);return await this.client.query({rowMode:"array",text:e,values:t})}async queryObjects(e,t){return this.client.query(e,t)}async transaction(t,s={}){const r=this.client instanceof e?new p(await this.client.connect(),this.dialect,this.options):this,i=new w(this.dialect,r);await i.execute(u`begin ${i.getTransactionConfigSQL(s)}`);try{const e=await t(i);return await i.execute(u`commit`),e}catch(e){throw await i.execute(u`rollback`),e}finally{this.client instanceof e&&r.client.release()}}}class w extends n{async transaction(e){const t=`sp${this.nestedIndex+1}`,s=new w(this.dialect,this.session,this.nestedIndex+1);await s.execute(u.raw(`savepoint ${t}`));try{const r=await e(s);return await s.execute(u.raw(`release savepoint ${t}`)),r}catch(e){throw await s.execute(u.raw(`rollback to savepoint ${t}`)),e}}}class y{constructor(e,t,s={}){this.client=e,this.dialect=t,this.options=s,this.initMappers()}createSession(){return new p(this.client,this.dialect,{logger:this.options.logger})}initMappers(){t.setTypeParser(t.builtins.TIMESTAMPTZ,(e=>e)),t.setTypeParser(t.builtins.TIMESTAMP,(e=>e)),t.setTypeParser(t.builtins.DATE,(e=>e))}}function m(e,t={}){const s=new c;let i;!0===t.logger?i=new r:!1!==t.logger&&(i=t.logger);const a=new y(e,s,{logger:i}).createSession();return new o(s,a)}export{y as NeonDriver,g as NeonPreparedQuery,p as NeonSession,w as NeonTransaction,m as drizzle};
1
+ import{Pool as e,types as t}from"@neondatabase/serverless";import{N as s,D as r}from"../logger-2598bf05.mjs";import{P as i,a,b as n,d as o,c}from"../session-fdec872e.mjs";import{k as l,s as u}from"../index-b71998f1.mjs";import{m as h}from"../utils-e6870670.mjs";import"../query-promise-a65edd44.mjs";import"../query-builder-2fcde2f0.mjs";import"../column-builder-592f0191.mjs";class g extends i{constructor(e,t,s,r,i,a){super(),this.client=e,this.params=s,this.logger=r,this.fields=i,this.rawQuery={name:a,text:t},this.query={name:a,text:t,rowMode:"array"}}execute(e={}){const t=l(this.params,e);this.logger.logQuery(this.rawQuery.text,t);const{fields:s,client:r,rawQuery:i,query:a,joinsNotNullableMap:n}=this;if(!s)return r.query(i,t);return r.query(a,t).then((e=>e.rows.map((e=>h(s,e,n)))))}all(e={}){const t=l(this.params,e);return this.logger.logQuery(this.rawQuery.text,t),this.client.query(this.rawQuery,t).then((e=>e.rows))}values(e={}){const t=l(this.params,e);return this.logger.logQuery(this.rawQuery.text,t),this.client.query(this.query,t).then((e=>e.rows))}}class p extends a{constructor(e,t,r={}){super(t),this.client=e,this.options=r,this.logger=r.logger??new s}prepareQuery(e,t,s){return new g(this.client,e.sql,e.params,this.logger,t,s)}async query(e,t){this.logger.logQuery(e,t);return await this.client.query({rowMode:"array",text:e,values:t})}async queryObjects(e,t){return this.client.query(e,t)}async transaction(t,s={}){const r=this.client instanceof e?new p(await this.client.connect(),this.dialect,this.options):this,i=new w(this.dialect,r);await i.execute(u`begin ${i.getTransactionConfigSQL(s)}`);try{const e=await t(i);return await i.execute(u`commit`),e}catch(e){throw await i.execute(u`rollback`),e}finally{this.client instanceof e&&r.client.release()}}}class w extends n{async transaction(e){const t=`sp${this.nestedIndex+1}`,s=new w(this.dialect,this.session,this.nestedIndex+1);await s.execute(u.raw(`savepoint ${t}`));try{const r=await e(s);return await s.execute(u.raw(`release savepoint ${t}`)),r}catch(e){throw await s.execute(u.raw(`rollback to savepoint ${t}`)),e}}}class y{constructor(e,t,s={}){this.client=e,this.dialect=t,this.options=s,this.initMappers()}createSession(){return new p(this.client,this.dialect,{logger:this.options.logger})}initMappers(){t.setTypeParser(t.builtins.TIMESTAMPTZ,(e=>e)),t.setTypeParser(t.builtins.TIMESTAMP,(e=>e)),t.setTypeParser(t.builtins.DATE,(e=>e))}}function m(e,t={}){const s=new c;let i;!0===t.logger?i=new r:!1!==t.logger&&(i=t.logger);const a=new y(e,s,{logger:i}).createSession();return new o(s,a)}export{y as NeonDriver,g as NeonPreparedQuery,p as NeonSession,w as NeonTransaction,m as drizzle};
2
2
  //# sourceMappingURL=index.mjs.map
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("pg"),t=require("../logger-04bad527.cjs"),s=require("../session-ef1ef979.cjs"),r=require("../index-59b7992d.cjs"),i=require("../utils-9d882195.cjs");require("../query-promise-2c5b43ab.cjs"),require("../query-builder-2f2e8229.cjs"),require("../column-builder-b48639f3.cjs");const{Pool:n}=e;class a extends s.PreparedQuery{constructor(e,t,s,r,i,n){super(),this.client=e,this.params=s,this.logger=r,this.fields=i,this.rawQuery={name:n,text:t},this.query={name:n,text:t,rowMode:"array"}}execute(e={}){const t=r.fillPlaceholders(this.params,e);this.logger.logQuery(this.rawQuery.text,t);const{fields:s,rawQuery:n,client:a,query:o,joinsNotNullableMap:l}=this;if(!s)return a.query(n,t);return a.query(o,t).then((e=>e.rows.map((e=>i.mapResultRow(s,e,l)))))}all(e={}){const t=r.fillPlaceholders(this.params,e);return this.logger.logQuery(this.rawQuery.text,t),this.client.query(this.rawQuery,t).then((e=>e.rows))}values(e={}){const t=r.fillPlaceholders(this.params,e);return this.logger.logQuery(this.rawQuery.text,t),this.client.query(this.query,t).then((e=>e.rows))}}class o extends s.PgSession{constructor(e,s,r={}){super(s),this.client=e,this.options=r,this.logger=r.logger??new t.NoopLogger}prepareQuery(e,t,s){return new a(this.client,e.sql,e.params,this.logger,t,s)}async query(e,t){this.logger.logQuery(e,t);return await this.client.query({rowMode:"array",text:e,values:t})}async queryObjects(e,t){return this.client.query(e,t)}async transaction(e,t){const s=this.client instanceof n?new o(await this.client.connect(),this.dialect,this.options):this,i=new l(this.dialect,s);await i.execute(r.sql`begin${t?r.sql` ${i.getTransactionConfigSQL(t)}`:void 0}`);try{const t=await e(i);return await i.execute(r.sql`commit`),t}catch(e){throw await i.execute(r.sql`rollback`),e}finally{this.client instanceof n&&s.client.release()}}}class l extends s.PgTransaction{async transaction(e){const t=`sp${this.nestedIndex+1}`,s=new l(this.dialect,this.session,this.nestedIndex+1);await s.execute(r.sql.raw(`savepoint ${t}`));try{const i=await e(s);return await s.execute(r.sql.raw(`release savepoint ${t}`)),i}catch(e){throw await s.execute(r.sql.raw(`rollback to savepoint ${t}`)),e}}}const{types:c}=e;class u{constructor(e,t,s={}){this.client=e,this.dialect=t,this.options=s,this.initMappers()}createSession(){return new o(this.client,this.dialect,{logger:this.options.logger})}initMappers(){c.setTypeParser(c.builtins.TIMESTAMPTZ,(e=>e)),c.setTypeParser(c.builtins.TIMESTAMP,(e=>e)),c.setTypeParser(c.builtins.DATE,(e=>e))}}exports.NodePgDriver=u,exports.NodePgPreparedQuery=a,exports.NodePgSession=o,exports.NodePgTransaction=l,exports.drizzle=function(e,r={}){const i=new s.PgDialect;let n;!0===r.logger?n=new t.DefaultLogger:!1!==r.logger&&(n=r.logger);const a=new u(e,i,{logger:n}).createSession();return new s.PgDatabase(i,a)};
1
+ "use strict";var e=require("pg"),t=require("../logger-04bad527.cjs"),s=require("../session-815af33e.cjs"),r=require("../index-59b7992d.cjs"),i=require("../utils-9d882195.cjs");require("../query-promise-2c5b43ab.cjs"),require("../query-builder-2f2e8229.cjs"),require("../column-builder-b48639f3.cjs");const{Pool:n}=e;class a extends s.PreparedQuery{constructor(e,t,s,r,i,n){super(),this.client=e,this.params=s,this.logger=r,this.fields=i,this.rawQuery={name:n,text:t},this.query={name:n,text:t,rowMode:"array"}}execute(e={}){const t=r.fillPlaceholders(this.params,e);this.logger.logQuery(this.rawQuery.text,t);const{fields:s,rawQuery:n,client:a,query:o,joinsNotNullableMap:l}=this;if(!s)return a.query(n,t);return a.query(o,t).then((e=>e.rows.map((e=>i.mapResultRow(s,e,l)))))}all(e={}){const t=r.fillPlaceholders(this.params,e);return this.logger.logQuery(this.rawQuery.text,t),this.client.query(this.rawQuery,t).then((e=>e.rows))}values(e={}){const t=r.fillPlaceholders(this.params,e);return this.logger.logQuery(this.rawQuery.text,t),this.client.query(this.query,t).then((e=>e.rows))}}class o extends s.PgSession{constructor(e,s,r={}){super(s),this.client=e,this.options=r,this.logger=r.logger??new t.NoopLogger}prepareQuery(e,t,s){return new a(this.client,e.sql,e.params,this.logger,t,s)}async query(e,t){this.logger.logQuery(e,t);return await this.client.query({rowMode:"array",text:e,values:t})}async queryObjects(e,t){return this.client.query(e,t)}async transaction(e,t){const s=this.client instanceof n?new o(await this.client.connect(),this.dialect,this.options):this,i=new l(this.dialect,s);await i.execute(r.sql`begin${t?r.sql` ${i.getTransactionConfigSQL(t)}`:void 0}`);try{const t=await e(i);return await i.execute(r.sql`commit`),t}catch(e){throw await i.execute(r.sql`rollback`),e}finally{this.client instanceof n&&s.client.release()}}}class l extends s.PgTransaction{async transaction(e){const t=`sp${this.nestedIndex+1}`,s=new l(this.dialect,this.session,this.nestedIndex+1);await s.execute(r.sql.raw(`savepoint ${t}`));try{const i=await e(s);return await s.execute(r.sql.raw(`release savepoint ${t}`)),i}catch(e){throw await s.execute(r.sql.raw(`rollback to savepoint ${t}`)),e}}}const{types:c}=e;class u{constructor(e,t,s={}){this.client=e,this.dialect=t,this.options=s,this.initMappers()}createSession(){return new o(this.client,this.dialect,{logger:this.options.logger})}initMappers(){c.setTypeParser(c.builtins.TIMESTAMPTZ,(e=>e)),c.setTypeParser(c.builtins.TIMESTAMP,(e=>e)),c.setTypeParser(c.builtins.DATE,(e=>e))}}exports.NodePgDriver=u,exports.NodePgPreparedQuery=a,exports.NodePgSession=o,exports.NodePgTransaction=l,exports.drizzle=function(e,r={}){const i=new s.PgDialect;let n;!0===r.logger?n=new t.DefaultLogger:!1!==r.logger&&(n=r.logger);const a=new u(e,i,{logger:n}).createSession();return new s.PgDatabase(i,a)};
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1,2 +1,2 @@
1
- import t from"pg";import{N as e,D as s}from"../logger-2598bf05.mjs";import{P as r,a as i,b as n,d as a,c as o}from"../session-c891400d.mjs";import{k as c,s as l}from"../index-b71998f1.mjs";import{m as u}from"../utils-e6870670.mjs";import"../query-promise-a65edd44.mjs";import"../query-builder-2fcde2f0.mjs";import"../column-builder-592f0191.mjs";const{Pool:h}=t;class g extends r{constructor(t,e,s,r,i,n){super(),this.client=t,this.params=s,this.logger=r,this.fields=i,this.rawQuery={name:n,text:e},this.query={name:n,text:e,rowMode:"array"}}execute(t={}){const e=c(this.params,t);this.logger.logQuery(this.rawQuery.text,e);const{fields:s,rawQuery:r,client:i,query:n,joinsNotNullableMap:a}=this;if(!s)return i.query(r,e);return i.query(n,e).then((t=>t.rows.map((t=>u(s,t,a)))))}all(t={}){const e=c(this.params,t);return this.logger.logQuery(this.rawQuery.text,e),this.client.query(this.rawQuery,e).then((t=>t.rows))}values(t={}){const e=c(this.params,t);return this.logger.logQuery(this.rawQuery.text,e),this.client.query(this.query,e).then((t=>t.rows))}}class p extends i{constructor(t,s,r={}){super(s),this.client=t,this.options=r,this.logger=r.logger??new e}prepareQuery(t,e,s){return new g(this.client,t.sql,t.params,this.logger,e,s)}async query(t,e){this.logger.logQuery(t,e);return await this.client.query({rowMode:"array",text:t,values:e})}async queryObjects(t,e){return this.client.query(t,e)}async transaction(t,e){const s=this.client instanceof h?new p(await this.client.connect(),this.dialect,this.options):this,r=new y(this.dialect,s);await r.execute(l`begin${e?l` ${r.getTransactionConfigSQL(e)}`:void 0}`);try{const e=await t(r);return await r.execute(l`commit`),e}catch(t){throw await r.execute(l`rollback`),t}finally{this.client instanceof h&&s.client.release()}}}class y extends n{async transaction(t){const e=`sp${this.nestedIndex+1}`,s=new y(this.dialect,this.session,this.nestedIndex+1);await s.execute(l.raw(`savepoint ${e}`));try{const r=await t(s);return await s.execute(l.raw(`release savepoint ${e}`)),r}catch(t){throw await s.execute(l.raw(`rollback to savepoint ${e}`)),t}}}const{types:w}=t;class m{constructor(t,e,s={}){this.client=t,this.dialect=e,this.options=s,this.initMappers()}createSession(){return new p(this.client,this.dialect,{logger:this.options.logger})}initMappers(){w.setTypeParser(w.builtins.TIMESTAMPTZ,(t=>t)),w.setTypeParser(w.builtins.TIMESTAMP,(t=>t)),w.setTypeParser(w.builtins.DATE,(t=>t))}}function d(t,e={}){const r=new o;let i;!0===e.logger?i=new s:!1!==e.logger&&(i=e.logger);const n=new m(t,r,{logger:i}).createSession();return new a(r,n)}export{m as NodePgDriver,g as NodePgPreparedQuery,p as NodePgSession,y as NodePgTransaction,d as drizzle};
1
+ import t from"pg";import{N as e,D as s}from"../logger-2598bf05.mjs";import{P as r,a as i,b as n,d as a,c as o}from"../session-fdec872e.mjs";import{k as c,s as l}from"../index-b71998f1.mjs";import{m as u}from"../utils-e6870670.mjs";import"../query-promise-a65edd44.mjs";import"../query-builder-2fcde2f0.mjs";import"../column-builder-592f0191.mjs";const{Pool:h}=t;class g extends r{constructor(t,e,s,r,i,n){super(),this.client=t,this.params=s,this.logger=r,this.fields=i,this.rawQuery={name:n,text:e},this.query={name:n,text:e,rowMode:"array"}}execute(t={}){const e=c(this.params,t);this.logger.logQuery(this.rawQuery.text,e);const{fields:s,rawQuery:r,client:i,query:n,joinsNotNullableMap:a}=this;if(!s)return i.query(r,e);return i.query(n,e).then((t=>t.rows.map((t=>u(s,t,a)))))}all(t={}){const e=c(this.params,t);return this.logger.logQuery(this.rawQuery.text,e),this.client.query(this.rawQuery,e).then((t=>t.rows))}values(t={}){const e=c(this.params,t);return this.logger.logQuery(this.rawQuery.text,e),this.client.query(this.query,e).then((t=>t.rows))}}class p extends i{constructor(t,s,r={}){super(s),this.client=t,this.options=r,this.logger=r.logger??new e}prepareQuery(t,e,s){return new g(this.client,t.sql,t.params,this.logger,e,s)}async query(t,e){this.logger.logQuery(t,e);return await this.client.query({rowMode:"array",text:t,values:e})}async queryObjects(t,e){return this.client.query(t,e)}async transaction(t,e){const s=this.client instanceof h?new p(await this.client.connect(),this.dialect,this.options):this,r=new y(this.dialect,s);await r.execute(l`begin${e?l` ${r.getTransactionConfigSQL(e)}`:void 0}`);try{const e=await t(r);return await r.execute(l`commit`),e}catch(t){throw await r.execute(l`rollback`),t}finally{this.client instanceof h&&s.client.release()}}}class y extends n{async transaction(t){const e=`sp${this.nestedIndex+1}`,s=new y(this.dialect,this.session,this.nestedIndex+1);await s.execute(l.raw(`savepoint ${e}`));try{const r=await t(s);return await s.execute(l.raw(`release savepoint ${e}`)),r}catch(t){throw await s.execute(l.raw(`rollback to savepoint ${e}`)),t}}}const{types:w}=t;class m{constructor(t,e,s={}){this.client=t,this.dialect=e,this.options=s,this.initMappers()}createSession(){return new p(this.client,this.dialect,{logger:this.options.logger})}initMappers(){w.setTypeParser(w.builtins.TIMESTAMPTZ,(t=>t)),w.setTypeParser(w.builtins.TIMESTAMP,(t=>t)),w.setTypeParser(w.builtins.DATE,(t=>t))}}function d(t,e={}){const r=new o;let i;!0===e.logger?i=new s:!1!==e.logger&&(i=e.logger);const n=new m(t,r,{logger:i}).createSession();return new a(r,n)}export{m as NodePgDriver,g as NodePgPreparedQuery,p as NodePgSession,y as NodePgTransaction,d as drizzle};
2
2
  //# sourceMappingURL=index.mjs.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drizzle-orm",
3
- "version": "0.25.4",
3
+ "version": "0.25.5-ee7217a",
4
4
  "description": "Drizzle ORM package for SQL databases",
5
5
  "type": "module",
6
6
  "scripts": {
package/pg-core/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("../index-59b7992d.cjs"),r=require("../session-ef1ef979.cjs");require("../utils-9d882195.cjs"),require("../query-promise-2c5b43ab.cjs"),require("../query-builder-2f2e8229.cjs"),require("../column-builder-b48639f3.cjs");class t extends r.PgColumnBuilder{build(e){return new i(e,this.config)}}class i extends r.PgColumn{getSQLType(){return"bigint"}mapFromDriverValue(e){return"number"==typeof e?e:Number(e)}}class s extends r.PgColumnBuilder{build(e){return new n(e,this.config)}}class n extends r.PgColumn{getSQLType(){return"bigint"}mapFromDriverValue(e){return BigInt(e)}}class o extends r.PgColumnBuilder{constructor(e){super(e),this.config.hasDefault=!0,this.config.notNull=!0}build(e){return new u(e,this.config)}}class u extends r.PgColumn{getSQLType(){return"bigserial"}mapFromDriverValue(e){return"number"==typeof e?e:Number(e)}}class l extends r.PgColumnBuilder{constructor(e){super(e),this.config.hasDefault=!0}build(e){return new a(e,this.config)}}class a extends r.PgColumn{getSQLType(){return"bigserial"}mapFromDriverValue(e){return BigInt(e)}}class g extends r.PgColumnBuilder{build(e){return new p(e,this.config)}}class p extends r.PgColumn{getSQLType(){return"boolean"}}class c extends r.PgColumnBuilder{constructor(e,r){super(e),this.config.length=r.length,this.config.enumValues=r.enum??[]}build(e){return new d(e,this.config)}}class d extends r.PgColumn{constructor(){super(...arguments),this.length=this.config.length,this.enumValues=this.config.enumValues}getSQLType(){return void 0===this.length?"char":`char(${this.length})`}}class m extends r.PgColumnBuilder{build(e){return new x(e,this.config)}}class x extends r.PgColumn{getSQLType(){return"cidr"}}class P extends r.PgColumnBuilder{constructor(e,r,t){super(e),this.config.fieldConfig=r,this.config.customTypeParams=t}build(e){return new h(e,this.config)}}class h extends r.PgColumn{constructor(e,r){super(e,r),this.sqlName=r.customTypeParams.dataType(r.fieldConfig),this.mapTo=r.customTypeParams.toDriver,this.mapFrom=r.customTypeParams.fromDriver}getSQLType(){return this.sqlName}mapFromDriverValue(e){return"function"==typeof this.mapFrom?this.mapFrom(e):e}mapToDriverValue(e){return"function"==typeof this.mapTo?this.mapTo(e):e}}class f extends r.PgColumnBuilder{build(e){return new B(e,this.config)}}class B extends r.PgColumn{getSQLType(){return"double precision"}mapFromDriverValue(e){return"string"==typeof e?Number.parseFloat(e):e}}const w=Symbol("isPgEnum");class C extends r.PgColumnBuilder{constructor(e,r){super(e),this.config.enum=r}build(e){return new y(e,this.config)}}class y extends r.PgColumn{constructor(e,r){super(e,r),this.enum=this.config.enum,this.enumValues=this.config.enum.enumValues,this.enum=r.enum}getSQLType(){return this.enum.enumName}}class b extends r.PgColumnBuilder{build(e){return new V(e,this.config)}}class V extends r.PgColumn{getSQLType(){return"inet"}}class S extends r.PgColumnBuilder{build(e){return new T(e,this.config)}}class T extends r.PgColumn{getSQLType(){return"integer"}mapFromDriverValue(e){return"string"==typeof e?Number.parseInt(e):e}}class D extends r.PgColumnBuilder{constructor(e,r){super(e),this.config.intervalConfig=r}build(e){return new I(e,this.config)}}class I extends r.PgColumn{constructor(){super(...arguments),this.fields=this.config.intervalConfig.fields,this.precision=this.config.intervalConfig.precision}getSQLType(){return`interval${this.fields?` ${this.fields}`:""}${this.precision?`(${this.precision})`:""}`}}class M extends r.PgColumnBuilder{build(e){return new Q(e,this.config)}}class Q extends r.PgColumn{getSQLType(){return"macaddr"}}class v extends r.PgColumnBuilder{build(e){return new N(e,this.config)}}class N extends r.PgColumn{getSQLType(){return"macaddr8"}}class L extends r.PgColumnBuilder{constructor(e,r){super(e),this.config.length=r}build(e){return new z(e,this.config)}}class z extends r.PgColumn{constructor(e,r){super(e,r),this.mapFromDriverValue=e=>"string"==typeof e?Number.parseFloat(e):e}getSQLType(){return"real"}}class F extends r.PgColumnBuilder{constructor(e){super(e),this.config.hasDefault=!0,this.config.notNull=!0}build(e){return new K(e,this.config)}}class K extends r.PgColumn{getSQLType(){return"serial"}}class j extends r.PgColumnBuilder{build(e){return new q(e,this.config)}}class q extends r.PgColumn{constructor(){super(...arguments),this.mapFromDriverValue=e=>"string"==typeof e?Number(e):e}getSQLType(){return"smallint"}}class U extends r.PgColumnBuilder{constructor(e){super(e),this.config.hasDefault=!0,this.config.notNull=!0}build(e){return new A(e,this.config)}}class A extends r.PgColumn{getSQLType(){return"serial"}}class W extends r.PgColumnBuilder{constructor(e,r){super(e),this.config.enumValues=r.enum??[]}build(e){return new k(e,this.config)}}class k extends r.PgColumn{constructor(){super(...arguments),this.enumValues=this.config.enumValues}getSQLType(){return"text"}}class E extends r.PgColumnBuilder{constructor(e,r){super(e),this.config.length=r.length,this.config.enumValues=r.enum??[]}build(e){return new J(e,this.config)}}class J extends r.PgColumn{constructor(){super(...arguments),this.length=this.config.length,this.enumValues=this.config.enumValues}getSQLType(){return void 0===this.length?"varchar":`varchar(${this.length})`}}class ${constructor(e){this.schemaName=e,this.table=(e,t,i)=>r.pgTableWithSchema(e,t,i,this.schemaName),this.view=(e,t)=>r.pgViewWithSchema(e,t,this.schemaName),this.materializedView=(e,t)=>r.pgMaterializedViewWithSchema(e,t,this.schemaName)}}exports.Check=r.Check,exports.CheckBuilder=r.CheckBuilder,exports.DefaultViewBuilderCore=r.DefaultViewBuilderCore,exports.ExtraConfigBuilder=r.ExtraConfigBuilder,exports.ForeignKey=r.ForeignKey,exports.ForeignKeyBuilder=r.ForeignKeyBuilder,exports.Index=r.Index,exports.IndexBuilder=r.IndexBuilder,exports.IndexBuilderOn=r.IndexBuilderOn,exports.InlineForeignKeys=r.InlineForeignKeys,exports.ManualMaterializedViewBuilder=r.ManualMaterializedViewBuilder,exports.ManualViewBuilder=r.ManualViewBuilder,exports.MaterializedViewBuilder=r.MaterializedViewBuilder,exports.MaterializedViewBuilderCore=r.MaterializedViewBuilderCore,exports.PgArray=r.PgArray,exports.PgArrayBuilder=r.PgArrayBuilder,exports.PgColumn=r.PgColumn,exports.PgColumnBuilder=r.PgColumnBuilder,exports.PgDatabase=r.PgDatabase,exports.PgDate=r.PgDate,exports.PgDateBuilder=r.PgDateBuilder,exports.PgDateString=r.PgDateString,exports.PgDateStringBuilder=r.PgDateStringBuilder,exports.PgDelete=r.PgDelete,exports.PgDialect=r.PgDialect,exports.PgInsert=r.PgInsert,exports.PgInsertBuilder=r.PgInsertBuilder,exports.PgJson=r.PgJson,exports.PgJsonBuilder=r.PgJsonBuilder,exports.PgJsonb=r.PgJsonb,exports.PgJsonbBuilder=r.PgJsonbBuilder,exports.PgMaterializedView=r.PgMaterializedView,exports.PgMaterializedViewConfig=r.PgMaterializedViewConfig,exports.PgNumeric=r.PgNumeric,exports.PgNumericBuilder=r.PgNumericBuilder,exports.PgRefreshMaterializedView=r.PgRefreshMaterializedView,exports.PgSelect=r.PgSelect,exports.PgSelectBuilder=r.PgSelectBuilder,exports.PgSelectQueryBuilder=r.PgSelectQueryBuilder,exports.PgSession=r.PgSession,exports.PgTable=r.PgTable,exports.PgTime=r.PgTime,exports.PgTimeBuilder=r.PgTimeBuilder,exports.PgTimestamp=r.PgTimestamp,exports.PgTimestampBuilder=r.PgTimestampBuilder,exports.PgTimestampString=r.PgTimestampString,exports.PgTimestampStringBuilder=r.PgTimestampStringBuilder,exports.PgTransaction=r.PgTransaction,exports.PgUUID=r.PgUUID,exports.PgUUIDBuilder=r.PgUUIDBuilder,exports.PgUpdate=r.PgUpdate,exports.PgUpdateBuilder=r.PgUpdateBuilder,exports.PgView=r.PgView,exports.PgViewBase=r.PgViewBase,exports.PgViewConfig=r.PgViewConfig,exports.PreparedQuery=r.PreparedQuery,exports.PrimaryKey=r.PrimaryKey,exports.PrimaryKeyBuilder=r.PrimaryKeyBuilder,exports.QueryBuilder=r.QueryBuilder,exports.ViewBuilder=r.ViewBuilder,exports.check=r.check,exports.date=r.date,exports.decimal=r.decimal,exports.foreignKey=r.foreignKey,exports.getMaterializedViewConfig=r.getMaterializedViewConfig,exports.getTableConfig=r.getTableConfig,exports.getViewConfig=r.getViewConfig,exports.index=r.index,exports.json=r.json,exports.jsonb=r.jsonb,exports.makePgArray=r.makePgArray,exports.numeric=r.numeric,exports.parsePgArray=r.parsePgArray,exports.parsePgNestedArray=r.parsePgNestedArray,exports.pgMaterializedView=r.pgMaterializedView,exports.pgMaterializedViewWithSchema=r.pgMaterializedViewWithSchema,exports.pgTable=r.pgTable,exports.pgTableCreator=r.pgTableCreator,exports.pgTableWithSchema=r.pgTableWithSchema,exports.pgView=r.pgView,exports.pgViewWithSchema=r.pgViewWithSchema,exports.primaryKey=r.primaryKey,exports.time=r.time,exports.timestamp=r.timestamp,exports.uniqueIndex=r.uniqueIndex,exports.uuid=r.uuid,exports.PgBigInt53=i,exports.PgBigInt53Builder=t,exports.PgBigInt64=n,exports.PgBigInt64Builder=s,exports.PgBigSerial53=u,exports.PgBigSerial53Builder=o,exports.PgBigSerial64=a,exports.PgBigSerial64Builder=l,exports.PgBoolean=p,exports.PgBooleanBuilder=g,exports.PgChar=d,exports.PgCharBuilder=c,exports.PgCidr=x,exports.PgCidrBuilder=m,exports.PgCustomColumn=h,exports.PgCustomColumnBuilder=P,exports.PgDoublePrecision=B,exports.PgDoublePrecisionBuilder=f,exports.PgEnumColumn=y,exports.PgEnumColumnBuilder=C,exports.PgInet=V,exports.PgInetBuilder=b,exports.PgInteger=T,exports.PgIntegerBuilder=S,exports.PgInterval=I,exports.PgIntervalBuilder=D,exports.PgMacaddr=Q,exports.PgMacaddr8=N,exports.PgMacaddr8Builder=v,exports.PgMacaddrBuilder=M,exports.PgReal=z,exports.PgRealBuilder=L,exports.PgSchema=$,exports.PgSerial=K,exports.PgSerialBuilder=F,exports.PgSmallInt=q,exports.PgSmallIntBuilder=j,exports.PgSmallSerial=A,exports.PgSmallSerialBuilder=U,exports.PgText=k,exports.PgTextBuilder=W,exports.PgVarchar=J,exports.PgVarcharBuilder=E,exports.alias=function(r,t){return new Proxy(r,new e.TableAliasProxyHandler(t,!1))},exports.bigint=function(e,r){return"number"===r.mode?new t(e):new s(e)},exports.bigserial=function(e,{mode:r}){return"number"===r?new o(e):new l(e)},exports.boolean=function(e){return new g(e)},exports.char=function(e,r={}){return new c(e,r)},exports.cidr=function(e){return new m(e)},exports.customType=function(e){return(r,t)=>new P(r,t,e)},exports.doublePrecision=function(e){return new f(e)},exports.inet=function(e){return new b(e)},exports.integer=function(e){return new S(e)},exports.interval=function(e,r={}){return new D(e,r)},exports.isPgEnum=function(e){return!!e&&"function"==typeof e&&w in e},exports.isPgSchema=function(e){return e instanceof $},exports.macaddr=function(e){return new M(e)},exports.macaddr8=function(e){return new v(e)},exports.pgEnum=function(e,r){const t=Object.assign((e=>new C(e,t)),{enumName:e,enumValues:r,[w]:!0});return t},exports.pgSchema=function(e){if("public"===e)throw new Error("You can't specify 'public' as schema name. Postgres is using public schema by default. If you want to use 'public' schema, just use pgTable() instead of creating a schema");return new $(e)},exports.real=function(e){return new L(e)},exports.serial=function(e){return new F(e)},exports.smallint=function(e){return new j(e)},exports.smallserial=function(e){return new U(e)},exports.text=function(e,r={}){return new W(e,r)},exports.varchar=function(e,r={}){return new E(e,r)};
1
+ "use strict";var e=require("../index-59b7992d.cjs"),r=require("../session-815af33e.cjs");require("../utils-9d882195.cjs"),require("../query-promise-2c5b43ab.cjs"),require("../query-builder-2f2e8229.cjs"),require("../column-builder-b48639f3.cjs");class t extends r.PgColumnBuilder{build(e){return new i(e,this.config)}}class i extends r.PgColumn{getSQLType(){return"bigint"}mapFromDriverValue(e){return"number"==typeof e?e:Number(e)}}class s extends r.PgColumnBuilder{build(e){return new n(e,this.config)}}class n extends r.PgColumn{getSQLType(){return"bigint"}mapFromDriverValue(e){return BigInt(e)}}class o extends r.PgColumnBuilder{constructor(e){super(e),this.config.hasDefault=!0,this.config.notNull=!0}build(e){return new u(e,this.config)}}class u extends r.PgColumn{getSQLType(){return"bigserial"}mapFromDriverValue(e){return"number"==typeof e?e:Number(e)}}class l extends r.PgColumnBuilder{constructor(e){super(e),this.config.hasDefault=!0}build(e){return new a(e,this.config)}}class a extends r.PgColumn{getSQLType(){return"bigserial"}mapFromDriverValue(e){return BigInt(e)}}class g extends r.PgColumnBuilder{build(e){return new p(e,this.config)}}class p extends r.PgColumn{getSQLType(){return"boolean"}}class c extends r.PgColumnBuilder{constructor(e,r){super(e),this.config.length=r.length,this.config.enumValues=r.enum??[]}build(e){return new d(e,this.config)}}class d extends r.PgColumn{constructor(){super(...arguments),this.length=this.config.length,this.enumValues=this.config.enumValues}getSQLType(){return void 0===this.length?"char":`char(${this.length})`}}class m extends r.PgColumnBuilder{build(e){return new x(e,this.config)}}class x extends r.PgColumn{getSQLType(){return"cidr"}}class P extends r.PgColumnBuilder{constructor(e,r,t){super(e),this.config.fieldConfig=r,this.config.customTypeParams=t}build(e){return new h(e,this.config)}}class h extends r.PgColumn{constructor(e,r){super(e,r),this.sqlName=r.customTypeParams.dataType(r.fieldConfig),this.mapTo=r.customTypeParams.toDriver,this.mapFrom=r.customTypeParams.fromDriver}getSQLType(){return this.sqlName}mapFromDriverValue(e){return"function"==typeof this.mapFrom?this.mapFrom(e):e}mapToDriverValue(e){return"function"==typeof this.mapTo?this.mapTo(e):e}}class f extends r.PgColumnBuilder{build(e){return new B(e,this.config)}}class B extends r.PgColumn{getSQLType(){return"double precision"}mapFromDriverValue(e){return"string"==typeof e?Number.parseFloat(e):e}}const w=Symbol("isPgEnum");class C extends r.PgColumnBuilder{constructor(e,r){super(e),this.config.enum=r}build(e){return new y(e,this.config)}}class y extends r.PgColumn{constructor(e,r){super(e,r),this.enum=this.config.enum,this.enumValues=this.config.enum.enumValues,this.enum=r.enum}getSQLType(){return this.enum.enumName}}class b extends r.PgColumnBuilder{build(e){return new V(e,this.config)}}class V extends r.PgColumn{getSQLType(){return"inet"}}class S extends r.PgColumnBuilder{build(e){return new T(e,this.config)}}class T extends r.PgColumn{getSQLType(){return"integer"}mapFromDriverValue(e){return"string"==typeof e?Number.parseInt(e):e}}class D extends r.PgColumnBuilder{constructor(e,r){super(e),this.config.intervalConfig=r}build(e){return new I(e,this.config)}}class I extends r.PgColumn{constructor(){super(...arguments),this.fields=this.config.intervalConfig.fields,this.precision=this.config.intervalConfig.precision}getSQLType(){return`interval${this.fields?` ${this.fields}`:""}${this.precision?`(${this.precision})`:""}`}}class M extends r.PgColumnBuilder{build(e){return new Q(e,this.config)}}class Q extends r.PgColumn{getSQLType(){return"macaddr"}}class v extends r.PgColumnBuilder{build(e){return new N(e,this.config)}}class N extends r.PgColumn{getSQLType(){return"macaddr8"}}class L extends r.PgColumnBuilder{constructor(e,r){super(e),this.config.length=r}build(e){return new z(e,this.config)}}class z extends r.PgColumn{constructor(e,r){super(e,r),this.mapFromDriverValue=e=>"string"==typeof e?Number.parseFloat(e):e}getSQLType(){return"real"}}class F extends r.PgColumnBuilder{constructor(e){super(e),this.config.hasDefault=!0,this.config.notNull=!0}build(e){return new K(e,this.config)}}class K extends r.PgColumn{getSQLType(){return"serial"}}class j extends r.PgColumnBuilder{build(e){return new q(e,this.config)}}class q extends r.PgColumn{constructor(){super(...arguments),this.mapFromDriverValue=e=>"string"==typeof e?Number(e):e}getSQLType(){return"smallint"}}class U extends r.PgColumnBuilder{constructor(e){super(e),this.config.hasDefault=!0,this.config.notNull=!0}build(e){return new A(e,this.config)}}class A extends r.PgColumn{getSQLType(){return"serial"}}class W extends r.PgColumnBuilder{constructor(e,r){super(e),this.config.enumValues=r.enum??[]}build(e){return new k(e,this.config)}}class k extends r.PgColumn{constructor(){super(...arguments),this.enumValues=this.config.enumValues}getSQLType(){return"text"}}class E extends r.PgColumnBuilder{constructor(e,r){super(e),this.config.length=r.length,this.config.enumValues=r.enum??[]}build(e){return new J(e,this.config)}}class J extends r.PgColumn{constructor(){super(...arguments),this.length=this.config.length,this.enumValues=this.config.enumValues}getSQLType(){return void 0===this.length?"varchar":`varchar(${this.length})`}}class ${constructor(e){this.schemaName=e,this.table=(e,t,i)=>r.pgTableWithSchema(e,t,i,this.schemaName),this.view=(e,t)=>r.pgViewWithSchema(e,t,this.schemaName),this.materializedView=(e,t)=>r.pgMaterializedViewWithSchema(e,t,this.schemaName)}}exports.Check=r.Check,exports.CheckBuilder=r.CheckBuilder,exports.DefaultViewBuilderCore=r.DefaultViewBuilderCore,exports.ExtraConfigBuilder=r.ExtraConfigBuilder,exports.ForeignKey=r.ForeignKey,exports.ForeignKeyBuilder=r.ForeignKeyBuilder,exports.Index=r.Index,exports.IndexBuilder=r.IndexBuilder,exports.IndexBuilderOn=r.IndexBuilderOn,exports.InlineForeignKeys=r.InlineForeignKeys,exports.ManualMaterializedViewBuilder=r.ManualMaterializedViewBuilder,exports.ManualViewBuilder=r.ManualViewBuilder,exports.MaterializedViewBuilder=r.MaterializedViewBuilder,exports.MaterializedViewBuilderCore=r.MaterializedViewBuilderCore,exports.PgArray=r.PgArray,exports.PgArrayBuilder=r.PgArrayBuilder,exports.PgColumn=r.PgColumn,exports.PgColumnBuilder=r.PgColumnBuilder,exports.PgDatabase=r.PgDatabase,exports.PgDate=r.PgDate,exports.PgDateBuilder=r.PgDateBuilder,exports.PgDateString=r.PgDateString,exports.PgDateStringBuilder=r.PgDateStringBuilder,exports.PgDelete=r.PgDelete,exports.PgDialect=r.PgDialect,exports.PgInsert=r.PgInsert,exports.PgInsertBuilder=r.PgInsertBuilder,exports.PgJson=r.PgJson,exports.PgJsonBuilder=r.PgJsonBuilder,exports.PgJsonb=r.PgJsonb,exports.PgJsonbBuilder=r.PgJsonbBuilder,exports.PgMaterializedView=r.PgMaterializedView,exports.PgMaterializedViewConfig=r.PgMaterializedViewConfig,exports.PgNumeric=r.PgNumeric,exports.PgNumericBuilder=r.PgNumericBuilder,exports.PgRefreshMaterializedView=r.PgRefreshMaterializedView,exports.PgSelect=r.PgSelect,exports.PgSelectBuilder=r.PgSelectBuilder,exports.PgSelectQueryBuilder=r.PgSelectQueryBuilder,exports.PgSession=r.PgSession,exports.PgTable=r.PgTable,exports.PgTime=r.PgTime,exports.PgTimeBuilder=r.PgTimeBuilder,exports.PgTimestamp=r.PgTimestamp,exports.PgTimestampBuilder=r.PgTimestampBuilder,exports.PgTimestampString=r.PgTimestampString,exports.PgTimestampStringBuilder=r.PgTimestampStringBuilder,exports.PgTransaction=r.PgTransaction,exports.PgUUID=r.PgUUID,exports.PgUUIDBuilder=r.PgUUIDBuilder,exports.PgUpdate=r.PgUpdate,exports.PgUpdateBuilder=r.PgUpdateBuilder,exports.PgView=r.PgView,exports.PgViewBase=r.PgViewBase,exports.PgViewConfig=r.PgViewConfig,exports.PreparedQuery=r.PreparedQuery,exports.PrimaryKey=r.PrimaryKey,exports.PrimaryKeyBuilder=r.PrimaryKeyBuilder,exports.QueryBuilder=r.QueryBuilder,exports.ViewBuilder=r.ViewBuilder,exports.check=r.check,exports.date=r.date,exports.decimal=r.decimal,exports.foreignKey=r.foreignKey,exports.getMaterializedViewConfig=r.getMaterializedViewConfig,exports.getTableConfig=r.getTableConfig,exports.getViewConfig=r.getViewConfig,exports.index=r.index,exports.json=r.json,exports.jsonb=r.jsonb,exports.makePgArray=r.makePgArray,exports.numeric=r.numeric,exports.parsePgArray=r.parsePgArray,exports.parsePgNestedArray=r.parsePgNestedArray,exports.pgMaterializedView=r.pgMaterializedView,exports.pgMaterializedViewWithSchema=r.pgMaterializedViewWithSchema,exports.pgTable=r.pgTable,exports.pgTableCreator=r.pgTableCreator,exports.pgTableWithSchema=r.pgTableWithSchema,exports.pgView=r.pgView,exports.pgViewWithSchema=r.pgViewWithSchema,exports.primaryKey=r.primaryKey,exports.time=r.time,exports.timestamp=r.timestamp,exports.uniqueIndex=r.uniqueIndex,exports.uuid=r.uuid,exports.PgBigInt53=i,exports.PgBigInt53Builder=t,exports.PgBigInt64=n,exports.PgBigInt64Builder=s,exports.PgBigSerial53=u,exports.PgBigSerial53Builder=o,exports.PgBigSerial64=a,exports.PgBigSerial64Builder=l,exports.PgBoolean=p,exports.PgBooleanBuilder=g,exports.PgChar=d,exports.PgCharBuilder=c,exports.PgCidr=x,exports.PgCidrBuilder=m,exports.PgCustomColumn=h,exports.PgCustomColumnBuilder=P,exports.PgDoublePrecision=B,exports.PgDoublePrecisionBuilder=f,exports.PgEnumColumn=y,exports.PgEnumColumnBuilder=C,exports.PgInet=V,exports.PgInetBuilder=b,exports.PgInteger=T,exports.PgIntegerBuilder=S,exports.PgInterval=I,exports.PgIntervalBuilder=D,exports.PgMacaddr=Q,exports.PgMacaddr8=N,exports.PgMacaddr8Builder=v,exports.PgMacaddrBuilder=M,exports.PgReal=z,exports.PgRealBuilder=L,exports.PgSchema=$,exports.PgSerial=K,exports.PgSerialBuilder=F,exports.PgSmallInt=q,exports.PgSmallIntBuilder=j,exports.PgSmallSerial=A,exports.PgSmallSerialBuilder=U,exports.PgText=k,exports.PgTextBuilder=W,exports.PgVarchar=J,exports.PgVarcharBuilder=E,exports.alias=function(r,t){return new Proxy(r,new e.TableAliasProxyHandler(t,!1))},exports.bigint=function(e,r){return"number"===r.mode?new t(e):new s(e)},exports.bigserial=function(e,{mode:r}){return"number"===r?new o(e):new l(e)},exports.boolean=function(e){return new g(e)},exports.char=function(e,r={}){return new c(e,r)},exports.cidr=function(e){return new m(e)},exports.customType=function(e){return(r,t)=>new P(r,t,e)},exports.doublePrecision=function(e){return new f(e)},exports.inet=function(e){return new b(e)},exports.integer=function(e){return new S(e)},exports.interval=function(e,r={}){return new D(e,r)},exports.isPgEnum=function(e){return!!e&&"function"==typeof e&&w in e},exports.isPgSchema=function(e){return e instanceof $},exports.macaddr=function(e){return new M(e)},exports.macaddr8=function(e){return new v(e)},exports.pgEnum=function(e,r){const t=Object.assign((e=>new C(e,t)),{enumName:e,enumValues:r,[w]:!0});return t},exports.pgSchema=function(e){if("public"===e)throw new Error("You can't specify 'public' as schema name. Postgres is using public schema by default. If you want to use 'public' schema, just use pgTable() instead of creating a schema");return new $(e)},exports.real=function(e){return new L(e)},exports.serial=function(e){return new F(e)},exports.smallint=function(e){return new j(e)},exports.smallserial=function(e){return new U(e)},exports.text=function(e,r={}){return new W(e,r)},exports.varchar=function(e,r={}){return new E(e,r)};
2
2
  //# sourceMappingURL=index.cjs.map
package/pg-core/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import{d as e}from"../index-b71998f1.mjs";import{e as g,f as h,p as f,g as p,h as ee}from"../session-c891400d.mjs";export{i as Check,C as CheckBuilder,aj as DefaultViewBuilderCore,a9 as ExtraConfigBuilder,Q as ForeignKey,O as ForeignKeyBuilder,U as Index,T as IndexBuilder,S as IndexBuilderOn,a8 as InlineForeignKeys,ao as ManualMaterializedViewBuilder,al as ManualViewBuilder,an as MaterializedViewBuilder,am as MaterializedViewBuilderCore,l as PgArray,k as PgArrayBuilder,d as PgDatabase,n as PgDate,m as PgDateBuilder,q as PgDateString,o as PgDateStringBuilder,_ as PgDelete,c as PgDialect,a0 as PgInsert,$ as PgInsertBuilder,t as PgJson,s as PgJsonBuilder,w as PgJsonb,v as PgJsonbBuilder,at as PgMaterializedView,as as PgMaterializedViewConfig,z as PgNumeric,y as PgNumericBuilder,a2 as PgRefreshMaterializedView,a5 as PgSelect,a3 as PgSelectBuilder,a4 as PgSelectQueryBuilder,a as PgSession,aa as PgTable,E as PgTime,D as PgTimeBuilder,H as PgTimestamp,G as PgTimestampBuilder,J as PgTimestampString,I as PgTimestampStringBuilder,b as PgTransaction,M as PgUUID,L as PgUUIDBuilder,a7 as PgUpdate,a6 as PgUpdateBuilder,ar as PgView,ap as PgViewBase,aq as PgViewConfig,P as PreparedQuery,Z as PrimaryKey,Y as PrimaryKeyBuilder,a1 as QueryBuilder,ak as ViewBuilder,j as check,r as date,B as decimal,R as foreignKey,af as getMaterializedViewConfig,ad as getTableConfig,ae as getViewConfig,V as index,u as json,x as jsonb,ai as makePgArray,A as numeric,ah as parsePgArray,ag as parsePgNestedArray,av as pgMaterializedView,ab as pgTable,ac as pgTableCreator,au as pgView,X as primaryKey,F as time,K as timestamp,W as uniqueIndex,N as uuid}from"../session-c891400d.mjs";import"../utils-e6870670.mjs";import"../query-promise-a65edd44.mjs";import"../query-builder-2fcde2f0.mjs";import"../column-builder-592f0191.mjs";class se extends g{build(e){return new te(e,this.config)}}class te extends h{getSQLType(){return"bigint"}mapFromDriverValue(e){return"number"==typeof e?e:Number(e)}}class ne extends g{build(e){return new re(e,this.config)}}class re extends h{getSQLType(){return"bigint"}mapFromDriverValue(e){return BigInt(e)}}function ie(e,s){return"number"===s.mode?new se(e):new ne(e)}class ue extends g{constructor(e){super(e),this.config.hasDefault=!0,this.config.notNull=!0}build(e){return new oe(e,this.config)}}class oe extends h{getSQLType(){return"bigserial"}mapFromDriverValue(e){return"number"==typeof e?e:Number(e)}}class ce extends g{constructor(e){super(e),this.config.hasDefault=!0}build(e){return new le(e,this.config)}}class le extends h{getSQLType(){return"bigserial"}mapFromDriverValue(e){return BigInt(e)}}function ge(e,{mode:s}){return"number"===s?new ue(e):new ce(e)}class me extends g{build(e){return new de(e,this.config)}}class de extends h{getSQLType(){return"boolean"}}function he(e){return new me(e)}class fe extends g{constructor(e,s){super(e),this.config.length=s.length,this.config.enumValues=s.enum??[]}build(e){return new pe(e,this.config)}}class pe extends h{constructor(){super(...arguments),this.length=this.config.length,this.enumValues=this.config.enumValues}getSQLType(){return void 0===this.length?"char":`char(${this.length})`}}function we(e,s={}){return new fe(e,s)}class ye extends g{build(e){return new be(e,this.config)}}class be extends h{getSQLType(){return"cidr"}}function xe(e){return new ye(e)}class Pe extends g{constructor(e,s,t){super(e),this.config.fieldConfig=s,this.config.customTypeParams=t}build(e){return new Te(e,this.config)}}class Te extends h{constructor(e,s){super(e,s),this.sqlName=s.customTypeParams.dataType(s.fieldConfig),this.mapTo=s.customTypeParams.toDriver,this.mapFrom=s.customTypeParams.fromDriver}getSQLType(){return this.sqlName}mapFromDriverValue(e){return"function"==typeof this.mapFrom?this.mapFrom(e):e}mapToDriverValue(e){return"function"==typeof this.mapTo?this.mapTo(e):e}}function Ve(e){return(s,t)=>new Pe(s,t,e)}class Be extends g{build(e){return new Se(e,this.config)}}class Se extends h{getSQLType(){return"double precision"}mapFromDriverValue(e){return"string"==typeof e?Number.parseFloat(e):e}}function De(e){return new Be(e)}const Qe=Symbol("isPgEnum");function ve(e){return!!e&&"function"==typeof e&&Qe in e}class Le extends g{constructor(e,s){super(e),this.config.enum=s}build(e){return new Ne(e,this.config)}}class Ne extends h{constructor(e,s){super(e,s),this.enum=this.config.enum,this.enumValues=this.config.enum.enumValues,this.enum=s.enum}getSQLType(){return this.enum.enumName}}function Fe(e,s){const t=Object.assign((e=>new Le(e,t)),{enumName:e,enumValues:s,[Qe]:!0});return t}class Ce extends g{build(e){return new Ie(e,this.config)}}class Ie extends h{getSQLType(){return"inet"}}function je(e){return new Ce(e)}class Me extends g{build(e){return new ze(e,this.config)}}class ze extends h{getSQLType(){return"integer"}mapFromDriverValue(e){return"string"==typeof e?Number.parseInt(e):e}}function Ke(e){return new Me(e)}class qe extends g{constructor(e,s){super(e),this.config.intervalConfig=s}build(e){return new Ue(e,this.config)}}class Ue extends h{constructor(){super(...arguments),this.fields=this.config.intervalConfig.fields,this.precision=this.config.intervalConfig.precision}getSQLType(){return`interval${this.fields?` ${this.fields}`:""}${this.precision?`(${this.precision})`:""}`}}function $e(e,s={}){return new qe(e,s)}class ke extends g{build(e){return new Ae(e,this.config)}}class Ae extends h{getSQLType(){return"macaddr"}}function Je(e){return new ke(e)}class Ee extends g{build(e){return new Oe(e,this.config)}}class Oe extends h{getSQLType(){return"macaddr8"}}function Re(e){return new Ee(e)}class Ye extends g{constructor(e,s){super(e),this.config.length=s}build(e){return new Ge(e,this.config)}}class Ge extends h{constructor(e,s){super(e,s),this.mapFromDriverValue=e=>"string"==typeof e?Number.parseFloat(e):e}getSQLType(){return"real"}}function He(e){return new Ye(e)}class We extends g{constructor(e){super(e),this.config.hasDefault=!0,this.config.notNull=!0}build(e){return new Xe(e,this.config)}}class Xe extends h{getSQLType(){return"serial"}}function Ze(e){return new We(e)}class _e extends g{build(e){return new es(e,this.config)}}class es extends h{constructor(){super(...arguments),this.mapFromDriverValue=e=>"string"==typeof e?Number(e):e}getSQLType(){return"smallint"}}function ss(e){return new _e(e)}class ts extends g{constructor(e){super(e),this.config.hasDefault=!0,this.config.notNull=!0}build(e){return new ns(e,this.config)}}class ns extends h{getSQLType(){return"serial"}}function rs(e){return new ts(e)}class is extends g{constructor(e,s){super(e),this.config.enumValues=s.enum??[]}build(e){return new us(e,this.config)}}class us extends h{constructor(){super(...arguments),this.enumValues=this.config.enumValues}getSQLType(){return"text"}}function os(e,s={}){return new is(e,s)}class cs extends g{constructor(e,s){super(e),this.config.length=s.length,this.config.enumValues=s.enum??[]}build(e){return new ls(e,this.config)}}class ls extends h{constructor(){super(...arguments),this.length=this.config.length,this.enumValues=this.config.enumValues}getSQLType(){return void 0===this.length?"varchar":`varchar(${this.length})`}}function gs(e,s={}){return new cs(e,s)}function ms(s,t){return new Proxy(s,new e(t,!1))}class ds{constructor(e){this.schemaName=e,this.table=(e,s,t)=>f(e,s,t,this.schemaName),this.view=(e,s)=>p(e,s,this.schemaName),this.materializedView=(e,s)=>ee(e,s,this.schemaName)}}function hs(e){return e instanceof ds}function fs(e){if("public"===e)throw new Error("You can't specify 'public' as schema name. Postgres is using public schema by default. If you want to use 'public' schema, just use pgTable() instead of creating a schema");return new ds(e)}export{te as PgBigInt53,se as PgBigInt53Builder,re as PgBigInt64,ne as PgBigInt64Builder,oe as PgBigSerial53,ue as PgBigSerial53Builder,le as PgBigSerial64,ce as PgBigSerial64Builder,de as PgBoolean,me as PgBooleanBuilder,pe as PgChar,fe as PgCharBuilder,be as PgCidr,ye as PgCidrBuilder,h as PgColumn,g as PgColumnBuilder,Te as PgCustomColumn,Pe as PgCustomColumnBuilder,Se as PgDoublePrecision,Be as PgDoublePrecisionBuilder,Ne as PgEnumColumn,Le as PgEnumColumnBuilder,Ie as PgInet,Ce as PgInetBuilder,ze as PgInteger,Me as PgIntegerBuilder,Ue as PgInterval,qe as PgIntervalBuilder,Ae as PgMacaddr,Oe as PgMacaddr8,Ee as PgMacaddr8Builder,ke as PgMacaddrBuilder,Ge as PgReal,Ye as PgRealBuilder,ds as PgSchema,Xe as PgSerial,We as PgSerialBuilder,es as PgSmallInt,_e as PgSmallIntBuilder,ns as PgSmallSerial,ts as PgSmallSerialBuilder,us as PgText,is as PgTextBuilder,ls as PgVarchar,cs as PgVarcharBuilder,ms as alias,ie as bigint,ge as bigserial,he as boolean,we as char,xe as cidr,Ve as customType,De as doublePrecision,je as inet,Ke as integer,$e as interval,ve as isPgEnum,hs as isPgSchema,Je as macaddr,Re as macaddr8,Fe as pgEnum,ee as pgMaterializedViewWithSchema,fs as pgSchema,f as pgTableWithSchema,p as pgViewWithSchema,He as real,Ze as serial,ss as smallint,rs as smallserial,os as text,gs as varchar};
1
+ import{d as e}from"../index-b71998f1.mjs";import{e as g,f as h,p as f,g as p,h as ee}from"../session-fdec872e.mjs";export{i as Check,C as CheckBuilder,aj as DefaultViewBuilderCore,a9 as ExtraConfigBuilder,Q as ForeignKey,O as ForeignKeyBuilder,U as Index,T as IndexBuilder,S as IndexBuilderOn,a8 as InlineForeignKeys,ao as ManualMaterializedViewBuilder,al as ManualViewBuilder,an as MaterializedViewBuilder,am as MaterializedViewBuilderCore,l as PgArray,k as PgArrayBuilder,d as PgDatabase,n as PgDate,m as PgDateBuilder,q as PgDateString,o as PgDateStringBuilder,_ as PgDelete,c as PgDialect,a0 as PgInsert,$ as PgInsertBuilder,t as PgJson,s as PgJsonBuilder,w as PgJsonb,v as PgJsonbBuilder,at as PgMaterializedView,as as PgMaterializedViewConfig,z as PgNumeric,y as PgNumericBuilder,a2 as PgRefreshMaterializedView,a5 as PgSelect,a3 as PgSelectBuilder,a4 as PgSelectQueryBuilder,a as PgSession,aa as PgTable,E as PgTime,D as PgTimeBuilder,H as PgTimestamp,G as PgTimestampBuilder,J as PgTimestampString,I as PgTimestampStringBuilder,b as PgTransaction,M as PgUUID,L as PgUUIDBuilder,a7 as PgUpdate,a6 as PgUpdateBuilder,ar as PgView,ap as PgViewBase,aq as PgViewConfig,P as PreparedQuery,Z as PrimaryKey,Y as PrimaryKeyBuilder,a1 as QueryBuilder,ak as ViewBuilder,j as check,r as date,B as decimal,R as foreignKey,af as getMaterializedViewConfig,ad as getTableConfig,ae as getViewConfig,V as index,u as json,x as jsonb,ai as makePgArray,A as numeric,ah as parsePgArray,ag as parsePgNestedArray,av as pgMaterializedView,ab as pgTable,ac as pgTableCreator,au as pgView,X as primaryKey,F as time,K as timestamp,W as uniqueIndex,N as uuid}from"../session-fdec872e.mjs";import"../utils-e6870670.mjs";import"../query-promise-a65edd44.mjs";import"../query-builder-2fcde2f0.mjs";import"../column-builder-592f0191.mjs";class se extends g{build(e){return new te(e,this.config)}}class te extends h{getSQLType(){return"bigint"}mapFromDriverValue(e){return"number"==typeof e?e:Number(e)}}class ne extends g{build(e){return new re(e,this.config)}}class re extends h{getSQLType(){return"bigint"}mapFromDriverValue(e){return BigInt(e)}}function ie(e,s){return"number"===s.mode?new se(e):new ne(e)}class ue extends g{constructor(e){super(e),this.config.hasDefault=!0,this.config.notNull=!0}build(e){return new oe(e,this.config)}}class oe extends h{getSQLType(){return"bigserial"}mapFromDriverValue(e){return"number"==typeof e?e:Number(e)}}class ce extends g{constructor(e){super(e),this.config.hasDefault=!0}build(e){return new le(e,this.config)}}class le extends h{getSQLType(){return"bigserial"}mapFromDriverValue(e){return BigInt(e)}}function ge(e,{mode:s}){return"number"===s?new ue(e):new ce(e)}class me extends g{build(e){return new de(e,this.config)}}class de extends h{getSQLType(){return"boolean"}}function he(e){return new me(e)}class fe extends g{constructor(e,s){super(e),this.config.length=s.length,this.config.enumValues=s.enum??[]}build(e){return new pe(e,this.config)}}class pe extends h{constructor(){super(...arguments),this.length=this.config.length,this.enumValues=this.config.enumValues}getSQLType(){return void 0===this.length?"char":`char(${this.length})`}}function we(e,s={}){return new fe(e,s)}class ye extends g{build(e){return new be(e,this.config)}}class be extends h{getSQLType(){return"cidr"}}function xe(e){return new ye(e)}class Pe extends g{constructor(e,s,t){super(e),this.config.fieldConfig=s,this.config.customTypeParams=t}build(e){return new Te(e,this.config)}}class Te extends h{constructor(e,s){super(e,s),this.sqlName=s.customTypeParams.dataType(s.fieldConfig),this.mapTo=s.customTypeParams.toDriver,this.mapFrom=s.customTypeParams.fromDriver}getSQLType(){return this.sqlName}mapFromDriverValue(e){return"function"==typeof this.mapFrom?this.mapFrom(e):e}mapToDriverValue(e){return"function"==typeof this.mapTo?this.mapTo(e):e}}function Ve(e){return(s,t)=>new Pe(s,t,e)}class Be extends g{build(e){return new Se(e,this.config)}}class Se extends h{getSQLType(){return"double precision"}mapFromDriverValue(e){return"string"==typeof e?Number.parseFloat(e):e}}function De(e){return new Be(e)}const Qe=Symbol("isPgEnum");function ve(e){return!!e&&"function"==typeof e&&Qe in e}class Le extends g{constructor(e,s){super(e),this.config.enum=s}build(e){return new Ne(e,this.config)}}class Ne extends h{constructor(e,s){super(e,s),this.enum=this.config.enum,this.enumValues=this.config.enum.enumValues,this.enum=s.enum}getSQLType(){return this.enum.enumName}}function Fe(e,s){const t=Object.assign((e=>new Le(e,t)),{enumName:e,enumValues:s,[Qe]:!0});return t}class Ce extends g{build(e){return new Ie(e,this.config)}}class Ie extends h{getSQLType(){return"inet"}}function je(e){return new Ce(e)}class Me extends g{build(e){return new ze(e,this.config)}}class ze extends h{getSQLType(){return"integer"}mapFromDriverValue(e){return"string"==typeof e?Number.parseInt(e):e}}function Ke(e){return new Me(e)}class qe extends g{constructor(e,s){super(e),this.config.intervalConfig=s}build(e){return new Ue(e,this.config)}}class Ue extends h{constructor(){super(...arguments),this.fields=this.config.intervalConfig.fields,this.precision=this.config.intervalConfig.precision}getSQLType(){return`interval${this.fields?` ${this.fields}`:""}${this.precision?`(${this.precision})`:""}`}}function $e(e,s={}){return new qe(e,s)}class ke extends g{build(e){return new Ae(e,this.config)}}class Ae extends h{getSQLType(){return"macaddr"}}function Je(e){return new ke(e)}class Ee extends g{build(e){return new Oe(e,this.config)}}class Oe extends h{getSQLType(){return"macaddr8"}}function Re(e){return new Ee(e)}class Ye extends g{constructor(e,s){super(e),this.config.length=s}build(e){return new Ge(e,this.config)}}class Ge extends h{constructor(e,s){super(e,s),this.mapFromDriverValue=e=>"string"==typeof e?Number.parseFloat(e):e}getSQLType(){return"real"}}function He(e){return new Ye(e)}class We extends g{constructor(e){super(e),this.config.hasDefault=!0,this.config.notNull=!0}build(e){return new Xe(e,this.config)}}class Xe extends h{getSQLType(){return"serial"}}function Ze(e){return new We(e)}class _e extends g{build(e){return new es(e,this.config)}}class es extends h{constructor(){super(...arguments),this.mapFromDriverValue=e=>"string"==typeof e?Number(e):e}getSQLType(){return"smallint"}}function ss(e){return new _e(e)}class ts extends g{constructor(e){super(e),this.config.hasDefault=!0,this.config.notNull=!0}build(e){return new ns(e,this.config)}}class ns extends h{getSQLType(){return"serial"}}function rs(e){return new ts(e)}class is extends g{constructor(e,s){super(e),this.config.enumValues=s.enum??[]}build(e){return new us(e,this.config)}}class us extends h{constructor(){super(...arguments),this.enumValues=this.config.enumValues}getSQLType(){return"text"}}function os(e,s={}){return new is(e,s)}class cs extends g{constructor(e,s){super(e),this.config.length=s.length,this.config.enumValues=s.enum??[]}build(e){return new ls(e,this.config)}}class ls extends h{constructor(){super(...arguments),this.length=this.config.length,this.enumValues=this.config.enumValues}getSQLType(){return void 0===this.length?"varchar":`varchar(${this.length})`}}function gs(e,s={}){return new cs(e,s)}function ms(s,t){return new Proxy(s,new e(t,!1))}class ds{constructor(e){this.schemaName=e,this.table=(e,s,t)=>f(e,s,t,this.schemaName),this.view=(e,s)=>p(e,s,this.schemaName),this.materializedView=(e,s)=>ee(e,s,this.schemaName)}}function hs(e){return e instanceof ds}function fs(e){if("public"===e)throw new Error("You can't specify 'public' as schema name. Postgres is using public schema by default. If you want to use 'public' schema, just use pgTable() instead of creating a schema");return new ds(e)}export{te as PgBigInt53,se as PgBigInt53Builder,re as PgBigInt64,ne as PgBigInt64Builder,oe as PgBigSerial53,ue as PgBigSerial53Builder,le as PgBigSerial64,ce as PgBigSerial64Builder,de as PgBoolean,me as PgBooleanBuilder,pe as PgChar,fe as PgCharBuilder,be as PgCidr,ye as PgCidrBuilder,h as PgColumn,g as PgColumnBuilder,Te as PgCustomColumn,Pe as PgCustomColumnBuilder,Se as PgDoublePrecision,Be as PgDoublePrecisionBuilder,Ne as PgEnumColumn,Le as PgEnumColumnBuilder,Ie as PgInet,Ce as PgInetBuilder,ze as PgInteger,Me as PgIntegerBuilder,Ue as PgInterval,qe as PgIntervalBuilder,Ae as PgMacaddr,Oe as PgMacaddr8,Ee as PgMacaddr8Builder,ke as PgMacaddrBuilder,Ge as PgReal,Ye as PgRealBuilder,ds as PgSchema,Xe as PgSerial,We as PgSerialBuilder,es as PgSmallInt,_e as PgSmallIntBuilder,ns as PgSmallSerial,ts as PgSmallSerialBuilder,us as PgText,is as PgTextBuilder,ls as PgVarchar,cs as PgVarcharBuilder,ms as alias,ie as bigint,ge as bigserial,he as boolean,we as char,xe as cidr,Ve as customType,De as doublePrecision,je as inet,Ke as integer,$e as interval,ve as isPgEnum,hs as isPgSchema,Je as macaddr,Re as macaddr8,Fe as pgEnum,ee as pgMaterializedViewWithSchema,fs as pgSchema,f as pgTableWithSchema,p as pgViewWithSchema,He as real,Ze as serial,ss as smallint,rs as smallserial,os as text,gs as varchar};
2
2
  //# sourceMappingURL=index.mjs.map
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("../logger-04bad527.cjs"),t=require("../session-e6db6732.cjs"),s=require("../index-59b7992d.cjs"),r=require("../utils-9d882195.cjs");require("../query-promise-2c5b43ab.cjs"),require("../column-builder-b48639f3.cjs"),require("../query-builder-2f2e8229.cjs");class i extends t.PreparedQuery{constructor(e,t,s,r,i){super(),this.client=e,this.queryString=t,this.params=s,this.logger=r,this.fields=i,this.rawQuery={as:"object"},this.query={as:"array"}}async execute(e={}){const t=s.fillPlaceholders(this.params,e);this.logger.logQuery(this.queryString,t);const{fields:i,client:a,queryString:n,rawQuery:l,query:o,joinsNotNullableMap:c}=this;if(!i)return a.execute(n,t,l);return a.execute(n,t,o).then((e=>e.rows.map((e=>r.mapResultRow(i,e,c)))))}iterator(e){throw new Error("Streaming is not supported by the PlanetScale Serverless driver")}}class a extends t.MySqlSession{constructor(t,s,r,i={}){super(s),this.baseClient=t,this.options=i,this.client=r??t,this.logger=i.logger??new e.NoopLogger}prepareQuery(e,t){return new i(this.client,e.sql,e.params,this.logger,t)}async query(e,t){return this.logger.logQuery(e,t),await this.client.execute(e,t,{as:"array"})}async queryObjects(e,t){return this.client.execute(e,t,{as:"object"})}all(e){const t=this.dialect.sqlToQuery(e);return this.logger.logQuery(t.sql,t.params),this.client.execute(t.sql,t.params,{as:"object"}).then((e=>e.rows))}transaction(e){return this.baseClient.transaction((t=>{const s=new a(this.baseClient,this.dialect,t,this.options),r=new n(this.dialect,s);return e(r)}))}}class n extends t.MySqlTransaction{async transaction(e){const t=`sp${this.nestedIndex+1}`,r=new n(this.dialect,this.session,this.nestedIndex+1);await r.execute(s.sql.raw(`savepoint ${t}`));try{const i=await e(r);return await r.execute(s.sql.raw(`release savepoint ${t}`)),i}catch(e){throw await r.execute(s.sql.raw(`rollback to savepoint ${t}`)),e}}}class l{constructor(e,t,s={}){this.client=e,this.dialect=t,this.options=s}createSession(){return new a(this.client,this.dialect,void 0,{logger:this.options.logger})}}exports.PlanetScalePreparedQuery=i,exports.PlanetScaleTransaction=n,exports.PlanetscaleDriver=l,exports.PlanetscaleSession=a,exports.drizzle=function(s,r={}){const i=new t.MySqlDialect;let a;!0===r.logger?a=new e.DefaultLogger:!1!==r.logger&&(a=r.logger);const n=new l(s,i,{logger:a}).createSession();return new t.MySqlDatabase(i,n)};
1
+ "use strict";var e=require("../logger-04bad527.cjs"),t=require("../session-e630c258.cjs"),s=require("../index-59b7992d.cjs"),r=require("../utils-9d882195.cjs");require("../query-promise-2c5b43ab.cjs"),require("../column-builder-b48639f3.cjs"),require("../query-builder-2f2e8229.cjs");class i extends t.PreparedQuery{constructor(e,t,s,r,i){super(),this.client=e,this.queryString=t,this.params=s,this.logger=r,this.fields=i,this.rawQuery={as:"object"},this.query={as:"array"}}async execute(e={}){const t=s.fillPlaceholders(this.params,e);this.logger.logQuery(this.queryString,t);const{fields:i,client:a,queryString:n,rawQuery:l,query:o,joinsNotNullableMap:c}=this;if(!i)return a.execute(n,t,l);return a.execute(n,t,o).then((e=>e.rows.map((e=>r.mapResultRow(i,e,c)))))}iterator(e){throw new Error("Streaming is not supported by the PlanetScale Serverless driver")}}class a extends t.MySqlSession{constructor(t,s,r,i={}){super(s),this.baseClient=t,this.options=i,this.client=r??t,this.logger=i.logger??new e.NoopLogger}prepareQuery(e,t){return new i(this.client,e.sql,e.params,this.logger,t)}async query(e,t){return this.logger.logQuery(e,t),await this.client.execute(e,t,{as:"array"})}async queryObjects(e,t){return this.client.execute(e,t,{as:"object"})}all(e){const t=this.dialect.sqlToQuery(e);return this.logger.logQuery(t.sql,t.params),this.client.execute(t.sql,t.params,{as:"object"}).then((e=>e.rows))}transaction(e){return this.baseClient.transaction((t=>{const s=new a(this.baseClient,this.dialect,t,this.options),r=new n(this.dialect,s);return e(r)}))}}class n extends t.MySqlTransaction{async transaction(e){const t=`sp${this.nestedIndex+1}`,r=new n(this.dialect,this.session,this.nestedIndex+1);await r.execute(s.sql.raw(`savepoint ${t}`));try{const i=await e(r);return await r.execute(s.sql.raw(`release savepoint ${t}`)),i}catch(e){throw await r.execute(s.sql.raw(`rollback to savepoint ${t}`)),e}}}class l{constructor(e,t,s={}){this.client=e,this.dialect=t,this.options=s}createSession(){return new a(this.client,this.dialect,void 0,{logger:this.options.logger})}}exports.PlanetScalePreparedQuery=i,exports.PlanetScaleTransaction=n,exports.PlanetscaleDriver=l,exports.PlanetscaleSession=a,exports.drizzle=function(s,r={}){const i=new t.MySqlDialect;let a;!0===r.logger?a=new e.DefaultLogger:!1!==r.logger&&(a=r.logger);const n=new l(s,i,{logger:a}).createSession();return new t.MySqlDatabase(i,n)};
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1,2 +1,2 @@
1
- import{N as e,D as t}from"../logger-2598bf05.mjs";import{P as s,t as r,u as i,g as n,h as a}from"../session-8a621f09.mjs";import{k as o,s as c}from"../index-b71998f1.mjs";import{m as l}from"../utils-e6870670.mjs";import"../query-promise-a65edd44.mjs";import"../column-builder-592f0191.mjs";import"../query-builder-2fcde2f0.mjs";class u extends s{constructor(e,t,s,r,i){super(),this.client=e,this.queryString=t,this.params=s,this.logger=r,this.fields=i,this.rawQuery={as:"object"},this.query={as:"array"}}async execute(e={}){const t=o(this.params,e);this.logger.logQuery(this.queryString,t);const{fields:s,client:r,queryString:i,rawQuery:n,query:a,joinsNotNullableMap:c}=this;if(!s)return r.execute(i,t,n);return r.execute(i,t,a).then((e=>e.rows.map((e=>l(s,e,c)))))}iterator(e){throw new Error("Streaming is not supported by the PlanetScale Serverless driver")}}class h extends r{constructor(t,s,r,i={}){super(s),this.baseClient=t,this.options=i,this.client=r??t,this.logger=i.logger??new e}prepareQuery(e,t){return new u(this.client,e.sql,e.params,this.logger,t)}async query(e,t){return this.logger.logQuery(e,t),await this.client.execute(e,t,{as:"array"})}async queryObjects(e,t){return this.client.execute(e,t,{as:"object"})}all(e){const t=this.dialect.sqlToQuery(e);return this.logger.logQuery(t.sql,t.params),this.client.execute(t.sql,t.params,{as:"object"}).then((e=>e.rows))}transaction(e){return this.baseClient.transaction((t=>{const s=new h(this.baseClient,this.dialect,t,this.options),r=new g(this.dialect,s);return e(r)}))}}class g extends i{async transaction(e){const t=`sp${this.nestedIndex+1}`,s=new g(this.dialect,this.session,this.nestedIndex+1);await s.execute(c.raw(`savepoint ${t}`));try{const r=await e(s);return await s.execute(c.raw(`release savepoint ${t}`)),r}catch(e){throw await s.execute(c.raw(`rollback to savepoint ${t}`)),e}}}class p{constructor(e,t,s={}){this.client=e,this.dialect=t,this.options=s}createSession(){return new h(this.client,this.dialect,void 0,{logger:this.options.logger})}}function m(e,s={}){const r=new a;let i;!0===s.logger?i=new t:!1!==s.logger&&(i=s.logger);const o=new p(e,r,{logger:i}).createSession();return new n(r,o)}export{u as PlanetScalePreparedQuery,g as PlanetScaleTransaction,p as PlanetscaleDriver,h as PlanetscaleSession,m as drizzle};
1
+ import{N as e,D as t}from"../logger-2598bf05.mjs";import{P as s,t as r,u as i,g as n,h as a}from"../session-a87f051d.mjs";import{k as o,s as c}from"../index-b71998f1.mjs";import{m as l}from"../utils-e6870670.mjs";import"../query-promise-a65edd44.mjs";import"../column-builder-592f0191.mjs";import"../query-builder-2fcde2f0.mjs";class u extends s{constructor(e,t,s,r,i){super(),this.client=e,this.queryString=t,this.params=s,this.logger=r,this.fields=i,this.rawQuery={as:"object"},this.query={as:"array"}}async execute(e={}){const t=o(this.params,e);this.logger.logQuery(this.queryString,t);const{fields:s,client:r,queryString:i,rawQuery:n,query:a,joinsNotNullableMap:c}=this;if(!s)return r.execute(i,t,n);return r.execute(i,t,a).then((e=>e.rows.map((e=>l(s,e,c)))))}iterator(e){throw new Error("Streaming is not supported by the PlanetScale Serverless driver")}}class h extends r{constructor(t,s,r,i={}){super(s),this.baseClient=t,this.options=i,this.client=r??t,this.logger=i.logger??new e}prepareQuery(e,t){return new u(this.client,e.sql,e.params,this.logger,t)}async query(e,t){return this.logger.logQuery(e,t),await this.client.execute(e,t,{as:"array"})}async queryObjects(e,t){return this.client.execute(e,t,{as:"object"})}all(e){const t=this.dialect.sqlToQuery(e);return this.logger.logQuery(t.sql,t.params),this.client.execute(t.sql,t.params,{as:"object"}).then((e=>e.rows))}transaction(e){return this.baseClient.transaction((t=>{const s=new h(this.baseClient,this.dialect,t,this.options),r=new g(this.dialect,s);return e(r)}))}}class g extends i{async transaction(e){const t=`sp${this.nestedIndex+1}`,s=new g(this.dialect,this.session,this.nestedIndex+1);await s.execute(c.raw(`savepoint ${t}`));try{const r=await e(s);return await s.execute(c.raw(`release savepoint ${t}`)),r}catch(e){throw await s.execute(c.raw(`rollback to savepoint ${t}`)),e}}}class p{constructor(e,t,s={}){this.client=e,this.dialect=t,this.options=s}createSession(){return new h(this.client,this.dialect,void 0,{logger:this.options.logger})}}function m(e,s={}){const r=new a;let i;!0===s.logger?i=new t:!1!==s.logger&&(i=s.logger);const o=new p(e,r,{logger:i}).createSession();return new n(r,o)}export{u as PlanetScalePreparedQuery,g as PlanetScaleTransaction,p as PlanetscaleDriver,h as PlanetscaleSession,m as drizzle};
2
2
  //# sourceMappingURL=index.mjs.map