drizzle-orm 0.39.2-8628c8a → 0.39.2-aaa57ff
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_relations.cjs +328 -0
- package/_relations.cjs.map +1 -0
- package/_relations.d.cts +215 -0
- package/_relations.d.ts +215 -0
- package/_relations.js +316 -0
- package/_relations.js.map +1 -0
- package/alias.cjs.map +1 -1
- package/alias.d.cts +3 -3
- package/alias.d.ts +3 -3
- package/alias.js.map +1 -1
- package/aws-data-api/pg/driver.cjs +19 -5
- package/aws-data-api/pg/driver.cjs.map +1 -1
- package/aws-data-api/pg/driver.d.cts +9 -8
- package/aws-data-api/pg/driver.d.ts +9 -8
- package/aws-data-api/pg/driver.js +9 -8
- package/aws-data-api/pg/driver.js.map +1 -1
- package/aws-data-api/pg/migrator.cjs.map +1 -1
- package/aws-data-api/pg/migrator.d.cts +2 -1
- package/aws-data-api/pg/migrator.d.ts +2 -1
- package/aws-data-api/pg/migrator.js.map +1 -1
- package/aws-data-api/pg/session.cjs +67 -4
- package/aws-data-api/pg/session.cjs.map +1 -1
- package/aws-data-api/pg/session.d.cts +13 -8
- package/aws-data-api/pg/session.d.ts +13 -8
- package/aws-data-api/pg/session.js +67 -4
- package/aws-data-api/pg/session.js.map +1 -1
- package/better-sqlite3/driver.cjs +12 -5
- package/better-sqlite3/driver.cjs.map +1 -1
- package/better-sqlite3/driver.d.cts +7 -6
- package/better-sqlite3/driver.d.ts +7 -6
- package/better-sqlite3/driver.js +12 -8
- package/better-sqlite3/driver.js.map +1 -1
- package/better-sqlite3/migrator.cjs.map +1 -1
- package/better-sqlite3/migrator.d.cts +2 -1
- package/better-sqlite3/migrator.d.ts +2 -1
- package/better-sqlite3/migrator.js.map +1 -1
- package/better-sqlite3/session.cjs +49 -4
- package/better-sqlite3/session.cjs.map +1 -1
- package/better-sqlite3/session.d.cts +14 -8
- package/better-sqlite3/session.d.ts +14 -8
- package/better-sqlite3/session.js +49 -4
- package/better-sqlite3/session.js.map +1 -1
- package/bun-sql/driver.cjs +16 -5
- package/bun-sql/driver.cjs.map +1 -1
- package/bun-sql/driver.d.cts +7 -6
- package/bun-sql/driver.d.ts +7 -6
- package/bun-sql/driver.js +6 -8
- package/bun-sql/driver.js.map +1 -1
- package/bun-sql/migrator.cjs.map +1 -1
- package/bun-sql/migrator.d.cts +2 -1
- package/bun-sql/migrator.d.ts +2 -1
- package/bun-sql/migrator.js.map +1 -1
- package/bun-sql/session.cjs +50 -6
- package/bun-sql/session.cjs.map +1 -1
- package/bun-sql/session.d.cts +14 -9
- package/bun-sql/session.d.ts +14 -9
- package/bun-sql/session.js +50 -6
- package/bun-sql/session.js.map +1 -1
- package/bun-sqlite/driver.cjs +22 -5
- package/bun-sqlite/driver.cjs.map +1 -1
- package/bun-sqlite/driver.d.cts +7 -6
- package/bun-sqlite/driver.d.ts +7 -6
- package/bun-sqlite/driver.js +12 -8
- package/bun-sqlite/driver.js.map +1 -1
- package/bun-sqlite/migrator.cjs.map +1 -1
- package/bun-sqlite/migrator.d.cts +2 -1
- package/bun-sqlite/migrator.d.ts +2 -1
- package/bun-sqlite/migrator.js.map +1 -1
- package/bun-sqlite/session.cjs +49 -4
- package/bun-sqlite/session.cjs.map +1 -1
- package/bun-sqlite/session.d.cts +14 -8
- package/bun-sqlite/session.d.ts +14 -8
- package/bun-sqlite/session.js +49 -4
- package/bun-sqlite/session.js.map +1 -1
- package/column-builder.cjs.map +1 -1
- package/column-builder.d.cts +5 -6
- package/column-builder.d.ts +5 -6
- package/column-builder.js.map +1 -1
- package/d1/driver.cjs +22 -5
- package/d1/driver.cjs.map +1 -1
- package/d1/driver.d.cts +3 -2
- package/d1/driver.d.ts +3 -2
- package/d1/driver.js +12 -8
- package/d1/driver.js.map +1 -1
- package/d1/migrator.cjs.map +1 -1
- package/d1/migrator.d.cts +2 -1
- package/d1/migrator.d.ts +2 -1
- package/d1/migrator.js.map +1 -1
- package/d1/session.cjs +50 -8
- package/d1/session.cjs.map +1 -1
- package/d1/session.d.cts +15 -8
- package/d1/session.d.ts +15 -8
- package/d1/session.js +50 -8
- package/d1/session.js.map +1 -1
- package/durable-sqlite/driver.cjs +16 -5
- package/durable-sqlite/driver.cjs.map +1 -1
- package/durable-sqlite/driver.d.cts +3 -2
- package/durable-sqlite/driver.d.ts +3 -2
- package/durable-sqlite/driver.js +6 -8
- package/durable-sqlite/driver.js.map +1 -1
- package/durable-sqlite/migrator.cjs.map +1 -1
- package/durable-sqlite/migrator.d.cts +2 -1
- package/durable-sqlite/migrator.d.ts +2 -1
- package/durable-sqlite/migrator.js.map +1 -1
- package/durable-sqlite/session.cjs +46 -4
- package/durable-sqlite/session.cjs.map +1 -1
- package/durable-sqlite/session.d.cts +14 -8
- package/durable-sqlite/session.d.ts +14 -8
- package/durable-sqlite/session.js +46 -4
- package/durable-sqlite/session.js.map +1 -1
- package/expo-sqlite/driver.cjs +22 -5
- package/expo-sqlite/driver.cjs.map +1 -1
- package/expo-sqlite/driver.d.cts +3 -2
- package/expo-sqlite/driver.d.ts +3 -2
- package/expo-sqlite/driver.js +12 -8
- package/expo-sqlite/driver.js.map +1 -1
- package/expo-sqlite/migrator.cjs.map +1 -1
- package/expo-sqlite/migrator.d.cts +3 -2
- package/expo-sqlite/migrator.d.ts +3 -2
- package/expo-sqlite/migrator.js.map +1 -1
- package/expo-sqlite/query.cjs +13 -2
- package/expo-sqlite/query.cjs.map +1 -1
- package/expo-sqlite/query.d.cts +2 -1
- package/expo-sqlite/query.d.ts +2 -1
- package/expo-sqlite/query.js +3 -2
- package/expo-sqlite/query.js.map +1 -1
- package/expo-sqlite/session.cjs +47 -4
- package/expo-sqlite/session.cjs.map +1 -1
- package/expo-sqlite/session.d.cts +14 -8
- package/expo-sqlite/session.d.ts +14 -8
- package/expo-sqlite/session.js +47 -4
- package/expo-sqlite/session.js.map +1 -1
- package/libsql/driver-core.cjs +22 -5
- package/libsql/driver-core.cjs.map +1 -1
- package/libsql/driver-core.d.cts +2 -1
- package/libsql/driver-core.d.ts +2 -1
- package/libsql/driver-core.js +12 -8
- package/libsql/driver-core.js.map +1 -1
- package/libsql/driver.cjs.map +1 -1
- package/libsql/driver.d.cts +6 -5
- package/libsql/driver.d.ts +6 -5
- package/libsql/driver.js.map +1 -1
- package/libsql/http/index.cjs.map +1 -1
- package/libsql/http/index.d.cts +6 -5
- package/libsql/http/index.d.ts +6 -5
- package/libsql/http/index.js.map +1 -1
- package/libsql/migrator.cjs.map +1 -1
- package/libsql/migrator.d.cts +2 -1
- package/libsql/migrator.d.ts +2 -1
- package/libsql/migrator.js.map +1 -1
- package/libsql/node/index.cjs.map +1 -1
- package/libsql/node/index.d.cts +6 -5
- package/libsql/node/index.d.ts +6 -5
- package/libsql/node/index.js.map +1 -1
- package/libsql/session.cjs +56 -4
- package/libsql/session.cjs.map +1 -1
- package/libsql/session.d.cts +15 -9
- package/libsql/session.d.ts +15 -9
- package/libsql/session.js +56 -4
- package/libsql/session.js.map +1 -1
- package/libsql/sqlite3/index.cjs.map +1 -1
- package/libsql/sqlite3/index.d.cts +6 -5
- package/libsql/sqlite3/index.d.ts +6 -5
- package/libsql/sqlite3/index.js.map +1 -1
- package/libsql/wasm/index.cjs.map +1 -1
- package/libsql/wasm/index.d.cts +6 -5
- package/libsql/wasm/index.d.ts +6 -5
- package/libsql/wasm/index.js.map +1 -1
- package/libsql/web/index.cjs.map +1 -1
- package/libsql/web/index.d.cts +6 -5
- package/libsql/web/index.d.ts +6 -5
- package/libsql/web/index.js.map +1 -1
- package/libsql/ws/index.cjs.map +1 -1
- package/libsql/ws/index.d.cts +6 -5
- package/libsql/ws/index.d.ts +6 -5
- package/libsql/ws/index.js.map +1 -1
- package/mysql-core/db.cjs +30 -6
- package/mysql-core/db.cjs.map +1 -1
- package/mysql-core/db.d.cts +15 -8
- package/mysql-core/db.d.ts +15 -8
- package/mysql-core/db.js +29 -5
- package/mysql-core/db.js.map +1 -1
- package/mysql-core/dialect.cjs +197 -15
- package/mysql-core/dialect.cjs.map +1 -1
- package/mysql-core/dialect.d.cts +36 -13
- package/mysql-core/dialect.d.ts +36 -13
- package/mysql-core/dialect.js +196 -22
- package/mysql-core/dialect.js.map +1 -1
- package/mysql-core/query-builders/_query.cjs +149 -0
- package/mysql-core/query-builders/_query.cjs.map +1 -0
- package/mysql-core/query-builders/_query.d.cts +44 -0
- package/mysql-core/query-builders/_query.d.ts +44 -0
- package/mysql-core/query-builders/_query.js +114 -0
- package/mysql-core/query-builders/_query.js.map +1 -0
- package/mysql-core/query-builders/count.cjs.map +1 -1
- package/mysql-core/query-builders/count.d.cts +1 -1
- package/mysql-core/query-builders/count.d.ts +1 -1
- package/mysql-core/query-builders/count.js.map +1 -1
- package/mysql-core/query-builders/query.cjs +18 -31
- package/mysql-core/query-builders/query.cjs.map +1 -1
- package/mysql-core/query-builders/query.d.cts +8 -10
- package/mysql-core/query-builders/query.d.ts +8 -10
- package/mysql-core/query-builders/query.js +18 -31
- package/mysql-core/query-builders/query.js.map +1 -1
- package/mysql-core/session.cjs +3 -2
- package/mysql-core/session.cjs.map +1 -1
- package/mysql-core/session.d.cts +10 -7
- package/mysql-core/session.d.ts +10 -7
- package/mysql-core/session.js +3 -2
- package/mysql-core/session.js.map +1 -1
- package/mysql-proxy/driver.cjs +22 -5
- package/mysql-proxy/driver.cjs.map +1 -1
- package/mysql-proxy/driver.d.cts +3 -2
- package/mysql-proxy/driver.d.ts +3 -2
- package/mysql-proxy/driver.js +12 -8
- package/mysql-proxy/driver.js.map +1 -1
- package/mysql-proxy/migrator.cjs.map +1 -1
- package/mysql-proxy/migrator.d.cts +2 -1
- package/mysql-proxy/migrator.d.ts +2 -1
- package/mysql-proxy/migrator.js.map +1 -1
- package/mysql-proxy/session.cjs +27 -2
- package/mysql-proxy/session.cjs.map +1 -1
- package/mysql-proxy/session.d.cts +13 -8
- package/mysql-proxy/session.d.ts +13 -8
- package/mysql-proxy/session.js +27 -2
- package/mysql-proxy/session.js.map +1 -1
- package/mysql2/driver.cjs +24 -7
- package/mysql2/driver.cjs.map +1 -1
- package/mysql2/driver.d.cts +10 -9
- package/mysql2/driver.d.ts +10 -9
- package/mysql2/driver.js +14 -10
- package/mysql2/driver.js.map +1 -1
- package/mysql2/migrator.cjs.map +1 -1
- package/mysql2/migrator.d.cts +2 -1
- package/mysql2/migrator.d.ts +2 -1
- package/mysql2/migrator.js.map +1 -1
- package/mysql2/session.cjs +30 -2
- package/mysql2/session.cjs.map +1 -1
- package/mysql2/session.d.cts +13 -8
- package/mysql2/session.d.ts +13 -8
- package/mysql2/session.js +30 -2
- package/mysql2/session.js.map +1 -1
- package/neon-http/driver.cjs +21 -7
- package/neon-http/driver.cjs.map +1 -1
- package/neon-http/driver.d.cts +10 -9
- package/neon-http/driver.d.ts +10 -9
- package/neon-http/driver.js +11 -7
- package/neon-http/driver.js.map +1 -1
- package/neon-http/migrator.cjs.map +1 -1
- package/neon-http/migrator.d.cts +2 -1
- package/neon-http/migrator.d.ts +2 -1
- package/neon-http/migrator.js.map +1 -1
- package/neon-http/session.cjs +32 -2
- package/neon-http/session.cjs.map +1 -1
- package/neon-http/session.d.cts +13 -8
- package/neon-http/session.d.ts +13 -8
- package/neon-http/session.js +32 -2
- package/neon-http/session.js.map +1 -1
- package/neon-serverless/driver.cjs +18 -7
- package/neon-serverless/driver.cjs.map +1 -1
- package/neon-serverless/driver.d.cts +9 -8
- package/neon-serverless/driver.d.ts +9 -8
- package/neon-serverless/driver.js +8 -10
- package/neon-serverless/driver.js.map +1 -1
- package/neon-serverless/migrator.cjs.map +1 -1
- package/neon-serverless/migrator.d.cts +2 -1
- package/neon-serverless/migrator.d.ts +2 -1
- package/neon-serverless/migrator.js.map +1 -1
- package/neon-serverless/session.cjs +40 -5
- package/neon-serverless/session.cjs.map +1 -1
- package/neon-serverless/session.d.cts +13 -8
- package/neon-serverless/session.d.ts +13 -8
- package/neon-serverless/session.js +40 -5
- package/neon-serverless/session.js.map +1 -1
- package/node-postgres/driver.cjs +13 -7
- package/node-postgres/driver.cjs.map +1 -1
- package/node-postgres/driver.d.cts +9 -8
- package/node-postgres/driver.d.ts +9 -8
- package/node-postgres/driver.js +13 -10
- package/node-postgres/driver.js.map +1 -1
- package/node-postgres/migrator.cjs.map +1 -1
- package/node-postgres/migrator.d.cts +2 -1
- package/node-postgres/migrator.d.ts +2 -1
- package/node-postgres/migrator.js.map +1 -1
- package/node-postgres/session.cjs +45 -4
- package/node-postgres/session.cjs.map +1 -1
- package/node-postgres/session.d.cts +13 -8
- package/node-postgres/session.d.ts +13 -8
- package/node-postgres/session.js +45 -4
- package/node-postgres/session.js.map +1 -1
- package/op-sqlite/driver.cjs +22 -5
- package/op-sqlite/driver.cjs.map +1 -1
- package/op-sqlite/driver.d.cts +3 -2
- package/op-sqlite/driver.d.ts +3 -2
- package/op-sqlite/driver.js +12 -8
- package/op-sqlite/driver.js.map +1 -1
- package/op-sqlite/migrator.cjs.map +1 -1
- package/op-sqlite/migrator.d.cts +3 -2
- package/op-sqlite/migrator.d.ts +3 -2
- package/op-sqlite/migrator.js.map +1 -1
- package/op-sqlite/session.cjs +47 -4
- package/op-sqlite/session.cjs.map +1 -1
- package/op-sqlite/session.d.cts +14 -8
- package/op-sqlite/session.d.ts +14 -8
- package/op-sqlite/session.js +47 -4
- package/op-sqlite/session.js.map +1 -1
- package/package.json +260 -945
- package/pg-core/db.cjs +32 -5
- package/pg-core/db.cjs.map +1 -1
- package/pg-core/db.d.cts +16 -9
- package/pg-core/db.d.ts +16 -9
- package/pg-core/db.js +31 -4
- package/pg-core/db.js.map +1 -1
- package/pg-core/dialect.cjs +173 -488
- package/pg-core/dialect.cjs.map +1 -1
- package/pg-core/dialect.d.cts +27 -8
- package/pg-core/dialect.d.ts +27 -8
- package/pg-core/dialect.js +172 -495
- package/pg-core/dialect.js.map +1 -1
- package/{gel-core/query-builders/query.cjs → pg-core/query-builders/_query.cjs} +31 -15
- package/pg-core/query-builders/_query.cjs.map +1 -0
- package/pg-core/query-builders/_query.d.cts +47 -0
- package/pg-core/query-builders/_query.d.ts +47 -0
- package/{gel-core/query-builders/query.js → pg-core/query-builders/_query.js} +19 -15
- package/pg-core/query-builders/_query.js.map +1 -0
- package/pg-core/query-builders/count.cjs.map +1 -1
- package/pg-core/query-builders/count.d.cts +1 -1
- package/pg-core/query-builders/count.d.ts +1 -1
- package/pg-core/query-builders/count.js.map +1 -1
- package/pg-core/query-builders/query.cjs +15 -18
- package/pg-core/query-builders/query.cjs.map +1 -1
- package/pg-core/query-builders/query.d.cts +6 -6
- package/pg-core/query-builders/query.d.ts +6 -6
- package/pg-core/query-builders/query.js +15 -18
- package/pg-core/query-builders/query.js.map +1 -1
- package/pg-core/session.cjs +3 -2
- package/pg-core/session.cjs.map +1 -1
- package/pg-core/session.d.cts +9 -6
- package/pg-core/session.d.ts +9 -6
- package/pg-core/session.js +3 -2
- package/pg-core/session.js.map +1 -1
- package/pg-core/table.cjs +0 -2
- package/pg-core/table.cjs.map +1 -1
- package/pg-core/table.js +0 -2
- package/pg-core/table.js.map +1 -1
- package/pg-proxy/driver.cjs +21 -5
- package/pg-proxy/driver.cjs.map +1 -1
- package/pg-proxy/driver.d.cts +3 -2
- package/pg-proxy/driver.d.ts +3 -2
- package/pg-proxy/driver.js +11 -8
- package/pg-proxy/driver.js.map +1 -1
- package/pg-proxy/migrator.cjs.map +1 -1
- package/pg-proxy/migrator.d.cts +2 -1
- package/pg-proxy/migrator.d.ts +2 -1
- package/pg-proxy/migrator.js.map +1 -1
- package/pg-proxy/session.cjs +37 -2
- package/pg-proxy/session.cjs.map +1 -1
- package/pg-proxy/session.d.cts +13 -8
- package/pg-proxy/session.d.ts +13 -8
- package/pg-proxy/session.js +37 -2
- package/pg-proxy/session.js.map +1 -1
- package/pglite/driver.cjs +23 -7
- package/pglite/driver.cjs.map +1 -1
- package/pglite/driver.d.cts +9 -8
- package/pglite/driver.d.ts +9 -8
- package/pglite/driver.js +13 -10
- package/pglite/driver.js.map +1 -1
- package/pglite/migrator.cjs.map +1 -1
- package/pglite/migrator.d.cts +2 -1
- package/pglite/migrator.d.ts +2 -1
- package/pglite/migrator.js.map +1 -1
- package/pglite/session.cjs +34 -3
- package/pglite/session.cjs.map +1 -1
- package/pglite/session.d.cts +13 -8
- package/pglite/session.d.ts +13 -8
- package/pglite/session.js +34 -3
- package/pglite/session.js.map +1 -1
- package/planetscale-serverless/driver.cjs +22 -5
- package/planetscale-serverless/driver.cjs.map +1 -1
- package/planetscale-serverless/driver.d.cts +7 -6
- package/planetscale-serverless/driver.d.ts +7 -6
- package/planetscale-serverless/driver.js +12 -8
- package/planetscale-serverless/driver.js.map +1 -1
- package/planetscale-serverless/migrator.cjs.map +1 -1
- package/planetscale-serverless/migrator.d.cts +2 -1
- package/planetscale-serverless/migrator.d.ts +2 -1
- package/planetscale-serverless/migrator.js.map +1 -1
- package/planetscale-serverless/session.cjs +45 -5
- package/planetscale-serverless/session.cjs.map +1 -1
- package/planetscale-serverless/session.d.cts +14 -9
- package/planetscale-serverless/session.d.ts +14 -9
- package/planetscale-serverless/session.js +45 -5
- package/planetscale-serverless/session.js.map +1 -1
- package/postgres-js/driver.cjs +6 -5
- package/postgres-js/driver.cjs.map +1 -1
- package/postgres-js/driver.d.cts +7 -6
- package/postgres-js/driver.d.ts +7 -6
- package/postgres-js/driver.js +6 -8
- package/postgres-js/driver.js.map +1 -1
- package/postgres-js/migrator.cjs.map +1 -1
- package/postgres-js/migrator.d.cts +2 -1
- package/postgres-js/migrator.d.ts +2 -1
- package/postgres-js/migrator.js.map +1 -1
- package/postgres-js/session.cjs +51 -6
- package/postgres-js/session.cjs.map +1 -1
- package/postgres-js/session.d.cts +15 -9
- package/postgres-js/session.d.ts +15 -9
- package/postgres-js/session.js +51 -6
- package/postgres-js/session.js.map +1 -1
- package/prisma/mysql/driver.cjs +1 -1
- package/prisma/mysql/driver.cjs.map +1 -1
- package/prisma/mysql/driver.js +1 -1
- package/prisma/mysql/driver.js.map +1 -1
- package/prisma/mysql/session.cjs +3 -0
- package/prisma/mysql/session.cjs.map +1 -1
- package/prisma/mysql/session.d.cts +3 -1
- package/prisma/mysql/session.d.ts +3 -1
- package/prisma/mysql/session.js +3 -0
- package/prisma/mysql/session.js.map +1 -1
- package/prisma/pg/driver.cjs +1 -1
- package/prisma/pg/driver.cjs.map +1 -1
- package/prisma/pg/driver.js +1 -1
- package/prisma/pg/driver.js.map +1 -1
- package/prisma/pg/session.cjs +3 -0
- package/prisma/pg/session.cjs.map +1 -1
- package/prisma/pg/session.d.cts +3 -1
- package/prisma/pg/session.d.ts +3 -1
- package/prisma/pg/session.js +3 -0
- package/prisma/pg/session.js.map +1 -1
- package/prisma/sqlite/driver.cjs +1 -1
- package/prisma/sqlite/driver.cjs.map +1 -1
- package/prisma/sqlite/driver.js +1 -1
- package/prisma/sqlite/driver.js.map +1 -1
- package/prisma/sqlite/session.cjs +3 -0
- package/prisma/sqlite/session.cjs.map +1 -1
- package/prisma/sqlite/session.d.cts +4 -2
- package/prisma/sqlite/session.d.ts +4 -2
- package/prisma/sqlite/session.js +3 -0
- package/prisma/sqlite/session.js.map +1 -1
- package/relations.cjs +596 -245
- package/relations.cjs.map +1 -1
- package/relations.d.cts +292 -140
- package/relations.d.ts +292 -140
- package/relations.js +589 -240
- package/relations.js.map +1 -1
- package/singlestore/driver.cjs +1 -1
- package/singlestore/driver.cjs.map +1 -1
- package/singlestore/driver.d.cts +1 -1
- package/singlestore/driver.d.ts +1 -1
- package/singlestore/driver.js +3 -3
- package/singlestore/driver.js.map +1 -1
- package/singlestore/session.cjs.map +1 -1
- package/singlestore/session.d.cts +4 -4
- package/singlestore/session.d.ts +4 -4
- package/singlestore/session.js.map +1 -1
- package/singlestore-core/db.cjs.map +1 -1
- package/singlestore-core/db.d.cts +3 -3
- package/singlestore-core/db.d.ts +3 -3
- package/singlestore-core/db.js.map +1 -1
- package/singlestore-core/dialect.cjs +16 -6
- package/singlestore-core/dialect.cjs.map +1 -1
- package/singlestore-core/dialect.d.cts +6 -6
- package/singlestore-core/dialect.d.ts +6 -6
- package/singlestore-core/dialect.js +6 -12
- package/singlestore-core/dialect.js.map +1 -1
- package/singlestore-core/query-builders/query.cjs +12 -2
- package/singlestore-core/query-builders/query.cjs.map +1 -1
- package/singlestore-core/query-builders/query.d.cts +6 -6
- package/singlestore-core/query-builders/query.d.ts +6 -6
- package/singlestore-core/query-builders/query.js +2 -4
- package/singlestore-core/query-builders/query.js.map +1 -1
- package/singlestore-core/session.cjs.map +1 -1
- package/singlestore-core/session.d.cts +5 -5
- package/singlestore-core/session.d.ts +5 -5
- package/singlestore-core/session.js.map +1 -1
- package/singlestore-proxy/driver.cjs +1 -1
- package/singlestore-proxy/driver.cjs.map +1 -1
- package/singlestore-proxy/driver.js +3 -3
- package/singlestore-proxy/driver.js.map +1 -1
- package/singlestore-proxy/session.cjs.map +1 -1
- package/singlestore-proxy/session.d.cts +4 -4
- package/singlestore-proxy/session.d.ts +4 -4
- package/singlestore-proxy/session.js.map +1 -1
- package/sql/expressions/conditions.cjs.map +1 -1
- package/sql/expressions/conditions.d.cts +4 -4
- package/sql/expressions/conditions.d.ts +4 -4
- package/sql/expressions/conditions.js.map +1 -1
- package/sql/sql.cjs +21 -0
- package/sql/sql.cjs.map +1 -1
- package/sql/sql.d.cts +8 -8
- package/sql/sql.d.ts +8 -8
- package/sql/sql.js +22 -1
- package/sql/sql.js.map +1 -1
- package/sql-js/driver.cjs +16 -5
- package/sql-js/driver.cjs.map +1 -1
- package/sql-js/driver.d.cts +3 -2
- package/sql-js/driver.d.ts +3 -2
- package/sql-js/driver.js +6 -8
- package/sql-js/driver.js.map +1 -1
- package/sql-js/migrator.cjs.map +1 -1
- package/sql-js/migrator.d.cts +2 -1
- package/sql-js/migrator.d.ts +2 -1
- package/sql-js/migrator.js.map +1 -1
- package/sql-js/session.cjs +71 -36
- package/sql-js/session.cjs.map +1 -1
- package/sql-js/session.d.cts +16 -13
- package/sql-js/session.d.ts +16 -13
- package/sql-js/session.js +71 -36
- package/sql-js/session.js.map +1 -1
- package/sqlite-core/db.cjs +39 -12
- package/sqlite-core/db.cjs.map +1 -1
- package/sqlite-core/db.d.cts +16 -8
- package/sqlite-core/db.d.ts +16 -8
- package/sqlite-core/db.js +38 -11
- package/sqlite-core/db.js.map +1 -1
- package/sqlite-core/dialect.cjs +186 -7
- package/sqlite-core/dialect.cjs.map +1 -1
- package/sqlite-core/dialect.d.cts +31 -9
- package/sqlite-core/dialect.d.ts +31 -9
- package/sqlite-core/dialect.js +185 -14
- package/sqlite-core/dialect.js.map +1 -1
- package/sqlite-core/query-builders/_query.cjs +187 -0
- package/sqlite-core/query-builders/_query.cjs.map +1 -0
- package/sqlite-core/query-builders/_query.d.cts +55 -0
- package/sqlite-core/query-builders/_query.d.ts +55 -0
- package/sqlite-core/query-builders/_query.js +151 -0
- package/sqlite-core/query-builders/_query.js.map +1 -0
- package/sqlite-core/query-builders/count.cjs.map +1 -1
- package/sqlite-core/query-builders/count.d.cts +1 -1
- package/sqlite-core/query-builders/count.d.ts +1 -1
- package/sqlite-core/query-builders/count.js.map +1 -1
- package/sqlite-core/query-builders/delete.cjs.map +1 -1
- package/sqlite-core/query-builders/delete.d.cts +1 -1
- package/sqlite-core/query-builders/delete.d.ts +1 -1
- package/sqlite-core/query-builders/delete.js.map +1 -1
- package/sqlite-core/query-builders/insert.cjs.map +1 -1
- package/sqlite-core/query-builders/insert.d.cts +3 -3
- package/sqlite-core/query-builders/insert.d.ts +3 -3
- package/sqlite-core/query-builders/insert.js.map +1 -1
- package/sqlite-core/query-builders/query.cjs +56 -35
- package/sqlite-core/query-builders/query.cjs.map +1 -1
- package/sqlite-core/query-builders/query.d.cts +18 -17
- package/sqlite-core/query-builders/query.d.ts +18 -17
- package/sqlite-core/query-builders/query.js +56 -35
- package/sqlite-core/query-builders/query.js.map +1 -1
- package/sqlite-core/query-builders/select.cjs.map +1 -1
- package/sqlite-core/query-builders/select.d.cts +3 -3
- package/sqlite-core/query-builders/select.d.ts +3 -3
- package/sqlite-core/query-builders/select.js.map +1 -1
- package/sqlite-core/query-builders/update.cjs.map +1 -1
- package/sqlite-core/query-builders/update.d.cts +3 -3
- package/sqlite-core/query-builders/update.d.ts +3 -3
- package/sqlite-core/query-builders/update.js.map +1 -1
- package/sqlite-core/session.cjs +6 -2
- package/sqlite-core/session.cjs.map +1 -1
- package/sqlite-core/session.d.cts +15 -7
- package/sqlite-core/session.d.ts +15 -7
- package/sqlite-core/session.js +6 -2
- package/sqlite-core/session.js.map +1 -1
- package/sqlite-proxy/driver.cjs +23 -5
- package/sqlite-proxy/driver.cjs.map +1 -1
- package/sqlite-proxy/driver.d.cts +4 -3
- package/sqlite-proxy/driver.d.ts +4 -3
- package/sqlite-proxy/driver.js +13 -5
- package/sqlite-proxy/driver.js.map +1 -1
- package/sqlite-proxy/migrator.cjs.map +1 -1
- package/sqlite-proxy/migrator.d.cts +2 -1
- package/sqlite-proxy/migrator.d.ts +2 -1
- package/sqlite-proxy/migrator.js.map +1 -1
- package/sqlite-proxy/session.cjs +50 -6
- package/sqlite-proxy/session.cjs.map +1 -1
- package/sqlite-proxy/session.d.cts +14 -8
- package/sqlite-proxy/session.d.ts +14 -8
- package/sqlite-proxy/session.js +50 -6
- package/sqlite-proxy/session.js.map +1 -1
- package/table.cjs.map +1 -1
- package/table.d.cts +2 -2
- package/table.d.ts +2 -2
- package/table.js.map +1 -1
- package/tidb-serverless/driver.cjs +22 -5
- package/tidb-serverless/driver.cjs.map +1 -1
- package/tidb-serverless/driver.d.cts +7 -6
- package/tidb-serverless/driver.d.ts +7 -6
- package/tidb-serverless/driver.js +12 -8
- package/tidb-serverless/driver.js.map +1 -1
- package/tidb-serverless/migrator.cjs.map +1 -1
- package/tidb-serverless/migrator.d.cts +2 -1
- package/tidb-serverless/migrator.d.ts +2 -1
- package/tidb-serverless/migrator.js.map +1 -1
- package/tidb-serverless/session.cjs +62 -5
- package/tidb-serverless/session.cjs.map +1 -1
- package/tidb-serverless/session.d.cts +14 -9
- package/tidb-serverless/session.d.ts +14 -9
- package/tidb-serverless/session.js +62 -5
- package/tidb-serverless/session.js.map +1 -1
- package/utils.cjs +2 -2
- package/utils.cjs.map +1 -1
- package/utils.d.cts +3 -1
- package/utils.d.ts +3 -1
- package/utils.js +2 -2
- package/utils.js.map +1 -1
- package/vercel-postgres/driver.cjs +23 -7
- package/vercel-postgres/driver.cjs.map +1 -1
- package/vercel-postgres/driver.d.cts +9 -8
- package/vercel-postgres/driver.d.ts +9 -8
- package/vercel-postgres/driver.js +13 -10
- package/vercel-postgres/driver.js.map +1 -1
- package/vercel-postgres/migrator.cjs.map +1 -1
- package/vercel-postgres/migrator.d.cts +2 -1
- package/vercel-postgres/migrator.d.ts +2 -1
- package/vercel-postgres/migrator.js.map +1 -1
- package/vercel-postgres/session.cjs +34 -4
- package/vercel-postgres/session.cjs.map +1 -1
- package/vercel-postgres/session.d.cts +13 -8
- package/vercel-postgres/session.d.ts +13 -8
- package/vercel-postgres/session.js +34 -4
- package/vercel-postgres/session.js.map +1 -1
- package/version.cjs +1 -1
- package/version.d.cts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/xata-http/driver.cjs +17 -5
- package/xata-http/driver.cjs.map +1 -1
- package/xata-http/driver.d.cts +5 -4
- package/xata-http/driver.d.ts +5 -4
- package/xata-http/driver.js +7 -5
- package/xata-http/driver.js.map +1 -1
- package/xata-http/migrator.cjs.map +1 -1
- package/xata-http/migrator.d.cts +2 -1
- package/xata-http/migrator.d.ts +2 -1
- package/xata-http/migrator.js.map +1 -1
- package/xata-http/session.cjs +30 -2
- package/xata-http/session.cjs.map +1 -1
- package/xata-http/session.d.cts +13 -8
- package/xata-http/session.d.ts +13 -8
- package/xata-http/session.js +30 -2
- package/xata-http/session.js.map +1 -1
- package/gel/driver.cjs +0 -97
- package/gel/driver.cjs.map +0 -1
- package/gel/driver.d.cts +0 -38
- package/gel/driver.d.ts +0 -38
- package/gel/driver.js +0 -74
- package/gel/driver.js.map +0 -1
- package/gel/index.cjs +0 -25
- package/gel/index.cjs.map +0 -1
- package/gel/index.d.cts +0 -2
- package/gel/index.d.ts +0 -2
- package/gel/index.js +0 -3
- package/gel/index.js.map +0 -1
- package/gel/migrator.cjs +0 -5
- package/gel/migrator.cjs.map +0 -1
- package/gel/migrator.d.cts +0 -1
- package/gel/migrator.d.ts +0 -1
- package/gel/migrator.js +0 -4
- package/gel/migrator.js.map +0 -1
- package/gel/session.cjs +0 -139
- package/gel/session.cjs.map +0 -1
- package/gel/session.d.cts +0 -47
- package/gel/session.d.ts +0 -47
- package/gel/session.js +0 -113
- package/gel/session.js.map +0 -1
- package/gel-core/alias.cjs +0 -32
- package/gel-core/alias.cjs.map +0 -1
- package/gel-core/alias.d.cts +0 -4
- package/gel-core/alias.d.ts +0 -4
- package/gel-core/alias.js +0 -8
- package/gel-core/alias.js.map +0 -1
- package/gel-core/checks.cjs +0 -58
- package/gel-core/checks.cjs.map +0 -1
- package/gel-core/checks.d.cts +0 -18
- package/gel-core/checks.d.ts +0 -18
- package/gel-core/checks.js +0 -32
- package/gel-core/checks.js.map +0 -1
- package/gel-core/columns/all.cjs +0 -72
- package/gel-core/columns/all.cjs.map +0 -1
- package/gel-core/columns/all.d.cts +0 -43
- package/gel-core/columns/all.d.ts +0 -43
- package/gel-core/columns/all.js +0 -48
- package/gel-core/columns/all.js.map +0 -1
- package/gel-core/columns/bigint.cjs +0 -54
- package/gel-core/columns/bigint.cjs.map +0 -1
- package/gel-core/columns/bigint.d.cts +0 -23
- package/gel-core/columns/bigint.d.ts +0 -23
- package/gel-core/columns/bigint.js +0 -28
- package/gel-core/columns/bigint.js.map +0 -1
- package/gel-core/columns/bigintT.cjs +0 -60
- package/gel-core/columns/bigintT.cjs.map +0 -1
- package/gel-core/columns/bigintT.d.cts +0 -24
- package/gel-core/columns/bigintT.d.ts +0 -24
- package/gel-core/columns/bigintT.js +0 -34
- package/gel-core/columns/bigintT.js.map +0 -1
- package/gel-core/columns/boolean.cjs +0 -53
- package/gel-core/columns/boolean.cjs.map +0 -1
- package/gel-core/columns/boolean.d.cts +0 -22
- package/gel-core/columns/boolean.d.ts +0 -22
- package/gel-core/columns/boolean.js +0 -27
- package/gel-core/columns/boolean.js.map +0 -1
- package/gel-core/columns/bytes.cjs +0 -56
- package/gel-core/columns/bytes.cjs.map +0 -1
- package/gel-core/columns/bytes.d.cts +0 -22
- package/gel-core/columns/bytes.d.ts +0 -22
- package/gel-core/columns/bytes.js +0 -30
- package/gel-core/columns/bytes.js.map +0 -1
- package/gel-core/columns/common.cjs +0 -213
- package/gel-core/columns/common.cjs.map +0 -1
- package/gel-core/columns/common.d.cts +0 -147
- package/gel-core/columns/common.d.ts +0 -147
- package/gel-core/columns/common.js +0 -184
- package/gel-core/columns/common.js.map +0 -1
- package/gel-core/columns/custom.cjs +0 -77
- package/gel-core/columns/custom.cjs.map +0 -1
- package/gel-core/columns/custom.d.cts +0 -155
- package/gel-core/columns/custom.d.ts +0 -155
- package/gel-core/columns/custom.js +0 -51
- package/gel-core/columns/custom.js.map +0 -1
- package/gel-core/columns/date-duration.cjs +0 -56
- package/gel-core/columns/date-duration.cjs.map +0 -1
- package/gel-core/columns/date-duration.d.cts +0 -23
- package/gel-core/columns/date-duration.d.ts +0 -23
- package/gel-core/columns/date-duration.js +0 -30
- package/gel-core/columns/date-duration.js.map +0 -1
- package/gel-core/columns/date.common.cjs +0 -37
- package/gel-core/columns/date.common.cjs.map +0 -1
- package/gel-core/columns/date.common.d.cts +0 -7
- package/gel-core/columns/date.common.d.ts +0 -7
- package/gel-core/columns/date.common.js +0 -13
- package/gel-core/columns/date.common.js.map +0 -1
- package/gel-core/columns/decimal.cjs +0 -56
- package/gel-core/columns/decimal.cjs.map +0 -1
- package/gel-core/columns/decimal.d.cts +0 -26
- package/gel-core/columns/decimal.d.ts +0 -26
- package/gel-core/columns/decimal.js +0 -30
- package/gel-core/columns/decimal.js.map +0 -1
- package/gel-core/columns/double-precision.cjs +0 -62
- package/gel-core/columns/double-precision.cjs.map +0 -1
- package/gel-core/columns/double-precision.d.cts +0 -23
- package/gel-core/columns/double-precision.d.ts +0 -23
- package/gel-core/columns/double-precision.js +0 -36
- package/gel-core/columns/double-precision.js.map +0 -1
- package/gel-core/columns/duration.cjs +0 -53
- package/gel-core/columns/duration.cjs.map +0 -1
- package/gel-core/columns/duration.d.cts +0 -23
- package/gel-core/columns/duration.d.ts +0 -23
- package/gel-core/columns/duration.js +0 -27
- package/gel-core/columns/duration.js.map +0 -1
- package/gel-core/columns/index.cjs +0 -65
- package/gel-core/columns/index.cjs.map +0 -1
- package/gel-core/columns/index.d.cts +0 -22
- package/gel-core/columns/index.d.ts +0 -22
- package/gel-core/columns/index.js +0 -23
- package/gel-core/columns/index.js.map +0 -1
- package/gel-core/columns/int.common.cjs +0 -67
- package/gel-core/columns/int.common.cjs.map +0 -1
- package/gel-core/columns/int.common.d.cts +0 -15
- package/gel-core/columns/int.common.d.ts +0 -15
- package/gel-core/columns/int.common.js +0 -43
- package/gel-core/columns/int.common.js.map +0 -1
- package/gel-core/columns/integer.cjs +0 -54
- package/gel-core/columns/integer.cjs.map +0 -1
- package/gel-core/columns/integer.d.cts +0 -23
- package/gel-core/columns/integer.d.ts +0 -23
- package/gel-core/columns/integer.js +0 -28
- package/gel-core/columns/integer.js.map +0 -1
- package/gel-core/columns/json.cjs +0 -56
- package/gel-core/columns/json.cjs.map +0 -1
- package/gel-core/columns/json.d.cts +0 -26
- package/gel-core/columns/json.d.ts +0 -26
- package/gel-core/columns/json.js +0 -30
- package/gel-core/columns/json.js.map +0 -1
- package/gel-core/columns/localdate.cjs +0 -57
- package/gel-core/columns/localdate.cjs.map +0 -1
- package/gel-core/columns/localdate.d.cts +0 -24
- package/gel-core/columns/localdate.d.ts +0 -24
- package/gel-core/columns/localdate.js +0 -31
- package/gel-core/columns/localdate.js.map +0 -1
- package/gel-core/columns/localtime.cjs +0 -57
- package/gel-core/columns/localtime.cjs.map +0 -1
- package/gel-core/columns/localtime.d.cts +0 -24
- package/gel-core/columns/localtime.d.ts +0 -24
- package/gel-core/columns/localtime.js +0 -31
- package/gel-core/columns/localtime.js.map +0 -1
- package/gel-core/columns/real.cjs +0 -57
- package/gel-core/columns/real.cjs.map +0 -1
- package/gel-core/columns/real.d.cts +0 -28
- package/gel-core/columns/real.d.ts +0 -28
- package/gel-core/columns/real.js +0 -31
- package/gel-core/columns/real.js.map +0 -1
- package/gel-core/columns/relative-duration.cjs +0 -56
- package/gel-core/columns/relative-duration.cjs.map +0 -1
- package/gel-core/columns/relative-duration.d.cts +0 -23
- package/gel-core/columns/relative-duration.d.ts +0 -23
- package/gel-core/columns/relative-duration.js +0 -30
- package/gel-core/columns/relative-duration.js.map +0 -1
- package/gel-core/columns/smallint.cjs +0 -54
- package/gel-core/columns/smallint.cjs.map +0 -1
- package/gel-core/columns/smallint.d.cts +0 -23
- package/gel-core/columns/smallint.d.ts +0 -23
- package/gel-core/columns/smallint.js +0 -28
- package/gel-core/columns/smallint.js.map +0 -1
- package/gel-core/columns/text.cjs +0 -54
- package/gel-core/columns/text.cjs.map +0 -1
- package/gel-core/columns/text.d.cts +0 -26
- package/gel-core/columns/text.d.ts +0 -26
- package/gel-core/columns/text.js +0 -28
- package/gel-core/columns/text.js.map +0 -1
- package/gel-core/columns/timestamp.cjs +0 -60
- package/gel-core/columns/timestamp.cjs.map +0 -1
- package/gel-core/columns/timestamp.d.cts +0 -28
- package/gel-core/columns/timestamp.d.ts +0 -28
- package/gel-core/columns/timestamp.js +0 -34
- package/gel-core/columns/timestamp.js.map +0 -1
- package/gel-core/columns/timestamptz.cjs +0 -60
- package/gel-core/columns/timestamptz.cjs.map +0 -1
- package/gel-core/columns/timestamptz.d.cts +0 -27
- package/gel-core/columns/timestamptz.d.ts +0 -27
- package/gel-core/columns/timestamptz.js +0 -34
- package/gel-core/columns/timestamptz.js.map +0 -1
- package/gel-core/columns/uuid.cjs +0 -53
- package/gel-core/columns/uuid.cjs.map +0 -1
- package/gel-core/columns/uuid.d.cts +0 -22
- package/gel-core/columns/uuid.d.ts +0 -22
- package/gel-core/columns/uuid.js +0 -27
- package/gel-core/columns/uuid.js.map +0 -1
- package/gel-core/db.cjs +0 -338
- package/gel-core/db.cjs.map +0 -1
- package/gel-core/db.d.cts +0 -281
- package/gel-core/db.d.ts +0 -281
- package/gel-core/db.js +0 -319
- package/gel-core/db.js.map +0 -1
- package/gel-core/dialect.cjs +0 -1142
- package/gel-core/dialect.cjs.map +0 -1
- package/gel-core/dialect.d.cts +0 -62
- package/gel-core/dialect.d.ts +0 -62
- package/gel-core/dialect.js +0 -1128
- package/gel-core/dialect.js.map +0 -1
- package/gel-core/expressions.cjs +0 -49
- package/gel-core/expressions.cjs.map +0 -1
- package/gel-core/expressions.d.cts +0 -8
- package/gel-core/expressions.d.ts +0 -8
- package/gel-core/expressions.js +0 -22
- package/gel-core/expressions.js.map +0 -1
- package/gel-core/foreign-keys.cjs +0 -100
- package/gel-core/foreign-keys.cjs.map +0 -1
- package/gel-core/foreign-keys.d.cts +0 -48
- package/gel-core/foreign-keys.d.ts +0 -48
- package/gel-core/foreign-keys.js +0 -74
- package/gel-core/foreign-keys.js.map +0 -1
- package/gel-core/index.cjs +0 -61
- package/gel-core/index.cjs.map +0 -1
- package/gel-core/index.d.cts +0 -20
- package/gel-core/index.d.ts +0 -20
- package/gel-core/index.js +0 -21
- package/gel-core/index.js.map +0 -1
- package/gel-core/indexes.cjs +0 -149
- package/gel-core/indexes.cjs.map +0 -1
- package/gel-core/indexes.d.cts +0 -79
- package/gel-core/indexes.d.ts +0 -79
- package/gel-core/indexes.js +0 -121
- package/gel-core/indexes.js.map +0 -1
- package/gel-core/policies.cjs +0 -58
- package/gel-core/policies.cjs.map +0 -1
- package/gel-core/policies.d.cts +0 -24
- package/gel-core/policies.d.ts +0 -24
- package/gel-core/policies.js +0 -33
- package/gel-core/policies.js.map +0 -1
- package/gel-core/primary-keys.cjs +0 -68
- package/gel-core/primary-keys.cjs.map +0 -1
- package/gel-core/primary-keys.d.cts +0 -30
- package/gel-core/primary-keys.d.ts +0 -30
- package/gel-core/primary-keys.js +0 -42
- package/gel-core/primary-keys.js.map +0 -1
- package/gel-core/query-builders/count.cjs +0 -73
- package/gel-core/query-builders/count.cjs.map +0 -1
- package/gel-core/query-builders/count.d.cts +0 -25
- package/gel-core/query-builders/count.d.ts +0 -25
- package/gel-core/query-builders/count.js +0 -49
- package/gel-core/query-builders/count.js.map +0 -1
- package/gel-core/query-builders/delete.cjs +0 -105
- package/gel-core/query-builders/delete.cjs.map +0 -1
- package/gel-core/query-builders/delete.d.cts +0 -99
- package/gel-core/query-builders/delete.d.ts +0 -99
- package/gel-core/query-builders/delete.js +0 -81
- package/gel-core/query-builders/delete.js.map +0 -1
- package/gel-core/query-builders/index.cjs +0 -35
- package/gel-core/query-builders/index.cjs.map +0 -1
- package/gel-core/query-builders/index.d.cts +0 -7
- package/gel-core/query-builders/index.d.ts +0 -7
- package/gel-core/query-builders/index.js +0 -8
- package/gel-core/query-builders/index.js.map +0 -1
- package/gel-core/query-builders/insert.cjs +0 -218
- package/gel-core/query-builders/insert.cjs.map +0 -1
- package/gel-core/query-builders/insert.d.cts +0 -116
- package/gel-core/query-builders/insert.d.ts +0 -116
- package/gel-core/query-builders/insert.js +0 -193
- package/gel-core/query-builders/insert.js.map +0 -1
- package/gel-core/query-builders/query-builder.cjs +0 -114
- package/gel-core/query-builders/query-builder.cjs.map +0 -1
- package/gel-core/query-builders/query-builder.d.cts +0 -40
- package/gel-core/query-builders/query-builder.d.ts +0 -40
- package/gel-core/query-builders/query-builder.js +0 -90
- package/gel-core/query-builders/query-builder.js.map +0 -1
- package/gel-core/query-builders/query.cjs.map +0 -1
- package/gel-core/query-builders/query.d.cts +0 -46
- package/gel-core/query-builders/query.d.ts +0 -46
- package/gel-core/query-builders/query.js.map +0 -1
- package/gel-core/query-builders/raw.cjs +0 -57
- package/gel-core/query-builders/raw.cjs.map +0 -1
- package/gel-core/query-builders/raw.d.cts +0 -22
- package/gel-core/query-builders/raw.d.ts +0 -22
- package/gel-core/query-builders/raw.js +0 -33
- package/gel-core/query-builders/raw.js.map +0 -1
- package/gel-core/query-builders/refresh-materialized-view.cjs +0 -77
- package/gel-core/query-builders/refresh-materialized-view.cjs.map +0 -1
- package/gel-core/query-builders/refresh-materialized-view.d.cts +0 -27
- package/gel-core/query-builders/refresh-materialized-view.d.ts +0 -27
- package/gel-core/query-builders/refresh-materialized-view.js +0 -53
- package/gel-core/query-builders/refresh-materialized-view.js.map +0 -1
- package/gel-core/query-builders/select.cjs +0 -775
- package/gel-core/query-builders/select.cjs.map +0 -1
- package/gel-core/query-builders/select.d.cts +0 -721
- package/gel-core/query-builders/select.d.ts +0 -721
- package/gel-core/query-builders/select.js +0 -748
- package/gel-core/query-builders/select.js.map +0 -1
- package/gel-core/query-builders/select.types.cjs +0 -17
- package/gel-core/query-builders/select.types.cjs.map +0 -1
- package/gel-core/query-builders/select.types.d.cts +0 -138
- package/gel-core/query-builders/select.types.d.ts +0 -138
- package/gel-core/query-builders/select.types.js +0 -1
- package/gel-core/query-builders/select.types.js.map +0 -1
- package/gel-core/query-builders/update.cjs +0 -226
- package/gel-core/query-builders/update.cjs.map +0 -1
- package/gel-core/query-builders/update.d.cts +0 -166
- package/gel-core/query-builders/update.d.ts +0 -166
- package/gel-core/query-builders/update.js +0 -205
- package/gel-core/query-builders/update.js.map +0 -1
- package/gel-core/roles.cjs +0 -57
- package/gel-core/roles.cjs.map +0 -1
- package/gel-core/roles.d.cts +0 -13
- package/gel-core/roles.d.ts +0 -13
- package/gel-core/roles.js +0 -32
- package/gel-core/roles.js.map +0 -1
- package/gel-core/schema.cjs +0 -74
- package/gel-core/schema.cjs.map +0 -1
- package/gel-core/schema.d.cts +0 -15
- package/gel-core/schema.d.ts +0 -15
- package/gel-core/schema.js +0 -48
- package/gel-core/schema.js.map +0 -1
- package/gel-core/sequence.cjs +0 -52
- package/gel-core/sequence.cjs.map +0 -1
- package/gel-core/sequence.d.cts +0 -18
- package/gel-core/sequence.d.ts +0 -18
- package/gel-core/sequence.js +0 -25
- package/gel-core/sequence.js.map +0 -1
- package/gel-core/session.cjs +0 -94
- package/gel-core/session.cjs.map +0 -1
- package/gel-core/session.d.cts +0 -56
- package/gel-core/session.d.ts +0 -56
- package/gel-core/session.js +0 -68
- package/gel-core/session.js.map +0 -1
- package/gel-core/subquery.cjs +0 -17
- package/gel-core/subquery.cjs.map +0 -1
- package/gel-core/subquery.d.cts +0 -5
- package/gel-core/subquery.d.ts +0 -5
- package/gel-core/subquery.js +0 -1
- package/gel-core/subquery.js.map +0 -1
- package/gel-core/table.cjs +0 -100
- package/gel-core/table.cjs.map +0 -1
- package/gel-core/table.d.cts +0 -95
- package/gel-core/table.d.ts +0 -95
- package/gel-core/table.js +0 -71
- package/gel-core/table.js.map +0 -1
- package/gel-core/unique-constraint.cjs +0 -89
- package/gel-core/unique-constraint.cjs.map +0 -1
- package/gel-core/unique-constraint.d.cts +0 -25
- package/gel-core/unique-constraint.d.ts +0 -25
- package/gel-core/unique-constraint.js +0 -61
- package/gel-core/unique-constraint.js.map +0 -1
- package/gel-core/utils.cjs +0 -100
- package/gel-core/utils.cjs.map +0 -1
- package/gel-core/utils.d.cts +0 -51
- package/gel-core/utils.d.ts +0 -51
- package/gel-core/utils.js +0 -74
- package/gel-core/utils.js.map +0 -1
- package/gel-core/view-base.cjs +0 -33
- package/gel-core/view-base.cjs.map +0 -1
- package/gel-core/view-base.d.cts +0 -8
- package/gel-core/view-base.d.ts +0 -8
- package/gel-core/view-base.js +0 -9
- package/gel-core/view-base.js.map +0 -1
- package/gel-core/view-common.cjs +0 -29
- package/gel-core/view-common.cjs.map +0 -1
- package/gel-core/view-common.d.cts +0 -1
- package/gel-core/view-common.d.ts +0 -1
- package/gel-core/view-common.js +0 -5
- package/gel-core/view-common.js.map +0 -1
- package/gel-core/view.cjs +0 -302
- package/gel-core/view.cjs.map +0 -1
- package/gel-core/view.d.cts +0 -150
- package/gel-core/view.d.ts +0 -150
- package/gel-core/view.js +0 -268
- package/gel-core/view.js.map +0 -1
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { Client } from "@planetscale/database";
|
|
2
|
+
import * as V1 from "../_relations.js";
|
|
2
3
|
import { entityKind } from "../entity.js";
|
|
3
4
|
import { DefaultLogger } from "../logger.js";
|
|
4
5
|
import { MySqlDatabase } from "../mysql-core/db.js";
|
|
5
6
|
import { MySqlDialect } from "../mysql-core/dialect.js";
|
|
6
|
-
import {
|
|
7
|
-
createTableRelationsHelpers,
|
|
8
|
-
extractTablesRelationalConfig
|
|
9
|
-
} from "../relations.js";
|
|
10
7
|
import { isConfig } from "../utils.js";
|
|
11
8
|
import { PlanetscaleSession } from "./session.js";
|
|
12
9
|
class PlanetScaleDatabase extends MySqlDatabase {
|
|
@@ -36,9 +33,9 @@ const db = drizzle(client);
|
|
|
36
33
|
}
|
|
37
34
|
let schema;
|
|
38
35
|
if (config.schema) {
|
|
39
|
-
const tablesConfig = extractTablesRelationalConfig(
|
|
36
|
+
const tablesConfig = V1.extractTablesRelationalConfig(
|
|
40
37
|
config.schema,
|
|
41
|
-
createTableRelationsHelpers
|
|
38
|
+
V1.createTableRelationsHelpers
|
|
42
39
|
);
|
|
43
40
|
schema = {
|
|
44
41
|
fullSchema: config.schema,
|
|
@@ -46,8 +43,15 @@ const db = drizzle(client);
|
|
|
46
43
|
tableNamesMap: tablesConfig.tableNamesMap
|
|
47
44
|
};
|
|
48
45
|
}
|
|
49
|
-
const
|
|
50
|
-
const
|
|
46
|
+
const relations = config.relations;
|
|
47
|
+
const session = new PlanetscaleSession(client, dialect, void 0, relations, schema, { logger });
|
|
48
|
+
const db = new PlanetScaleDatabase(
|
|
49
|
+
dialect,
|
|
50
|
+
session,
|
|
51
|
+
relations,
|
|
52
|
+
schema,
|
|
53
|
+
"planetscale"
|
|
54
|
+
);
|
|
51
55
|
db.$client = client;
|
|
52
56
|
return db;
|
|
53
57
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/planetscale-serverless/driver.ts"],"sourcesContent":["import type { Config } from '@planetscale/database';\nimport { Client } from '@planetscale/database';\nimport { entityKind } from '~/entity.ts';\nimport type { Logger } from '~/logger.ts';\nimport { DefaultLogger } from '~/logger.ts';\nimport { MySqlDatabase } from '~/mysql-core/db.ts';\nimport { MySqlDialect } from '~/mysql-core/dialect.ts';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../src/planetscale-serverless/driver.ts"],"sourcesContent":["import type { Config } from '@planetscale/database';\nimport { Client } from '@planetscale/database';\nimport * as V1 from '~/_relations.ts';\nimport { entityKind } from '~/entity.ts';\nimport type { Logger } from '~/logger.ts';\nimport { DefaultLogger } from '~/logger.ts';\nimport { MySqlDatabase } from '~/mysql-core/db.ts';\nimport { MySqlDialect } from '~/mysql-core/dialect.ts';\nimport type { AnyRelations, EmptyRelations } from '~/relations.ts';\nimport { type DrizzleConfig, isConfig } from '~/utils.ts';\nimport type { PlanetScalePreparedQueryHKT, PlanetscaleQueryResultHKT } from './session.ts';\nimport { PlanetscaleSession } from './session.ts';\n\nexport interface PlanetscaleSDriverOptions {\n\tlogger?: Logger;\n}\n\nexport class PlanetScaleDatabase<\n\tTSchema extends Record<string, unknown> = Record<string, never>,\n\tTRelations extends AnyRelations = EmptyRelations,\n> extends MySqlDatabase<PlanetscaleQueryResultHKT, PlanetScalePreparedQueryHKT, TSchema, TRelations> {\n\tstatic override readonly [entityKind]: string = 'PlanetScaleDatabase';\n}\n\nfunction construct<\n\tTSchema extends Record<string, unknown> = Record<string, never>,\n\tTRelations extends AnyRelations = EmptyRelations,\n\tTClient extends Client = Client,\n>(\n\tclient: TClient,\n\tconfig: DrizzleConfig<TSchema, TRelations> = {},\n): PlanetScaleDatabase<TSchema, TRelations> & {\n\t$client: TClient;\n} {\n\t// Client is not Drizzle Object, so we can ignore this rule here\n\t// eslint-disable-next-line no-instanceof/no-instanceof\n\tif (!(client instanceof Client)) {\n\t\tthrow new Error(`Warning: You need to pass an instance of Client:\n\nimport { Client } from \"@planetscale/database\";\n\nconst client = new Client({\n host: process.env[\"DATABASE_HOST\"],\n username: process.env[\"DATABASE_USERNAME\"],\n password: process.env[\"DATABASE_PASSWORD\"],\n});\n\nconst db = drizzle(client);\n\t\t`);\n\t}\n\n\tconst dialect = new MySqlDialect({ casing: config.casing });\n\tlet logger;\n\tif (config.logger === true) {\n\t\tlogger = new DefaultLogger();\n\t} else if (config.logger !== false) {\n\t\tlogger = config.logger;\n\t}\n\n\tlet schema: V1.RelationalSchemaConfig<V1.TablesRelationalConfig> | undefined;\n\tif (config.schema) {\n\t\tconst tablesConfig = V1.extractTablesRelationalConfig(\n\t\t\tconfig.schema,\n\t\t\tV1.createTableRelationsHelpers,\n\t\t);\n\t\tschema = {\n\t\t\tfullSchema: config.schema,\n\t\t\tschema: tablesConfig.tables,\n\t\t\ttableNamesMap: tablesConfig.tableNamesMap,\n\t\t};\n\t}\n\n\tconst relations = config.relations;\n\tconst session = new PlanetscaleSession(client, dialect, undefined, relations, schema, { logger });\n\tconst db = new PlanetScaleDatabase(\n\t\tdialect,\n\t\tsession,\n\t\trelations,\n\t\tschema as V1.RelationalSchemaConfig<any>,\n\t\t'planetscale',\n\t) as PlanetScaleDatabase<TSchema, TRelations>;\n\t(<any> db).$client = client;\n\n\treturn db as any;\n}\n\nexport function drizzle<\n\tTSchema extends Record<string, unknown> = Record<string, never>,\n\tTRelations extends AnyRelations = EmptyRelations,\n\tTClient extends Client = Client,\n>(\n\t...params: [\n\t\tTClient | string,\n\t] | [\n\t\tTClient | string,\n\t\tDrizzleConfig<TSchema, TRelations>,\n\t] | [\n\t\t(\n\t\t\t& DrizzleConfig<TSchema, TRelations>\n\t\t\t& ({\n\t\t\t\tconnection: string | Config;\n\t\t\t} | {\n\t\t\t\tclient: TClient;\n\t\t\t})\n\t\t),\n\t]\n): PlanetScaleDatabase<TSchema, TRelations> & {\n\t$client: TClient;\n} {\n\tif (typeof params[0] === 'string') {\n\t\tconst instance = new Client({\n\t\t\turl: params[0],\n\t\t});\n\n\t\treturn construct(instance, params[1]) as any;\n\t}\n\n\tif (isConfig(params[0])) {\n\t\tconst { connection, client, ...drizzleConfig } = params[0] as\n\t\t\t& { connection?: Config | string; client?: TClient }\n\t\t\t& DrizzleConfig;\n\n\t\tif (client) return construct(client, drizzleConfig) as any;\n\n\t\tconst instance = typeof connection === 'string'\n\t\t\t? new Client({\n\t\t\t\turl: connection,\n\t\t\t})\n\t\t\t: new Client(\n\t\t\t\tconnection!,\n\t\t\t);\n\n\t\treturn construct(instance, drizzleConfig) as any;\n\t}\n\n\treturn construct(params[0] as TClient, params[1] as DrizzleConfig<TSchema, TRelations> | undefined) as any;\n}\n\nexport namespace drizzle {\n\texport function mock<\n\t\tTSchema extends Record<string, unknown> = Record<string, never>,\n\t\tTRelations extends AnyRelations = EmptyRelations,\n\t>(\n\t\tconfig?: DrizzleConfig<TSchema, TRelations>,\n\t): PlanetScaleDatabase<TSchema, TRelations> & {\n\t\t$client: '$client is not available on drizzle.mock()';\n\t} {\n\t\treturn construct({} as any, config) as any;\n\t}\n}\n"],"mappings":"AACA,SAAS,cAAc;AACvB,YAAY,QAAQ;AACpB,SAAS,kBAAkB;AAE3B,SAAS,qBAAqB;AAC9B,SAAS,qBAAqB;AAC9B,SAAS,oBAAoB;AAE7B,SAA6B,gBAAgB;AAE7C,SAAS,0BAA0B;AAM5B,MAAM,4BAGH,cAA2F;AAAA,EACpG,QAA0B,UAAU,IAAY;AACjD;AAEA,SAAS,UAKR,QACA,SAA6C,CAAC,GAG7C;AAGD,MAAI,EAAE,kBAAkB,SAAS;AAChC,UAAM,IAAI,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAWf;AAAA,EACF;AAEA,QAAM,UAAU,IAAI,aAAa,EAAE,QAAQ,OAAO,OAAO,CAAC;AAC1D,MAAI;AACJ,MAAI,OAAO,WAAW,MAAM;AAC3B,aAAS,IAAI,cAAc;AAAA,EAC5B,WAAW,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|
-
{"version":3,"sources":["../../src/planetscale-serverless/migrator.ts"],"sourcesContent":["import type { MigrationConfig } from '~/migrator.ts';\nimport { readMigrationFiles } from '~/migrator.ts';\nimport type { PlanetScaleDatabase } from './driver.ts';\n\nexport async function migrate<TSchema extends Record<string, unknown
|
|
1
|
+
{"version":3,"sources":["../../src/planetscale-serverless/migrator.ts"],"sourcesContent":["import type { MigrationConfig } from '~/migrator.ts';\nimport { readMigrationFiles } from '~/migrator.ts';\nimport type { AnyRelations } from '~/relations.ts';\nimport type { PlanetScaleDatabase } from './driver.ts';\n\nexport async function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(\n\tdb: PlanetScaleDatabase<TSchema, TRelations>,\n\tconfig: MigrationConfig,\n) {\n\tconst migrations = readMigrationFiles(config);\n\n\tawait db.dialect.migrate(migrations, db.session, config);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sBAAmC;AAInC,eAAsB,QACrB,IACA,QACC;AACD,QAAM,iBAAa,oCAAmB,MAAM;AAE5C,QAAM,GAAG,QAAQ,QAAQ,YAAY,GAAG,SAAS,MAAM;AACxD;","names":[]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { MigrationConfig } from "../migrator.cjs";
|
|
2
|
+
import type { AnyRelations } from "../relations.cjs";
|
|
2
3
|
import type { PlanetScaleDatabase } from "./driver.cjs";
|
|
3
|
-
export declare function migrate<TSchema extends Record<string, unknown
|
|
4
|
+
export declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: PlanetScaleDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { MigrationConfig } from "../migrator.js";
|
|
2
|
+
import type { AnyRelations } from "../relations.js";
|
|
2
3
|
import type { PlanetScaleDatabase } from "./driver.js";
|
|
3
|
-
export declare function migrate<TSchema extends Record<string, unknown
|
|
4
|
+
export declare function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(db: PlanetScaleDatabase<TSchema, TRelations>, config: MigrationConfig): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/planetscale-serverless/migrator.ts"],"sourcesContent":["import type { MigrationConfig } from '~/migrator.ts';\nimport { readMigrationFiles } from '~/migrator.ts';\nimport type { PlanetScaleDatabase } from './driver.ts';\n\nexport async function migrate<TSchema extends Record<string, unknown
|
|
1
|
+
{"version":3,"sources":["../../src/planetscale-serverless/migrator.ts"],"sourcesContent":["import type { MigrationConfig } from '~/migrator.ts';\nimport { readMigrationFiles } from '~/migrator.ts';\nimport type { AnyRelations } from '~/relations.ts';\nimport type { PlanetScaleDatabase } from './driver.ts';\n\nexport async function migrate<TSchema extends Record<string, unknown>, TRelations extends AnyRelations>(\n\tdb: PlanetScaleDatabase<TSchema, TRelations>,\n\tconfig: MigrationConfig,\n) {\n\tconst migrations = readMigrationFiles(config);\n\n\tawait db.dialect.migrate(migrations, db.session, config);\n}\n"],"mappings":"AACA,SAAS,0BAA0B;AAInC,eAAsB,QACrB,IACA,QACC;AACD,QAAM,aAAa,mBAAmB,MAAM;AAE5C,QAAM,GAAG,QAAQ,QAAQ,YAAY,GAAG,SAAS,MAAM;AACxD;","names":[]}
|
|
@@ -30,7 +30,7 @@ var import_session = require("../mysql-core/session.cjs");
|
|
|
30
30
|
var import_sql = require("../sql/sql.cjs");
|
|
31
31
|
var import_utils = require("../utils.cjs");
|
|
32
32
|
class PlanetScalePreparedQuery extends import_session.MySqlPreparedQuery {
|
|
33
|
-
constructor(client, queryString, params, logger, fields, customResultMapper, generatedIds, returningIds) {
|
|
33
|
+
constructor(client, queryString, params, logger, fields, customResultMapper, generatedIds, returningIds, isRqbV2Query) {
|
|
34
34
|
super();
|
|
35
35
|
this.client = client;
|
|
36
36
|
this.queryString = queryString;
|
|
@@ -40,11 +40,14 @@ class PlanetScalePreparedQuery extends import_session.MySqlPreparedQuery {
|
|
|
40
40
|
this.customResultMapper = customResultMapper;
|
|
41
41
|
this.generatedIds = generatedIds;
|
|
42
42
|
this.returningIds = returningIds;
|
|
43
|
+
this.isRqbV2Query = isRqbV2Query;
|
|
43
44
|
}
|
|
44
45
|
static [import_entity.entityKind] = "PlanetScalePreparedQuery";
|
|
45
46
|
rawQuery = { as: "object" };
|
|
46
47
|
query = { as: "array" };
|
|
47
48
|
async execute(placeholderValues = {}) {
|
|
49
|
+
if (this.isRqbV2Query)
|
|
50
|
+
return this.executeRqbV2(placeholderValues);
|
|
48
51
|
const params = (0, import_sql.fillPlaceholders)(this.params, placeholderValues);
|
|
49
52
|
this.logger.logQuery(this.queryString, params);
|
|
50
53
|
const {
|
|
@@ -89,14 +92,29 @@ class PlanetScalePreparedQuery extends import_session.MySqlPreparedQuery {
|
|
|
89
92
|
}
|
|
90
93
|
return rows.map((row) => (0, import_utils.mapResultRow)(fields, row, joinsNotNullableMap));
|
|
91
94
|
}
|
|
95
|
+
async executeRqbV2(placeholderValues = {}) {
|
|
96
|
+
const params = (0, import_sql.fillPlaceholders)(this.params, placeholderValues);
|
|
97
|
+
this.logger.logQuery(this.queryString, params);
|
|
98
|
+
const {
|
|
99
|
+
client,
|
|
100
|
+
queryString,
|
|
101
|
+
rawQuery,
|
|
102
|
+
customResultMapper
|
|
103
|
+
} = this;
|
|
104
|
+
const res = await client.execute(queryString, params, rawQuery);
|
|
105
|
+
return customResultMapper(
|
|
106
|
+
res.rows
|
|
107
|
+
);
|
|
108
|
+
}
|
|
92
109
|
iterator(_placeholderValues) {
|
|
93
110
|
throw new Error("Streaming is not supported by the PlanetScale Serverless driver");
|
|
94
111
|
}
|
|
95
112
|
}
|
|
96
113
|
class PlanetscaleSession extends import_session.MySqlSession {
|
|
97
|
-
constructor(baseClient, dialect, tx, schema, options = {}) {
|
|
114
|
+
constructor(baseClient, dialect, tx, relations, schema, options = {}) {
|
|
98
115
|
super(dialect);
|
|
99
116
|
this.baseClient = baseClient;
|
|
117
|
+
this.relations = relations;
|
|
100
118
|
this.schema = schema;
|
|
101
119
|
this.options = options;
|
|
102
120
|
this.client = tx ?? baseClient;
|
|
@@ -117,6 +135,19 @@ class PlanetscaleSession extends import_session.MySqlSession {
|
|
|
117
135
|
returningIds
|
|
118
136
|
);
|
|
119
137
|
}
|
|
138
|
+
prepareRelationalQuery(query, fields, customResultMapper, generatedIds, returningIds) {
|
|
139
|
+
return new PlanetScalePreparedQuery(
|
|
140
|
+
this.client,
|
|
141
|
+
query.sql,
|
|
142
|
+
query.params,
|
|
143
|
+
this.logger,
|
|
144
|
+
fields,
|
|
145
|
+
customResultMapper,
|
|
146
|
+
generatedIds,
|
|
147
|
+
returningIds,
|
|
148
|
+
true
|
|
149
|
+
);
|
|
150
|
+
}
|
|
120
151
|
async query(query, params) {
|
|
121
152
|
this.logger.logQuery(query, params);
|
|
122
153
|
return await this.client.execute(query, params, { as: "array" });
|
|
@@ -137,10 +168,18 @@ class PlanetscaleSession extends import_session.MySqlSession {
|
|
|
137
168
|
}
|
|
138
169
|
transaction(transaction) {
|
|
139
170
|
return this.baseClient.transaction((pstx) => {
|
|
140
|
-
const session = new PlanetscaleSession(
|
|
171
|
+
const session = new PlanetscaleSession(
|
|
172
|
+
this.baseClient,
|
|
173
|
+
this.dialect,
|
|
174
|
+
pstx,
|
|
175
|
+
this.relations,
|
|
176
|
+
this.schema,
|
|
177
|
+
this.options
|
|
178
|
+
);
|
|
141
179
|
const tx = new PlanetScaleTransaction(
|
|
142
180
|
this.dialect,
|
|
143
181
|
session,
|
|
182
|
+
this.relations,
|
|
144
183
|
this.schema
|
|
145
184
|
);
|
|
146
185
|
return transaction(tx);
|
|
@@ -149,14 +188,15 @@ class PlanetscaleSession extends import_session.MySqlSession {
|
|
|
149
188
|
}
|
|
150
189
|
class PlanetScaleTransaction extends import_session.MySqlTransaction {
|
|
151
190
|
static [import_entity.entityKind] = "PlanetScaleTransaction";
|
|
152
|
-
constructor(dialect, session, schema, nestedIndex = 0) {
|
|
153
|
-
super(dialect, session, schema, nestedIndex, "planetscale");
|
|
191
|
+
constructor(dialect, session, relations, schema, nestedIndex = 0) {
|
|
192
|
+
super(dialect, session, relations, schema, nestedIndex, "planetscale");
|
|
154
193
|
}
|
|
155
194
|
async transaction(transaction) {
|
|
156
195
|
const savepointName = `sp${this.nestedIndex + 1}`;
|
|
157
196
|
const tx = new PlanetScaleTransaction(
|
|
158
197
|
this.dialect,
|
|
159
198
|
this.session,
|
|
199
|
+
this.relations,
|
|
160
200
|
this.schema,
|
|
161
201
|
this.nestedIndex + 1
|
|
162
202
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/planetscale-serverless/session.ts"],"sourcesContent":["import type { Client, Connection, ExecutedQuery, Transaction } from '@planetscale/database';\nimport { Column } from '~/column.ts';\nimport { entityKind, is } from '~/entity.ts';\nimport type { Logger } from '~/logger.ts';\nimport { NoopLogger } from '~/logger.ts';\nimport type { MySqlDialect } from '~/mysql-core/dialect.ts';\nimport type { SelectedFieldsOrdered } from '~/mysql-core/query-builders/select.types.ts';\nimport {\n\tMySqlPreparedQuery,\n\ttype MySqlPreparedQueryConfig,\n\ttype MySqlPreparedQueryHKT,\n\ttype MySqlQueryResultHKT,\n\tMySqlSession,\n\tMySqlTransaction,\n} from '~/mysql-core/session.ts';\nimport type { RelationalSchemaConfig, TablesRelationalConfig } from '~/relations.ts';\nimport { fillPlaceholders, type Query, type SQL, sql } from '~/sql/sql.ts';\nimport { type Assume, mapResultRow } from '~/utils.ts';\n\nexport class PlanetScalePreparedQuery<T extends MySqlPreparedQueryConfig> extends MySqlPreparedQuery<T> {\n\tstatic override readonly [entityKind]: string = 'PlanetScalePreparedQuery';\n\n\tprivate rawQuery = { as: 'object' } as const;\n\tprivate query = { as: 'array' } as const;\n\n\tconstructor(\n\t\tprivate client: Client | Transaction | Connection,\n\t\tprivate queryString: string,\n\t\tprivate params: unknown[],\n\t\tprivate logger: Logger,\n\t\tprivate fields: SelectedFieldsOrdered | undefined,\n\t\tprivate customResultMapper?: (rows: unknown[][]) => T['execute'],\n\t\t// Keys that were used in $default and the value that was generated for them\n\t\tprivate generatedIds?: Record<string, unknown>[],\n\t\t// Keys that should be returned, it has the column with all properries + key from object\n\t\tprivate returningIds?: SelectedFieldsOrdered,\n\t) {\n\t\tsuper();\n\t}\n\n\tasync execute(placeholderValues: Record<string, unknown> | undefined = {}): Promise<T['execute']> {\n\t\tconst params = fillPlaceholders(this.params, placeholderValues);\n\n\t\tthis.logger.logQuery(this.queryString, params);\n\n\t\tconst {\n\t\t\tfields,\n\t\t\tclient,\n\t\t\tqueryString,\n\t\t\trawQuery,\n\t\t\tquery,\n\t\t\tjoinsNotNullableMap,\n\t\t\tcustomResultMapper,\n\t\t\treturningIds,\n\t\t\tgeneratedIds,\n\t\t} = this;\n\t\tif (!fields && !customResultMapper) {\n\t\t\tconst res = await client.execute(queryString, params, rawQuery);\n\n\t\t\tconst insertId = Number.parseFloat(res.insertId);\n\t\t\tconst affectedRows = res.rowsAffected;\n\n\t\t\t// for each row, I need to check keys from\n\t\t\tif (returningIds) {\n\t\t\t\tconst returningResponse = [];\n\t\t\t\tlet j = 0;\n\t\t\t\tfor (let i = insertId; i < insertId + affectedRows; i++) {\n\t\t\t\t\tfor (const column of returningIds) {\n\t\t\t\t\t\tconst key = returningIds[0]!.path[0]!;\n\t\t\t\t\t\tif (is(column.field, Column)) {\n\t\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\t\tif (column.field.primary && column.field.autoIncrement) {\n\t\t\t\t\t\t\t\treturningResponse.push({ [key]: i });\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (column.field.defaultFn && generatedIds) {\n\t\t\t\t\t\t\t\t// generatedIds[rowIdx][key]\n\t\t\t\t\t\t\t\treturningResponse.push({ [key]: generatedIds[j]![key] });\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tj++;\n\t\t\t\t}\n\t\t\t\treturn returningResponse;\n\t\t\t}\n\t\t\treturn res;\n\t\t}\n\t\tconst { rows } = await client.execute(queryString, params, query);\n\n\t\tif (customResultMapper) {\n\t\t\treturn customResultMapper(rows as unknown[][]);\n\t\t}\n\n\t\treturn rows.map((row) => mapResultRow<T['execute']>(fields!, row as unknown[], joinsNotNullableMap));\n\t}\n\n\toverride iterator(_placeholderValues?: Record<string, unknown>): AsyncGenerator<T['iterator']> {\n\t\tthrow new Error('Streaming is not supported by the PlanetScale Serverless driver');\n\t}\n}\n\nexport interface PlanetscaleSessionOptions {\n\tlogger?: Logger;\n}\n\nexport class PlanetscaleSession<\n\tTFullSchema extends Record<string, unknown>,\n\tTSchema extends TablesRelationalConfig,\n> extends MySqlSession<MySqlQueryResultHKT, PlanetScalePreparedQueryHKT, TFullSchema, TSchema> {\n\tstatic override readonly [entityKind]: string = 'PlanetscaleSession';\n\n\tprivate logger: Logger;\n\tprivate client: Client | Transaction | Connection;\n\n\tconstructor(\n\t\tprivate baseClient: Client | Connection,\n\t\tdialect: MySqlDialect,\n\t\ttx: Transaction | undefined,\n\t\tprivate schema: RelationalSchemaConfig<TSchema> | undefined,\n\t\tprivate options: PlanetscaleSessionOptions = {},\n\t) {\n\t\tsuper(dialect);\n\t\tthis.client = tx ?? baseClient;\n\t\tthis.logger = options.logger ?? new NoopLogger();\n\t}\n\n\tprepareQuery<T extends MySqlPreparedQueryConfig = MySqlPreparedQueryConfig>(\n\t\tquery: Query,\n\t\tfields: SelectedFieldsOrdered | undefined,\n\t\tcustomResultMapper?: (rows: unknown[][]) => T['execute'],\n\t\tgeneratedIds?: Record<string, unknown>[],\n\t\treturningIds?: SelectedFieldsOrdered,\n\t): MySqlPreparedQuery<T> {\n\t\treturn new PlanetScalePreparedQuery(\n\t\t\tthis.client,\n\t\t\tquery.sql,\n\t\t\tquery.params,\n\t\t\tthis.logger,\n\t\t\tfields,\n\t\t\tcustomResultMapper,\n\t\t\tgeneratedIds,\n\t\t\treturningIds,\n\t\t);\n\t}\n\n\tasync query(query: string, params: unknown[]): Promise<ExecutedQuery> {\n\t\tthis.logger.logQuery(query, params);\n\n\t\treturn await this.client.execute(query, params, { as: 'array' });\n\t}\n\n\tasync queryObjects(\n\t\tquery: string,\n\t\tparams: unknown[],\n\t): Promise<ExecutedQuery> {\n\t\treturn this.client.execute(query, params, { as: 'object' });\n\t}\n\n\toverride all<T = unknown>(query: SQL): Promise<T[]> {\n\t\tconst querySql = this.dialect.sqlToQuery(query);\n\t\tthis.logger.logQuery(querySql.sql, querySql.params);\n\n\t\treturn this.client.execute(querySql.sql, querySql.params, { as: 'object' }).then((\n\t\t\teQuery,\n\t\t) => eQuery.rows as T[]);\n\t}\n\n\toverride async count(sql: SQL): Promise<number> {\n\t\tconst res = await this.execute<{ rows: [{ count: string }] }>(sql);\n\n\t\treturn Number(\n\t\t\tres['rows'][0]['count'],\n\t\t);\n\t}\n\n\toverride transaction<T>(\n\t\ttransaction: (tx: PlanetScaleTransaction<TFullSchema, TSchema>) => Promise<T>,\n\t): Promise<T> {\n\t\treturn this.baseClient.transaction((pstx) => {\n\t\t\tconst session = new PlanetscaleSession(this.baseClient, this.dialect, pstx, this.schema, this.options);\n\t\t\tconst tx = new PlanetScaleTransaction<TFullSchema, TSchema>(\n\t\t\t\tthis.dialect,\n\t\t\t\tsession as MySqlSession<any, any, any, any>,\n\t\t\t\tthis.schema,\n\t\t\t);\n\t\t\treturn transaction(tx);\n\t\t});\n\t}\n}\n\nexport class PlanetScaleTransaction<\n\tTFullSchema extends Record<string, unknown>,\n\tTSchema extends TablesRelationalConfig,\n> extends MySqlTransaction<PlanetscaleQueryResultHKT, PlanetScalePreparedQueryHKT, TFullSchema, TSchema> {\n\tstatic override readonly [entityKind]: string = 'PlanetScaleTransaction';\n\n\tconstructor(\n\t\tdialect: MySqlDialect,\n\t\tsession: MySqlSession,\n\t\tschema: RelationalSchemaConfig<TSchema> | undefined,\n\t\tnestedIndex = 0,\n\t) {\n\t\tsuper(dialect, session, schema, nestedIndex, 'planetscale');\n\t}\n\n\toverride async transaction<T>(\n\t\ttransaction: (tx: PlanetScaleTransaction<TFullSchema, TSchema>) => Promise<T>,\n\t): Promise<T> {\n\t\tconst savepointName = `sp${this.nestedIndex + 1}`;\n\t\tconst tx = new PlanetScaleTransaction<TFullSchema, TSchema>(\n\t\t\tthis.dialect,\n\t\t\tthis.session,\n\t\t\tthis.schema,\n\t\t\tthis.nestedIndex + 1,\n\t\t);\n\t\tawait tx.execute(sql.raw(`savepoint ${savepointName}`));\n\t\ttry {\n\t\t\tconst result = await transaction(tx);\n\t\t\tawait tx.execute(sql.raw(`release savepoint ${savepointName}`));\n\t\t\treturn result;\n\t\t} catch (err) {\n\t\t\tawait tx.execute(sql.raw(`rollback to savepoint ${savepointName}`));\n\t\t\tthrow err;\n\t\t}\n\t}\n}\n\nexport interface PlanetscaleQueryResultHKT extends MySqlQueryResultHKT {\n\ttype: ExecutedQuery;\n}\n\nexport interface PlanetScalePreparedQueryHKT extends MySqlPreparedQueryHKT {\n\ttype: PlanetScalePreparedQuery<Assume<this['config'], MySqlPreparedQueryConfig>>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAAuB;AACvB,oBAA+B;AAE/B,oBAA2B;AAG3B,qBAOO;AAEP,iBAA4D;AAC5D,mBAA0C;AAEnC,MAAM,iCAAqE,kCAAsB;AAAA,EAMvG,YACS,QACA,aACA,QACA,QACA,QACA,oBAEA,cAEA,cACP;AACD,UAAM;AAXE;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AAAA,EAGT;AAAA,EAlBA,QAA0B,wBAAU,IAAY;AAAA,EAExC,WAAW,EAAE,IAAI,SAAS;AAAA,EAC1B,QAAQ,EAAE,IAAI,QAAQ;AAAA,EAiB9B,MAAM,QAAQ,oBAAyD,CAAC,GAA0B;AACjG,UAAM,aAAS,6BAAiB,KAAK,QAAQ,iBAAiB;AAE9D,SAAK,OAAO,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M,KAAK,IAAI;AAAA,QACd,KAAK;AAAA,QACL;AAAA,QACA,KAAK;AAAA,MACN;AACA,aAAO,YAAY,EAAE;AAAA,IACtB,CAAC;AAAA,EACF;AACD;AAEO,MAAM,+BAGH,gCAA+F;AAAA,EACxG,QAA0B,wBAAU,IAAY;AAAA,EAEhD,YACC,SACA,SACA,QACA,cAAc,GACb;AACD,UAAM,SAAS,SAAS,QAAQ,aAAa,aAAa;AAAA,EAC3D;AAAA,EAEA,MAAe,YACd,aACa;AACb,UAAM,gBAAgB,KAAK,KAAK,cAAc,CAAC;AAC/C,UAAM,KAAK,IAAI;AAAA,MACd,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK,cAAc;AAAA,IACpB;AACA,UAAM,GAAG,QAAQ,eAAI,IAAI,aAAa,aAAa,EAAE,CAAC;AACtD,QAAI;AACH,YAAM,SAAS,MAAM,YAAY,EAAE;AACnC,YAAM,GAAG,QAAQ,eAAI,IAAI,qBAAqB,aAAa,EAAE,CAAC;AAC9D,aAAO;AAAA,IACR,SAAS,KAAK;AACb,YAAM,GAAG,QAAQ,eAAI,IAAI,yBAAyB,aAAa,EAAE,CAAC;AAClE,YAAM;AAAA,IACP;AAAA,EACD;AACD;","names":["sql"]}
|
|
1
|
+
{"version":3,"sources":["../../src/planetscale-serverless/session.ts"],"sourcesContent":["import type { Client, Connection, ExecutedQuery, Transaction } from '@planetscale/database';\nimport type * as V1 from '~/_relations.ts';\nimport { Column } from '~/column.ts';\nimport { entityKind, is } from '~/entity.ts';\nimport type { Logger } from '~/logger.ts';\nimport { NoopLogger } from '~/logger.ts';\nimport type { MySqlDialect } from '~/mysql-core/dialect.ts';\nimport type { SelectedFieldsOrdered } from '~/mysql-core/query-builders/select.types.ts';\nimport {\n\tMySqlPreparedQuery,\n\ttype MySqlPreparedQueryConfig,\n\ttype MySqlPreparedQueryHKT,\n\ttype MySqlQueryResultHKT,\n\tMySqlSession,\n\tMySqlTransaction,\n} from '~/mysql-core/session.ts';\nimport type { AnyRelations, TablesRelationalConfig } from '~/relations.ts';\nimport { fillPlaceholders, type Query, type SQL, sql } from '~/sql/sql.ts';\nimport { type Assume, mapResultRow } from '~/utils.ts';\n\nexport class PlanetScalePreparedQuery<T extends MySqlPreparedQueryConfig, TIsRqbV2 extends boolean = false>\n\textends MySqlPreparedQuery<T>\n{\n\tstatic override readonly [entityKind]: string = 'PlanetScalePreparedQuery';\n\n\tprivate rawQuery = { as: 'object' } as const;\n\tprivate query = { as: 'array' } as const;\n\n\tconstructor(\n\t\tprivate client: Client | Transaction | Connection,\n\t\tprivate queryString: string,\n\t\tprivate params: unknown[],\n\t\tprivate logger: Logger,\n\t\tprivate fields: SelectedFieldsOrdered | undefined,\n\t\tprivate customResultMapper?: (\n\t\t\trows: TIsRqbV2 extends true ? Record<string, unknown>[] : unknown[][],\n\t\t) => T['execute'],\n\t\t// Keys that were used in $default and the value that was generated for them\n\t\tprivate generatedIds?: Record<string, unknown>[],\n\t\t// Keys that should be returned, it has the column with all properries + key from object\n\t\tprivate returningIds?: SelectedFieldsOrdered,\n\t\tprivate isRqbV2Query?: TIsRqbV2,\n\t) {\n\t\tsuper();\n\t}\n\n\tasync execute(placeholderValues: Record<string, unknown> | undefined = {}): Promise<T['execute']> {\n\t\tif (this.isRqbV2Query) return this.executeRqbV2(placeholderValues);\n\n\t\tconst params = fillPlaceholders(this.params, placeholderValues);\n\n\t\tthis.logger.logQuery(this.queryString, params);\n\n\t\tconst {\n\t\t\tfields,\n\t\t\tclient,\n\t\t\tqueryString,\n\t\t\trawQuery,\n\t\t\tquery,\n\t\t\tjoinsNotNullableMap,\n\t\t\tcustomResultMapper,\n\t\t\treturningIds,\n\t\t\tgeneratedIds,\n\t\t} = this;\n\t\tif (!fields && !customResultMapper) {\n\t\t\tconst res = await client.execute(queryString, params, rawQuery);\n\n\t\t\tconst insertId = Number.parseFloat(res.insertId);\n\t\t\tconst affectedRows = res.rowsAffected;\n\n\t\t\t// for each row, I need to check keys from\n\t\t\tif (returningIds) {\n\t\t\t\tconst returningResponse = [];\n\t\t\t\tlet j = 0;\n\t\t\t\tfor (let i = insertId; i < insertId + affectedRows; i++) {\n\t\t\t\t\tfor (const column of returningIds) {\n\t\t\t\t\t\tconst key = returningIds[0]!.path[0]!;\n\t\t\t\t\t\tif (is(column.field, Column)) {\n\t\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\t\tif (column.field.primary && column.field.autoIncrement) {\n\t\t\t\t\t\t\t\treturningResponse.push({ [key]: i });\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (column.field.defaultFn && generatedIds) {\n\t\t\t\t\t\t\t\t// generatedIds[rowIdx][key]\n\t\t\t\t\t\t\t\treturningResponse.push({ [key]: generatedIds[j]![key] });\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tj++;\n\t\t\t\t}\n\t\t\t\treturn returningResponse;\n\t\t\t}\n\t\t\treturn res;\n\t\t}\n\t\tconst { rows } = await client.execute(queryString, params, query);\n\n\t\tif (customResultMapper) {\n\t\t\treturn (customResultMapper as (rows: unknown[][]) => T['execute'])(rows as unknown[][]);\n\t\t}\n\n\t\treturn rows.map((row) => mapResultRow<T['execute']>(fields!, row as unknown[], joinsNotNullableMap));\n\t}\n\n\tprivate async executeRqbV2(placeholderValues: Record<string, unknown> | undefined = {}): Promise<T['execute']> {\n\t\tconst params = fillPlaceholders(this.params, placeholderValues);\n\n\t\tthis.logger.logQuery(this.queryString, params);\n\n\t\tconst {\n\t\t\tclient,\n\t\t\tqueryString,\n\t\t\trawQuery,\n\t\t\tcustomResultMapper,\n\t\t} = this;\n\n\t\tconst res = await client.execute(queryString, params, rawQuery);\n\n\t\treturn (customResultMapper as (rows: Record<string, unknown>[]) => T['execute'])(\n\t\t\tres.rows as any as Record<string, unknown>[],\n\t\t);\n\t}\n\n\toverride iterator(_placeholderValues?: Record<string, unknown>): AsyncGenerator<T['iterator']> {\n\t\tthrow new Error('Streaming is not supported by the PlanetScale Serverless driver');\n\t}\n}\n\nexport interface PlanetscaleSessionOptions {\n\tlogger?: Logger;\n}\n\nexport class PlanetscaleSession<\n\tTFullSchema extends Record<string, unknown>,\n\tTRelations extends AnyRelations,\n\tTTablesConfig extends TablesRelationalConfig,\n\tTSchema extends V1.TablesRelationalConfig,\n> extends MySqlSession<\n\tMySqlQueryResultHKT,\n\tPlanetScalePreparedQueryHKT,\n\tTFullSchema,\n\tTRelations,\n\tTTablesConfig,\n\tTSchema\n> {\n\tstatic override readonly [entityKind]: string = 'PlanetscaleSession';\n\n\tprivate logger: Logger;\n\tprivate client: Client | Transaction | Connection;\n\n\tconstructor(\n\t\tprivate baseClient: Client | Connection,\n\t\tdialect: MySqlDialect,\n\t\ttx: Transaction | undefined,\n\t\tprivate relations: AnyRelations | undefined,\n\t\tprivate schema: V1.RelationalSchemaConfig<TSchema> | undefined,\n\t\tprivate options: PlanetscaleSessionOptions = {},\n\t) {\n\t\tsuper(dialect);\n\t\tthis.client = tx ?? baseClient;\n\t\tthis.logger = options.logger ?? new NoopLogger();\n\t}\n\n\tprepareQuery<T extends MySqlPreparedQueryConfig = MySqlPreparedQueryConfig>(\n\t\tquery: Query,\n\t\tfields: SelectedFieldsOrdered | undefined,\n\t\tcustomResultMapper?: (rows: unknown[][]) => T['execute'],\n\t\tgeneratedIds?: Record<string, unknown>[],\n\t\treturningIds?: SelectedFieldsOrdered,\n\t): MySqlPreparedQuery<T> {\n\t\treturn new PlanetScalePreparedQuery(\n\t\t\tthis.client,\n\t\t\tquery.sql,\n\t\t\tquery.params,\n\t\t\tthis.logger,\n\t\t\tfields,\n\t\t\tcustomResultMapper,\n\t\t\tgeneratedIds,\n\t\t\treturningIds,\n\t\t);\n\t}\n\n\tprepareRelationalQuery<T extends MySqlPreparedQueryConfig = MySqlPreparedQueryConfig>(\n\t\tquery: Query,\n\t\tfields: SelectedFieldsOrdered | undefined,\n\t\tcustomResultMapper: (rows: Record<string, unknown>[]) => T['execute'],\n\t\tgeneratedIds?: Record<string, unknown>[],\n\t\treturningIds?: SelectedFieldsOrdered,\n\t): MySqlPreparedQuery<T> {\n\t\treturn new PlanetScalePreparedQuery(\n\t\t\tthis.client,\n\t\t\tquery.sql,\n\t\t\tquery.params,\n\t\t\tthis.logger,\n\t\t\tfields,\n\t\t\tcustomResultMapper,\n\t\t\tgeneratedIds,\n\t\t\treturningIds,\n\t\t\ttrue,\n\t\t);\n\t}\n\n\tasync query(query: string, params: unknown[]): Promise<ExecutedQuery> {\n\t\tthis.logger.logQuery(query, params);\n\n\t\treturn await this.client.execute(query, params, { as: 'array' });\n\t}\n\n\tasync queryObjects(\n\t\tquery: string,\n\t\tparams: unknown[],\n\t): Promise<ExecutedQuery> {\n\t\treturn this.client.execute(query, params, { as: 'object' });\n\t}\n\n\toverride all<T = unknown>(query: SQL): Promise<T[]> {\n\t\tconst querySql = this.dialect.sqlToQuery(query);\n\t\tthis.logger.logQuery(querySql.sql, querySql.params);\n\n\t\treturn this.client.execute(querySql.sql, querySql.params, { as: 'object' }).then((\n\t\t\teQuery,\n\t\t) => eQuery.rows as T[]);\n\t}\n\n\toverride async count(sql: SQL): Promise<number> {\n\t\tconst res = await this.execute<{ rows: [{ count: string }] }>(sql);\n\n\t\treturn Number(\n\t\t\tres['rows'][0]['count'],\n\t\t);\n\t}\n\n\toverride transaction<T>(\n\t\ttransaction: (tx: PlanetScaleTransaction<TFullSchema, TRelations, TTablesConfig, TSchema>) => Promise<T>,\n\t): Promise<T> {\n\t\treturn this.baseClient.transaction((pstx) => {\n\t\t\tconst session = new PlanetscaleSession(\n\t\t\t\tthis.baseClient,\n\t\t\t\tthis.dialect,\n\t\t\t\tpstx,\n\t\t\t\tthis.relations,\n\t\t\t\tthis.schema,\n\t\t\t\tthis.options,\n\t\t\t);\n\t\t\tconst tx = new PlanetScaleTransaction<TFullSchema, TRelations, TTablesConfig, TSchema>(\n\t\t\t\tthis.dialect,\n\t\t\t\tsession as MySqlSession<any, any, any, any, any, any>,\n\t\t\t\tthis.relations,\n\t\t\t\tthis.schema,\n\t\t\t);\n\t\t\treturn transaction(tx);\n\t\t});\n\t}\n}\n\nexport class PlanetScaleTransaction<\n\tTFullSchema extends Record<string, unknown>,\n\tTRelations extends AnyRelations,\n\tTTablesConfig extends TablesRelationalConfig,\n\tTSchema extends V1.TablesRelationalConfig,\n> extends MySqlTransaction<\n\tPlanetscaleQueryResultHKT,\n\tPlanetScalePreparedQueryHKT,\n\tTFullSchema,\n\tTRelations,\n\tTTablesConfig,\n\tTSchema\n> {\n\tstatic override readonly [entityKind]: string = 'PlanetScaleTransaction';\n\n\tconstructor(\n\t\tdialect: MySqlDialect,\n\t\tsession: MySqlSession,\n\t\trelations: AnyRelations | undefined,\n\t\tschema: V1.RelationalSchemaConfig<TSchema> | undefined,\n\t\tnestedIndex = 0,\n\t) {\n\t\tsuper(dialect, session, relations, schema, nestedIndex, 'planetscale');\n\t}\n\n\toverride async transaction<T>(\n\t\ttransaction: (tx: PlanetScaleTransaction<TFullSchema, TRelations, TTablesConfig, TSchema>) => Promise<T>,\n\t): Promise<T> {\n\t\tconst savepointName = `sp${this.nestedIndex + 1}`;\n\t\tconst tx = new PlanetScaleTransaction<TFullSchema, TRelations, TTablesConfig, TSchema>(\n\t\t\tthis.dialect,\n\t\t\tthis.session,\n\t\t\tthis.relations,\n\t\t\tthis.schema,\n\t\t\tthis.nestedIndex + 1,\n\t\t);\n\t\tawait tx.execute(sql.raw(`savepoint ${savepointName}`));\n\t\ttry {\n\t\t\tconst result = await transaction(tx);\n\t\t\tawait tx.execute(sql.raw(`release savepoint ${savepointName}`));\n\t\t\treturn result;\n\t\t} catch (err) {\n\t\t\tawait tx.execute(sql.raw(`rollback to savepoint ${savepointName}`));\n\t\t\tthrow err;\n\t\t}\n\t}\n}\n\nexport interface PlanetscaleQueryResultHKT extends MySqlQueryResultHKT {\n\ttype: ExecutedQuery;\n}\n\nexport interface PlanetScalePreparedQueryHKT extends MySqlPrepar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AAAA,MACN;AACA,YAAM,KAAK,IAAI;AAAA,QACd,KAAK;AAAA,QACL;AAAA,QACA,KAAK;AAAA,QACL,KAAK;AAAA,MACN;AACA,aAAO,YAAY,EAAE;AAAA,IACtB,CAAC;AAAA,EACF;AACD;AAEO,MAAM,+BAKH,gCAOR;AAAA,EACD,QAA0B,wBAAU,IAAY;AAAA,EAEhD,YACC,SACA,SACA,WACA,QACA,cAAc,GACb;AACD,UAAM,SAAS,SAAS,WAAW,QAAQ,aAAa,aAAa;AAAA,EACtE;AAAA,EAEA,MAAe,YACd,aACa;AACb,UAAM,gBAAgB,KAAK,KAAK,cAAc,CAAC;AAC/C,UAAM,KAAK,IAAI;AAAA,MACd,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK,cAAc;AAAA,IACpB;AACA,UAAM,GAAG,QAAQ,eAAI,IAAI,aAAa,aAAa,EAAE,CAAC;AACtD,QAAI;AACH,YAAM,SAAS,MAAM,YAAY,EAAE;AACnC,YAAM,GAAG,QAAQ,eAAI,IAAI,qBAAqB,aAAa,EAAE,CAAC;AAC9D,aAAO;AAAA,IACR,SAAS,KAAK;AACb,YAAM,GAAG,QAAQ,eAAI,IAAI,yBAAyB,aAAa,EAAE,CAAC;AAClE,YAAM;AAAA,IACP;AAAA,EACD;AACD;","names":["sql"]}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import type { Client, Connection, ExecutedQuery, Transaction } from '@planetscale/database';
|
|
2
|
+
import type * as V1 from "../_relations.cjs";
|
|
2
3
|
import { entityKind } from "../entity.cjs";
|
|
3
4
|
import type { Logger } from "../logger.cjs";
|
|
4
5
|
import type { MySqlDialect } from "../mysql-core/dialect.cjs";
|
|
5
6
|
import type { SelectedFieldsOrdered } from "../mysql-core/query-builders/select.types.cjs";
|
|
6
7
|
import { MySqlPreparedQuery, type MySqlPreparedQueryConfig, type MySqlPreparedQueryHKT, type MySqlQueryResultHKT, MySqlSession, MySqlTransaction } from "../mysql-core/session.cjs";
|
|
7
|
-
import type {
|
|
8
|
+
import type { AnyRelations, TablesRelationalConfig } from "../relations.cjs";
|
|
8
9
|
import { type Query, type SQL } from "../sql/sql.cjs";
|
|
9
10
|
import { type Assume } from "../utils.cjs";
|
|
10
|
-
export declare class PlanetScalePreparedQuery<T extends MySqlPreparedQueryConfig> extends MySqlPreparedQuery<T> {
|
|
11
|
+
export declare class PlanetScalePreparedQuery<T extends MySqlPreparedQueryConfig, TIsRqbV2 extends boolean = false> extends MySqlPreparedQuery<T> {
|
|
11
12
|
private client;
|
|
12
13
|
private queryString;
|
|
13
14
|
private params;
|
|
@@ -16,35 +17,39 @@ export declare class PlanetScalePreparedQuery<T extends MySqlPreparedQueryConfig
|
|
|
16
17
|
private customResultMapper?;
|
|
17
18
|
private generatedIds?;
|
|
18
19
|
private returningIds?;
|
|
20
|
+
private isRqbV2Query?;
|
|
19
21
|
static readonly [entityKind]: string;
|
|
20
22
|
private rawQuery;
|
|
21
23
|
private query;
|
|
22
|
-
constructor(client: Client | Transaction | Connection, queryString: string, params: unknown[], logger: Logger, fields: SelectedFieldsOrdered | undefined, customResultMapper?: ((rows: unknown[][]) => T["execute"]) | undefined, generatedIds?: Record<string, unknown>[] | undefined, returningIds?: SelectedFieldsOrdered | undefined);
|
|
24
|
+
constructor(client: Client | Transaction | Connection, queryString: string, params: unknown[], logger: Logger, fields: SelectedFieldsOrdered | undefined, customResultMapper?: ((rows: TIsRqbV2 extends true ? Record<string, unknown>[] : unknown[][]) => T["execute"]) | undefined, generatedIds?: Record<string, unknown>[] | undefined, returningIds?: SelectedFieldsOrdered | undefined, isRqbV2Query?: TIsRqbV2 | undefined);
|
|
23
25
|
execute(placeholderValues?: Record<string, unknown> | undefined): Promise<T['execute']>;
|
|
26
|
+
private executeRqbV2;
|
|
24
27
|
iterator(_placeholderValues?: Record<string, unknown>): AsyncGenerator<T['iterator']>;
|
|
25
28
|
}
|
|
26
29
|
export interface PlanetscaleSessionOptions {
|
|
27
30
|
logger?: Logger;
|
|
28
31
|
}
|
|
29
|
-
export declare class PlanetscaleSession<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends MySqlSession<MySqlQueryResultHKT, PlanetScalePreparedQueryHKT, TFullSchema, TSchema> {
|
|
32
|
+
export declare class PlanetscaleSession<TFullSchema extends Record<string, unknown>, TRelations extends AnyRelations, TTablesConfig extends TablesRelationalConfig, TSchema extends V1.TablesRelationalConfig> extends MySqlSession<MySqlQueryResultHKT, PlanetScalePreparedQueryHKT, TFullSchema, TRelations, TTablesConfig, TSchema> {
|
|
30
33
|
private baseClient;
|
|
34
|
+
private relations;
|
|
31
35
|
private schema;
|
|
32
36
|
private options;
|
|
33
37
|
static readonly [entityKind]: string;
|
|
34
38
|
private logger;
|
|
35
39
|
private client;
|
|
36
|
-
constructor(baseClient: Client | Connection, dialect: MySqlDialect, tx: Transaction | undefined, schema: RelationalSchemaConfig<TSchema> | undefined, options?: PlanetscaleSessionOptions);
|
|
40
|
+
constructor(baseClient: Client | Connection, dialect: MySqlDialect, tx: Transaction | undefined, relations: AnyRelations | undefined, schema: V1.RelationalSchemaConfig<TSchema> | undefined, options?: PlanetscaleSessionOptions);
|
|
37
41
|
prepareQuery<T extends MySqlPreparedQueryConfig = MySqlPreparedQueryConfig>(query: Query, fields: SelectedFieldsOrdered | undefined, customResultMapper?: (rows: unknown[][]) => T['execute'], generatedIds?: Record<string, unknown>[], returningIds?: SelectedFieldsOrdered): MySqlPreparedQuery<T>;
|
|
42
|
+
prepareRelationalQuery<T extends MySqlPreparedQueryConfig = MySqlPreparedQueryConfig>(query: Query, fields: SelectedFieldsOrdered | undefined, customResultMapper: (rows: Record<string, unknown>[]) => T['execute'], generatedIds?: Record<string, unknown>[], returningIds?: SelectedFieldsOrdered): MySqlPreparedQuery<T>;
|
|
38
43
|
query(query: string, params: unknown[]): Promise<ExecutedQuery>;
|
|
39
44
|
queryObjects(query: string, params: unknown[]): Promise<ExecutedQuery>;
|
|
40
45
|
all<T = unknown>(query: SQL): Promise<T[]>;
|
|
41
46
|
count(sql: SQL): Promise<number>;
|
|
42
|
-
transaction<T>(transaction: (tx: PlanetScaleTransaction<TFullSchema, TSchema>) => Promise<T>): Promise<T>;
|
|
47
|
+
transaction<T>(transaction: (tx: PlanetScaleTransaction<TFullSchema, TRelations, TTablesConfig, TSchema>) => Promise<T>): Promise<T>;
|
|
43
48
|
}
|
|
44
|
-
export declare class PlanetScaleTransaction<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends MySqlTransaction<PlanetscaleQueryResultHKT, PlanetScalePreparedQueryHKT, TFullSchema, TSchema> {
|
|
49
|
+
export declare class PlanetScaleTransaction<TFullSchema extends Record<string, unknown>, TRelations extends AnyRelations, TTablesConfig extends TablesRelationalConfig, TSchema extends V1.TablesRelationalConfig> extends MySqlTransaction<PlanetscaleQueryResultHKT, PlanetScalePreparedQueryHKT, TFullSchema, TRelations, TTablesConfig, TSchema> {
|
|
45
50
|
static readonly [entityKind]: string;
|
|
46
|
-
constructor(dialect: MySqlDialect, session: MySqlSession, schema: RelationalSchemaConfig<TSchema> | undefined, nestedIndex?: number);
|
|
47
|
-
transaction<T>(transaction: (tx: PlanetScaleTransaction<TFullSchema, TSchema>) => Promise<T>): Promise<T>;
|
|
51
|
+
constructor(dialect: MySqlDialect, session: MySqlSession, relations: AnyRelations | undefined, schema: V1.RelationalSchemaConfig<TSchema> | undefined, nestedIndex?: number);
|
|
52
|
+
transaction<T>(transaction: (tx: PlanetScaleTransaction<TFullSchema, TRelations, TTablesConfig, TSchema>) => Promise<T>): Promise<T>;
|
|
48
53
|
}
|
|
49
54
|
export interface PlanetscaleQueryResultHKT extends MySqlQueryResultHKT {
|
|
50
55
|
type: ExecutedQuery;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import type { Client, Connection, ExecutedQuery, Transaction } from '@planetscale/database';
|
|
2
|
+
import type * as V1 from "../_relations.js";
|
|
2
3
|
import { entityKind } from "../entity.js";
|
|
3
4
|
import type { Logger } from "../logger.js";
|
|
4
5
|
import type { MySqlDialect } from "../mysql-core/dialect.js";
|
|
5
6
|
import type { SelectedFieldsOrdered } from "../mysql-core/query-builders/select.types.js";
|
|
6
7
|
import { MySqlPreparedQuery, type MySqlPreparedQueryConfig, type MySqlPreparedQueryHKT, type MySqlQueryResultHKT, MySqlSession, MySqlTransaction } from "../mysql-core/session.js";
|
|
7
|
-
import type {
|
|
8
|
+
import type { AnyRelations, TablesRelationalConfig } from "../relations.js";
|
|
8
9
|
import { type Query, type SQL } from "../sql/sql.js";
|
|
9
10
|
import { type Assume } from "../utils.js";
|
|
10
|
-
export declare class PlanetScalePreparedQuery<T extends MySqlPreparedQueryConfig> extends MySqlPreparedQuery<T> {
|
|
11
|
+
export declare class PlanetScalePreparedQuery<T extends MySqlPreparedQueryConfig, TIsRqbV2 extends boolean = false> extends MySqlPreparedQuery<T> {
|
|
11
12
|
private client;
|
|
12
13
|
private queryString;
|
|
13
14
|
private params;
|
|
@@ -16,35 +17,39 @@ export declare class PlanetScalePreparedQuery<T extends MySqlPreparedQueryConfig
|
|
|
16
17
|
private customResultMapper?;
|
|
17
18
|
private generatedIds?;
|
|
18
19
|
private returningIds?;
|
|
20
|
+
private isRqbV2Query?;
|
|
19
21
|
static readonly [entityKind]: string;
|
|
20
22
|
private rawQuery;
|
|
21
23
|
private query;
|
|
22
|
-
constructor(client: Client | Transaction | Connection, queryString: string, params: unknown[], logger: Logger, fields: SelectedFieldsOrdered | undefined, customResultMapper?: ((rows: unknown[][]) => T["execute"]) | undefined, generatedIds?: Record<string, unknown>[] | undefined, returningIds?: SelectedFieldsOrdered | undefined);
|
|
24
|
+
constructor(client: Client | Transaction | Connection, queryString: string, params: unknown[], logger: Logger, fields: SelectedFieldsOrdered | undefined, customResultMapper?: ((rows: TIsRqbV2 extends true ? Record<string, unknown>[] : unknown[][]) => T["execute"]) | undefined, generatedIds?: Record<string, unknown>[] | undefined, returningIds?: SelectedFieldsOrdered | undefined, isRqbV2Query?: TIsRqbV2 | undefined);
|
|
23
25
|
execute(placeholderValues?: Record<string, unknown> | undefined): Promise<T['execute']>;
|
|
26
|
+
private executeRqbV2;
|
|
24
27
|
iterator(_placeholderValues?: Record<string, unknown>): AsyncGenerator<T['iterator']>;
|
|
25
28
|
}
|
|
26
29
|
export interface PlanetscaleSessionOptions {
|
|
27
30
|
logger?: Logger;
|
|
28
31
|
}
|
|
29
|
-
export declare class PlanetscaleSession<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends MySqlSession<MySqlQueryResultHKT, PlanetScalePreparedQueryHKT, TFullSchema, TSchema> {
|
|
32
|
+
export declare class PlanetscaleSession<TFullSchema extends Record<string, unknown>, TRelations extends AnyRelations, TTablesConfig extends TablesRelationalConfig, TSchema extends V1.TablesRelationalConfig> extends MySqlSession<MySqlQueryResultHKT, PlanetScalePreparedQueryHKT, TFullSchema, TRelations, TTablesConfig, TSchema> {
|
|
30
33
|
private baseClient;
|
|
34
|
+
private relations;
|
|
31
35
|
private schema;
|
|
32
36
|
private options;
|
|
33
37
|
static readonly [entityKind]: string;
|
|
34
38
|
private logger;
|
|
35
39
|
private client;
|
|
36
|
-
constructor(baseClient: Client | Connection, dialect: MySqlDialect, tx: Transaction | undefined, schema: RelationalSchemaConfig<TSchema> | undefined, options?: PlanetscaleSessionOptions);
|
|
40
|
+
constructor(baseClient: Client | Connection, dialect: MySqlDialect, tx: Transaction | undefined, relations: AnyRelations | undefined, schema: V1.RelationalSchemaConfig<TSchema> | undefined, options?: PlanetscaleSessionOptions);
|
|
37
41
|
prepareQuery<T extends MySqlPreparedQueryConfig = MySqlPreparedQueryConfig>(query: Query, fields: SelectedFieldsOrdered | undefined, customResultMapper?: (rows: unknown[][]) => T['execute'], generatedIds?: Record<string, unknown>[], returningIds?: SelectedFieldsOrdered): MySqlPreparedQuery<T>;
|
|
42
|
+
prepareRelationalQuery<T extends MySqlPreparedQueryConfig = MySqlPreparedQueryConfig>(query: Query, fields: SelectedFieldsOrdered | undefined, customResultMapper: (rows: Record<string, unknown>[]) => T['execute'], generatedIds?: Record<string, unknown>[], returningIds?: SelectedFieldsOrdered): MySqlPreparedQuery<T>;
|
|
38
43
|
query(query: string, params: unknown[]): Promise<ExecutedQuery>;
|
|
39
44
|
queryObjects(query: string, params: unknown[]): Promise<ExecutedQuery>;
|
|
40
45
|
all<T = unknown>(query: SQL): Promise<T[]>;
|
|
41
46
|
count(sql: SQL): Promise<number>;
|
|
42
|
-
transaction<T>(transaction: (tx: PlanetScaleTransaction<TFullSchema, TSchema>) => Promise<T>): Promise<T>;
|
|
47
|
+
transaction<T>(transaction: (tx: PlanetScaleTransaction<TFullSchema, TRelations, TTablesConfig, TSchema>) => Promise<T>): Promise<T>;
|
|
43
48
|
}
|
|
44
|
-
export declare class PlanetScaleTransaction<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends MySqlTransaction<PlanetscaleQueryResultHKT, PlanetScalePreparedQueryHKT, TFullSchema, TSchema> {
|
|
49
|
+
export declare class PlanetScaleTransaction<TFullSchema extends Record<string, unknown>, TRelations extends AnyRelations, TTablesConfig extends TablesRelationalConfig, TSchema extends V1.TablesRelationalConfig> extends MySqlTransaction<PlanetscaleQueryResultHKT, PlanetScalePreparedQueryHKT, TFullSchema, TRelations, TTablesConfig, TSchema> {
|
|
45
50
|
static readonly [entityKind]: string;
|
|
46
|
-
constructor(dialect: MySqlDialect, session: MySqlSession, schema: RelationalSchemaConfig<TSchema> | undefined, nestedIndex?: number);
|
|
47
|
-
transaction<T>(transaction: (tx: PlanetScaleTransaction<TFullSchema, TSchema>) => Promise<T>): Promise<T>;
|
|
51
|
+
constructor(dialect: MySqlDialect, session: MySqlSession, relations: AnyRelations | undefined, schema: V1.RelationalSchemaConfig<TSchema> | undefined, nestedIndex?: number);
|
|
52
|
+
transaction<T>(transaction: (tx: PlanetScaleTransaction<TFullSchema, TRelations, TTablesConfig, TSchema>) => Promise<T>): Promise<T>;
|
|
48
53
|
}
|
|
49
54
|
export interface PlanetscaleQueryResultHKT extends MySqlQueryResultHKT {
|
|
50
55
|
type: ExecutedQuery;
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
import { fillPlaceholders, sql } from "../sql/sql.js";
|
|
10
10
|
import { mapResultRow } from "../utils.js";
|
|
11
11
|
class PlanetScalePreparedQuery extends MySqlPreparedQuery {
|
|
12
|
-
constructor(client, queryString, params, logger, fields, customResultMapper, generatedIds, returningIds) {
|
|
12
|
+
constructor(client, queryString, params, logger, fields, customResultMapper, generatedIds, returningIds, isRqbV2Query) {
|
|
13
13
|
super();
|
|
14
14
|
this.client = client;
|
|
15
15
|
this.queryString = queryString;
|
|
@@ -19,11 +19,14 @@ class PlanetScalePreparedQuery extends MySqlPreparedQuery {
|
|
|
19
19
|
this.customResultMapper = customResultMapper;
|
|
20
20
|
this.generatedIds = generatedIds;
|
|
21
21
|
this.returningIds = returningIds;
|
|
22
|
+
this.isRqbV2Query = isRqbV2Query;
|
|
22
23
|
}
|
|
23
24
|
static [entityKind] = "PlanetScalePreparedQuery";
|
|
24
25
|
rawQuery = { as: "object" };
|
|
25
26
|
query = { as: "array" };
|
|
26
27
|
async execute(placeholderValues = {}) {
|
|
28
|
+
if (this.isRqbV2Query)
|
|
29
|
+
return this.executeRqbV2(placeholderValues);
|
|
27
30
|
const params = fillPlaceholders(this.params, placeholderValues);
|
|
28
31
|
this.logger.logQuery(this.queryString, params);
|
|
29
32
|
const {
|
|
@@ -68,14 +71,29 @@ class PlanetScalePreparedQuery extends MySqlPreparedQuery {
|
|
|
68
71
|
}
|
|
69
72
|
return rows.map((row) => mapResultRow(fields, row, joinsNotNullableMap));
|
|
70
73
|
}
|
|
74
|
+
async executeRqbV2(placeholderValues = {}) {
|
|
75
|
+
const params = fillPlaceholders(this.params, placeholderValues);
|
|
76
|
+
this.logger.logQuery(this.queryString, params);
|
|
77
|
+
const {
|
|
78
|
+
client,
|
|
79
|
+
queryString,
|
|
80
|
+
rawQuery,
|
|
81
|
+
customResultMapper
|
|
82
|
+
} = this;
|
|
83
|
+
const res = await client.execute(queryString, params, rawQuery);
|
|
84
|
+
return customResultMapper(
|
|
85
|
+
res.rows
|
|
86
|
+
);
|
|
87
|
+
}
|
|
71
88
|
iterator(_placeholderValues) {
|
|
72
89
|
throw new Error("Streaming is not supported by the PlanetScale Serverless driver");
|
|
73
90
|
}
|
|
74
91
|
}
|
|
75
92
|
class PlanetscaleSession extends MySqlSession {
|
|
76
|
-
constructor(baseClient, dialect, tx, schema, options = {}) {
|
|
93
|
+
constructor(baseClient, dialect, tx, relations, schema, options = {}) {
|
|
77
94
|
super(dialect);
|
|
78
95
|
this.baseClient = baseClient;
|
|
96
|
+
this.relations = relations;
|
|
79
97
|
this.schema = schema;
|
|
80
98
|
this.options = options;
|
|
81
99
|
this.client = tx ?? baseClient;
|
|
@@ -96,6 +114,19 @@ class PlanetscaleSession extends MySqlSession {
|
|
|
96
114
|
returningIds
|
|
97
115
|
);
|
|
98
116
|
}
|
|
117
|
+
prepareRelationalQuery(query, fields, customResultMapper, generatedIds, returningIds) {
|
|
118
|
+
return new PlanetScalePreparedQuery(
|
|
119
|
+
this.client,
|
|
120
|
+
query.sql,
|
|
121
|
+
query.params,
|
|
122
|
+
this.logger,
|
|
123
|
+
fields,
|
|
124
|
+
customResultMapper,
|
|
125
|
+
generatedIds,
|
|
126
|
+
returningIds,
|
|
127
|
+
true
|
|
128
|
+
);
|
|
129
|
+
}
|
|
99
130
|
async query(query, params) {
|
|
100
131
|
this.logger.logQuery(query, params);
|
|
101
132
|
return await this.client.execute(query, params, { as: "array" });
|
|
@@ -116,10 +147,18 @@ class PlanetscaleSession extends MySqlSession {
|
|
|
116
147
|
}
|
|
117
148
|
transaction(transaction) {
|
|
118
149
|
return this.baseClient.transaction((pstx) => {
|
|
119
|
-
const session = new PlanetscaleSession(
|
|
150
|
+
const session = new PlanetscaleSession(
|
|
151
|
+
this.baseClient,
|
|
152
|
+
this.dialect,
|
|
153
|
+
pstx,
|
|
154
|
+
this.relations,
|
|
155
|
+
this.schema,
|
|
156
|
+
this.options
|
|
157
|
+
);
|
|
120
158
|
const tx = new PlanetScaleTransaction(
|
|
121
159
|
this.dialect,
|
|
122
160
|
session,
|
|
161
|
+
this.relations,
|
|
123
162
|
this.schema
|
|
124
163
|
);
|
|
125
164
|
return transaction(tx);
|
|
@@ -128,14 +167,15 @@ class PlanetscaleSession extends MySqlSession {
|
|
|
128
167
|
}
|
|
129
168
|
class PlanetScaleTransaction extends MySqlTransaction {
|
|
130
169
|
static [entityKind] = "PlanetScaleTransaction";
|
|
131
|
-
constructor(dialect, session, schema, nestedIndex = 0) {
|
|
132
|
-
super(dialect, session, schema, nestedIndex, "planetscale");
|
|
170
|
+
constructor(dialect, session, relations, schema, nestedIndex = 0) {
|
|
171
|
+
super(dialect, session, relations, schema, nestedIndex, "planetscale");
|
|
133
172
|
}
|
|
134
173
|
async transaction(transaction) {
|
|
135
174
|
const savepointName = `sp${this.nestedIndex + 1}`;
|
|
136
175
|
const tx = new PlanetScaleTransaction(
|
|
137
176
|
this.dialect,
|
|
138
177
|
this.session,
|
|
178
|
+
this.relations,
|
|
139
179
|
this.schema,
|
|
140
180
|
this.nestedIndex + 1
|
|
141
181
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/planetscale-serverless/session.ts"],"sourcesContent":["import type { Client, Connection, ExecutedQuery, Transaction } from '@planetscale/database';\nimport { Column } from '~/column.ts';\nimport { entityKind, is } from '~/entity.ts';\nimport type { Logger } from '~/logger.ts';\nimport { NoopLogger } from '~/logger.ts';\nimport type { MySqlDialect } from '~/mysql-core/dialect.ts';\nimport type { SelectedFieldsOrdered } from '~/mysql-core/query-builders/select.types.ts';\nimport {\n\tMySqlPreparedQuery,\n\ttype MySqlPreparedQueryConfig,\n\ttype MySqlPreparedQueryHKT,\n\ttype MySqlQueryResultHKT,\n\tMySqlSession,\n\tMySqlTransaction,\n} from '~/mysql-core/session.ts';\nimport type { RelationalSchemaConfig, TablesRelationalConfig } from '~/relations.ts';\nimport { fillPlaceholders, type Query, type SQL, sql } from '~/sql/sql.ts';\nimport { type Assume, mapResultRow } from '~/utils.ts';\n\nexport class PlanetScalePreparedQuery<T extends MySqlPreparedQueryConfig> extends MySqlPreparedQuery<T> {\n\tstatic override readonly [entityKind]: string = 'PlanetScalePreparedQuery';\n\n\tprivate rawQuery = { as: 'object' } as const;\n\tprivate query = { as: 'array' } as const;\n\n\tconstructor(\n\t\tprivate client: Client | Transaction | Connection,\n\t\tprivate queryString: string,\n\t\tprivate params: unknown[],\n\t\tprivate logger: Logger,\n\t\tprivate fields: SelectedFieldsOrdered | undefined,\n\t\tprivate customResultMapper?: (rows: unknown[][]) => T['execute'],\n\t\t// Keys that were used in $default and the value that was generated for them\n\t\tprivate generatedIds?: Record<string, unknown>[],\n\t\t// Keys that should be returned, it has the column with all properries + key from object\n\t\tprivate returningIds?: SelectedFieldsOrdered,\n\t) {\n\t\tsuper();\n\t}\n\n\tasync execute(placeholderValues: Record<string, unknown> | undefined = {}): Promise<T['execute']> {\n\t\tconst params = fillPlaceholders(this.params, placeholderValues);\n\n\t\tthis.logger.logQuery(this.queryString, params);\n\n\t\tconst {\n\t\t\tfields,\n\t\t\tclient,\n\t\t\tqueryString,\n\t\t\trawQuery,\n\t\t\tquery,\n\t\t\tjoinsNotNullableMap,\n\t\t\tcustomResultMapper,\n\t\t\treturningIds,\n\t\t\tgeneratedIds,\n\t\t} = this;\n\t\tif (!fields && !customResultMapper) {\n\t\t\tconst res = await client.execute(queryString, params, rawQuery);\n\n\t\t\tconst insertId = Number.parseFloat(res.insertId);\n\t\t\tconst affectedRows = res.rowsAffected;\n\n\t\t\t// for each row, I need to check keys from\n\t\t\tif (returningIds) {\n\t\t\t\tconst returningResponse = [];\n\t\t\t\tlet j = 0;\n\t\t\t\tfor (let i = insertId; i < insertId + affectedRows; i++) {\n\t\t\t\t\tfor (const column of returningIds) {\n\t\t\t\t\t\tconst key = returningIds[0]!.path[0]!;\n\t\t\t\t\t\tif (is(column.field, Column)) {\n\t\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\t\tif (column.field.primary && column.field.autoIncrement) {\n\t\t\t\t\t\t\t\treturningResponse.push({ [key]: i });\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (column.field.defaultFn && generatedIds) {\n\t\t\t\t\t\t\t\t// generatedIds[rowIdx][key]\n\t\t\t\t\t\t\t\treturningResponse.push({ [key]: generatedIds[j]![key] });\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tj++;\n\t\t\t\t}\n\t\t\t\treturn returningResponse;\n\t\t\t}\n\t\t\treturn res;\n\t\t}\n\t\tconst { rows } = await client.execute(queryString, params, query);\n\n\t\tif (customResultMapper) {\n\t\t\treturn customResultMapper(rows as unknown[][]);\n\t\t}\n\n\t\treturn rows.map((row) => mapResultRow<T['execute']>(fields!, row as unknown[], joinsNotNullableMap));\n\t}\n\n\toverride iterator(_placeholderValues?: Record<string, unknown>): AsyncGenerator<T['iterator']> {\n\t\tthrow new Error('Streaming is not supported by the PlanetScale Serverless driver');\n\t}\n}\n\nexport interface PlanetscaleSessionOptions {\n\tlogger?: Logger;\n}\n\nexport class PlanetscaleSession<\n\tTFullSchema extends Record<string, unknown>,\n\tTSchema extends TablesRelationalConfig,\n> extends MySqlSession<MySqlQueryResultHKT, PlanetScalePreparedQueryHKT, TFullSchema, TSchema> {\n\tstatic override readonly [entityKind]: string = 'PlanetscaleSession';\n\n\tprivate logger: Logger;\n\tprivate client: Client | Transaction | Connection;\n\n\tconstructor(\n\t\tprivate baseClient: Client | Connection,\n\t\tdialect: MySqlDialect,\n\t\ttx: Transaction | undefined,\n\t\tprivate schema: RelationalSchemaConfig<TSchema> | undefined,\n\t\tprivate options: PlanetscaleSessionOptions = {},\n\t) {\n\t\tsuper(dialect);\n\t\tthis.client = tx ?? baseClient;\n\t\tthis.logger = options.logger ?? new NoopLogger();\n\t}\n\n\tprepareQuery<T extends MySqlPreparedQueryConfig = MySqlPreparedQueryConfig>(\n\t\tquery: Query,\n\t\tfields: SelectedFieldsOrdered | undefined,\n\t\tcustomResultMapper?: (rows: unknown[][]) => T['execute'],\n\t\tgeneratedIds?: Record<string, unknown>[],\n\t\treturningIds?: SelectedFieldsOrdered,\n\t): MySqlPreparedQuery<T> {\n\t\treturn new PlanetScalePreparedQuery(\n\t\t\tthis.client,\n\t\t\tquery.sql,\n\t\t\tquery.params,\n\t\t\tthis.logger,\n\t\t\tfields,\n\t\t\tcustomResultMapper,\n\t\t\tgeneratedIds,\n\t\t\treturningIds,\n\t\t);\n\t}\n\n\tasync query(query: string, params: unknown[]): Promise<ExecutedQuery> {\n\t\tthis.logger.logQuery(query, params);\n\n\t\treturn await this.client.execute(query, params, { as: 'array' });\n\t}\n\n\tasync queryObjects(\n\t\tquery: string,\n\t\tparams: unknown[],\n\t): Promise<ExecutedQuery> {\n\t\treturn this.client.execute(query, params, { as: 'object' });\n\t}\n\n\toverride all<T = unknown>(query: SQL): Promise<T[]> {\n\t\tconst querySql = this.dialect.sqlToQuery(query);\n\t\tthis.logger.logQuery(querySql.sql, querySql.params);\n\n\t\treturn this.client.execute(querySql.sql, querySql.params, { as: 'object' }).then((\n\t\t\teQuery,\n\t\t) => eQuery.rows as T[]);\n\t}\n\n\toverride async count(sql: SQL): Promise<number> {\n\t\tconst res = await this.execute<{ rows: [{ count: string }] }>(sql);\n\n\t\treturn Number(\n\t\t\tres['rows'][0]['count'],\n\t\t);\n\t}\n\n\toverride transaction<T>(\n\t\ttransaction: (tx: PlanetScaleTransaction<TFullSchema, TSchema>) => Promise<T>,\n\t): Promise<T> {\n\t\treturn this.baseClient.transaction((pstx) => {\n\t\t\tconst session = new PlanetscaleSession(this.baseClient, this.dialect, pstx, this.schema, this.options);\n\t\t\tconst tx = new PlanetScaleTransaction<TFullSchema, TSchema>(\n\t\t\t\tthis.dialect,\n\t\t\t\tsession as MySqlSession<any, any, any, any>,\n\t\t\t\tthis.schema,\n\t\t\t);\n\t\t\treturn transaction(tx);\n\t\t});\n\t}\n}\n\nexport class PlanetScaleTransaction<\n\tTFullSchema extends Record<string, unknown>,\n\tTSchema extends TablesRelationalConfig,\n> extends MySqlTransaction<PlanetscaleQueryResultHKT, PlanetScalePreparedQueryHKT, TFullSchema, TSchema> {\n\tstatic override readonly [entityKind]: string = 'PlanetScaleTransaction';\n\n\tconstructor(\n\t\tdialect: MySqlDialect,\n\t\tsession: MySqlSession,\n\t\tschema: RelationalSchemaConfig<TSchema> | undefined,\n\t\tnestedIndex = 0,\n\t) {\n\t\tsuper(dialect, session, schema, nestedIndex, 'planetscale');\n\t}\n\n\toverride async transaction<T>(\n\t\ttransaction: (tx: PlanetScaleTransaction<TFullSchema, TSchema>) => Promise<T>,\n\t): Promise<T> {\n\t\tconst savepointName = `sp${this.nestedIndex + 1}`;\n\t\tconst tx = new PlanetScaleTransaction<TFullSchema, TSchema>(\n\t\t\tthis.dialect,\n\t\t\tthis.session,\n\t\t\tthis.schema,\n\t\t\tthis.nestedIndex + 1,\n\t\t);\n\t\tawait tx.execute(sql.raw(`savepoint ${savepointName}`));\n\t\ttry {\n\t\t\tconst result = await transaction(tx);\n\t\t\tawait tx.execute(sql.raw(`release savepoint ${savepointName}`));\n\t\t\treturn result;\n\t\t} catch (err) {\n\t\t\tawait tx.execute(sql.raw(`rollback to savepoint ${savepointName}`));\n\t\t\tthrow err;\n\t\t}\n\t}\n}\n\nexport interface PlanetscaleQueryResultHKT extends MySqlQueryResultHKT {\n\ttype: ExecutedQuery;\n}\n\nexport interface PlanetScalePreparedQueryHKT extends MySqlPreparedQueryHKT {\n\ttype: PlanetScalePreparedQuery<Assume<this['config'], MySqlPreparedQueryConfig>>;\n}\n"],"mappings":"AACA,SAAS,cAAc;AACvB,SAAS,YAAY,UAAU;AAE/B,SAAS,kBAAkB;AAG3B;AAAA,EACC;AAAA,EAIA;AAAA,EACA;AA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":3,"sources":["../../src/planetscale-serverless/session.ts"],"sourcesContent":["import type { Client, Connection, ExecutedQuery, Transaction } from '@planetscale/database';\nimport type * as V1 from '~/_relations.ts';\nimport { Column } from '~/column.ts';\nimport { entityKind, is } from '~/entity.ts';\nimport type { Logger } from '~/logger.ts';\nimport { NoopLogger } from '~/logger.ts';\nimport type { MySqlDialect } from '~/mysql-core/dialect.ts';\nimport type { SelectedFieldsOrdered } from '~/mysql-core/query-builders/select.types.ts';\nimport {\n\tMySqlPreparedQuery,\n\ttype MySqlPreparedQueryConfig,\n\ttype MySqlPreparedQueryHKT,\n\ttype MySqlQueryResultHKT,\n\tMySqlSession,\n\tMySqlTransaction,\n} from '~/mysql-core/session.ts';\nimport type { AnyRelations, TablesRelationalConfig } from '~/relations.ts';\nimport { fillPlaceholders, type Query, type SQL, sql } from '~/sql/sql.ts';\nimport { type Assume, mapResultRow } from '~/utils.ts';\n\nexport class PlanetScalePreparedQuery<T extends MySqlPreparedQueryConfig, TIsRqbV2 extends boolean = false>\n\textends MySqlPreparedQuery<T>\n{\n\tstatic override readonly [entityKind]: string = 'PlanetScalePreparedQuery';\n\n\tprivate rawQuery = { as: 'object' } as const;\n\tprivate query = { as: 'array' } as const;\n\n\tconstructor(\n\t\tprivate client: Client | Transaction | Connection,\n\t\tprivate queryString: string,\n\t\tprivate params: unknown[],\n\t\tprivate logger: Logger,\n\t\tprivate fields: SelectedFieldsOrdered | undefined,\n\t\tprivate customResultMapper?: (\n\t\t\trows: TIsRqbV2 extends true ? Record<string, unknown>[] : unknown[][],\n\t\t) => T['execute'],\n\t\t// Keys that were used in $default and the value that was generated for them\n\t\tprivate generatedIds?: Record<string, unknown>[],\n\t\t// Keys that should be returned, it has the column with all properries + key from object\n\t\tprivate returningIds?: SelectedFieldsOrdered,\n\t\tprivate isRqbV2Query?: TIsRqbV2,\n\t) {\n\t\tsuper();\n\t}\n\n\tasync execute(placeholderValues: Record<string, unknown> | undefined = {}): Promise<T['execute']> {\n\t\tif (this.isRqbV2Query) return this.executeRqbV2(placeholderValues);\n\n\t\tconst params = fillPlaceholders(this.params, placeholderValues);\n\n\t\tthis.logger.logQuery(this.queryString, params);\n\n\t\tconst {\n\t\t\tfields,\n\t\t\tclient,\n\t\t\tqueryString,\n\t\t\trawQuery,\n\t\t\tquery,\n\t\t\tjoinsNotNullableMap,\n\t\t\tcustomResultMapper,\n\t\t\treturningIds,\n\t\t\tgeneratedIds,\n\t\t} = this;\n\t\tif (!fields && !customResultMapper) {\n\t\t\tconst res = await client.execute(queryString, params, rawQuery);\n\n\t\t\tconst insertId = Number.parseFloat(res.insertId);\n\t\t\tconst affectedRows = res.rowsAffected;\n\n\t\t\t// for each row, I need to check keys from\n\t\t\tif (returningIds) {\n\t\t\t\tconst returningResponse = [];\n\t\t\t\tlet j = 0;\n\t\t\t\tfor (let i = insertId; i < insertId + affectedRows; i++) {\n\t\t\t\t\tfor (const column of returningIds) {\n\t\t\t\t\t\tconst key = returningIds[0]!.path[0]!;\n\t\t\t\t\t\tif (is(column.field, Column)) {\n\t\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\t\tif (column.field.primary && column.field.autoIncrement) {\n\t\t\t\t\t\t\t\treturningResponse.push({ [key]: i });\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (column.field.defaultFn && generatedIds) {\n\t\t\t\t\t\t\t\t// generatedIds[rowIdx][key]\n\t\t\t\t\t\t\t\treturningResponse.push({ [key]: generatedIds[j]![key] });\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tj++;\n\t\t\t\t}\n\t\t\t\treturn returningResponse;\n\t\t\t}\n\t\t\treturn res;\n\t\t}\n\t\tconst { rows } = await client.execute(queryString, params, query);\n\n\t\tif (customResultMapper) {\n\t\t\treturn (customResultMapper as (rows: unknown[][]) => T['execute'])(rows as unknown[][]);\n\t\t}\n\n\t\treturn rows.map((row) => mapResultRow<T['execute']>(fields!, row as unknown[], joinsNotNullableMap));\n\t}\n\n\tprivate async executeRqbV2(placeholderValues: Record<string, unknown> | undefined = {}): Promise<T['execute']> {\n\t\tconst params = fillPlaceholders(this.params, placeholderValues);\n\n\t\tthis.logger.logQuery(this.queryString, params);\n\n\t\tconst {\n\t\t\tclient,\n\t\t\tqueryString,\n\t\t\trawQuery,\n\t\t\tcustomResultMapper,\n\t\t} = this;\n\n\t\tconst res = await client.execute(queryString, params, rawQuery);\n\n\t\treturn (customResultMapper as (rows: Record<string, unknown>[]) => T['execute'])(\n\t\t\tres.rows as any as Record<string, unknown>[],\n\t\t);\n\t}\n\n\toverride iterator(_placeholderValues?: Record<string, unknown>): AsyncGenerator<T['iterator']> {\n\t\tthrow new Error('Streaming is not supported by the PlanetScale Serverless driver');\n\t}\n}\n\nexport interface PlanetscaleSessionOptions {\n\tlogger?: Logger;\n}\n\nexport class PlanetscaleSession<\n\tTFullSchema extends Record<string, unknown>,\n\tTRelations extends AnyRelations,\n\tTTablesConfig extends TablesRelationalConfig,\n\tTSchema extends V1.TablesRelationalConfig,\n> extends MySqlSession<\n\tMySqlQueryResultHKT,\n\tPlanetScalePreparedQueryHKT,\n\tTFullSchema,\n\tTRelations,\n\tTTablesConfig,\n\tTSchema\n> {\n\tstatic override readonly [entityKind]: string = 'PlanetscaleSession';\n\n\tprivate logger: Logger;\n\tprivate client: Client | Transaction | Connection;\n\n\tconstructor(\n\t\tprivate baseClient: Client | Connection,\n\t\tdialect: MySqlDialect,\n\t\ttx: Transaction | undefined,\n\t\tprivate relations: AnyRelations | undefined,\n\t\tprivate schema: V1.RelationalSchemaConfig<TSchema> | undefined,\n\t\tprivate options: PlanetscaleSessionOptions = {},\n\t) {\n\t\tsuper(dialect);\n\t\tthis.client = tx ?? baseClient;\n\t\tthis.logger = options.logger ?? new NoopLogger();\n\t}\n\n\tprepareQuery<T extends MySqlPreparedQueryConfig = MySqlPreparedQueryConfig>(\n\t\tquery: Query,\n\t\tfields: SelectedFieldsOrdered | undefined,\n\t\tcustomResultMapper?: (rows: unknown[][]) => T['execute'],\n\t\tgeneratedIds?: Record<string, unknown>[],\n\t\treturningIds?: SelectedFieldsOrdered,\n\t): MySqlPreparedQuery<T> {\n\t\treturn new PlanetScalePreparedQuery(\n\t\t\tthis.client,\n\t\t\tquery.sql,\n\t\t\tquery.params,\n\t\t\tthis.logger,\n\t\t\tfields,\n\t\t\tcustomResultMapper,\n\t\t\tgeneratedIds,\n\t\t\treturningIds,\n\t\t);\n\t}\n\n\tprepareRelationalQuery<T extends MySqlPreparedQueryConfig = MySqlPreparedQueryConfig>(\n\t\tquery: Query,\n\t\tfields: SelectedFieldsOrdered | undefined,\n\t\tcustomResultMapper: (rows: Record<string, unknown>[]) => T['execute'],\n\t\tgeneratedIds?: Record<string, unknown>[],\n\t\treturningIds?: SelectedFieldsOrdered,\n\t): MySqlPreparedQuery<T> {\n\t\treturn new PlanetScalePreparedQuery(\n\t\t\tthis.client,\n\t\t\tquery.sql,\n\t\t\tquery.params,\n\t\t\tthis.logger,\n\t\t\tfields,\n\t\t\tcustomResultMapper,\n\t\t\tgeneratedIds,\n\t\t\treturningIds,\n\t\t\ttrue,\n\t\t);\n\t}\n\n\tasync query(query: string, params: unknown[]): Promise<ExecutedQuery> {\n\t\tthis.logger.logQuery(query, params);\n\n\t\treturn await this.client.execute(query, params, { as: 'array' });\n\t}\n\n\tasync queryObjects(\n\t\tquery: string,\n\t\tparams: unknown[],\n\t): Promise<ExecutedQuery> {\n\t\treturn this.client.execute(query, params, { as: 'object' });\n\t}\n\n\toverride all<T = unknown>(query: SQL): Promise<T[]> {\n\t\tconst querySql = this.dialect.sqlToQuery(query);\n\t\tthis.logger.logQuery(querySql.sql, querySql.params);\n\n\t\treturn this.client.execute(querySql.sql, querySql.params, { as: 'object' }).then((\n\t\t\teQuery,\n\t\t) => eQuery.rows as T[]);\n\t}\n\n\toverride async count(sql: SQL): Promise<number> {\n\t\tconst res = await this.execute<{ rows: [{ count: string }] }>(sql);\n\n\t\treturn Number(\n\t\t\tres['rows'][0]['count'],\n\t\t);\n\t}\n\n\toverride transaction<T>(\n\t\ttransaction: (tx: PlanetScaleTransaction<TFullSchema, TRelations, TTablesConfig, TSchema>) => Promise<T>,\n\t): Promise<T> {\n\t\treturn this.baseClient.transaction((pstx) => {\n\t\t\tconst session = new PlanetscaleSession(\n\t\t\t\tthis.baseClient,\n\t\t\t\tthis.dialect,\n\t\t\t\tpstx,\n\t\t\t\tthis.relations,\n\t\t\t\tthis.schema,\n\t\t\t\tthis.options,\n\t\t\t);\n\t\t\tconst tx = new PlanetScaleTransaction<TFullSchema, TRelations, TTablesConfig, TSchema>(\n\t\t\t\tthis.dialect,\n\t\t\t\tsession as MySqlSession<any, any, any, any, any, any>,\n\t\t\t\tthis.relations,\n\t\t\t\tthis.schema,\n\t\t\t);\n\t\t\treturn transaction(tx);\n\t\t});\n\t}\n}\n\nexport class PlanetScaleTransaction<\n\tTFullSchema extends Record<string, unknown>,\n\tTRelations extends AnyRelations,\n\tTTablesConfig extends TablesRelationalConfig,\n\tTSchema extends V1.TablesRelationalConfig,\n> extends MySqlTransaction<\n\tPlanetscaleQueryResultHKT,\n\tPlanetScalePreparedQueryHKT,\n\tTFullSchema,\n\tTRelations,\n\tTTablesConfig,\n\tTSchema\n> {\n\tstatic override readonly [entityKind]: string = 'PlanetScaleTransaction';\n\n\tconstructor(\n\t\tdialect: MySqlDialect,\n\t\tsession: MySqlSession,\n\t\trelations: AnyRelations | undefined,\n\t\tschema: V1.RelationalSchemaConfig<TSchema> | undefined,\n\t\tnestedIndex = 0,\n\t) {\n\t\tsuper(dialect, session, relations, schema, nestedIndex, 'planetscale');\n\t}\n\n\toverride async transaction<T>(\n\t\ttransaction: (tx: PlanetScaleTransaction<TFullSchema, TRelations, TTablesConfig, TSchema>) => Promise<T>,\n\t): Promise<T> {\n\t\tconst savepointName = `sp${this.nestedIndex + 1}`;\n\t\tconst tx = new PlanetScaleTransaction<TFullSchema, TRelations, TTablesConfig, TSchema>(\n\t\t\tthis.dialect,\n\t\t\tthis.session,\n\t\t\tthis.relations,\n\t\t\tthis.schema,\n\t\t\tthis.nestedIndex + 1,\n\t\t);\n\t\tawait tx.execute(sql.raw(`savepoint ${savepointName}`));\n\t\ttry {\n\t\t\tconst result = await transaction(tx);\n\t\t\tawait tx.execute(sql.raw(`release savepoint ${savepointName}`));\n\t\t\treturn result;\n\t\t} catch (err) {\n\t\t\tawait tx.execute(sql.raw(`rollback to savepoint ${savepointName}`));\n\t\t\tthrow err;\n\t\t}\n\t}\n}\n\nexport interface PlanetscaleQueryResultHKT extends MySqlQueryResultHKT {\n\ttype: ExecutedQuery;\n}\n\nexport interface PlanetScalePreparedQueryHKT extends MySqlPreparedQueryHKT {\n\ttype: PlanetScalePreparedQuery<Assume<this['config'], MySqlPreparedQueryConfig>>;\n}\n"],"mappings":"AAEA,SAAS,cAAc;AACvB,SAAS,YAAY,UAAU;AAE/B,SAAS,kBAAkB;AAG3B;AAAA,EACC;AAAA,EAIA;AAAA,EACA;AAAA,OACM;AAEP,SAAS,kBAAwC,WAAW;AAC5D,SAAsB,oBAAoB;AAEnC,MAAM,iCACJ,mBACT;AAAA,EAMC,YACS,QACA,aACA,QACA,QACA,QACA,oBAIA,cAEA,cACA,cACP;AACD,UAAM;AAdE;AACA;AACA;AACA;AACA;AACA;AAIA;AAEA;AACA;AAAA,EAGT;AAAA,EArBA,QAA0B,UAAU,IAAY;AAAA,EAExC,WAAW,EAAE,IAAI,SAAS;AAAA,EAC1B,QAAQ,EAAE,IAAI,QAAQ;AAAA,EAoB9B,MAAM,QAAQ,oBAAyD,CAAC,GAA0B;AACjG,QAAI,KAAK;AAAc,aAAO,KAAK,aAAa,iBAAiB;AAEjE,UAAM,SAAS,iBAAiB,KAAK,QAAQ,iBAAiB;AAE9D,SAAK,OAAO,SAAS,KAAK,aAAa,MAAM;AAE7C,UAAM;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,M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