drizzle-orm 0.38.3-e6823b4 → 0.38.4-9927cf1
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/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 +5 -19
- package/aws-data-api/pg/driver.cjs.map +1 -1
- package/aws-data-api/pg/driver.d.cts +8 -9
- package/aws-data-api/pg/driver.d.ts +8 -9
- package/aws-data-api/pg/driver.js +8 -9
- 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 +1 -2
- package/aws-data-api/pg/migrator.d.ts +1 -2
- package/aws-data-api/pg/migrator.js.map +1 -1
- package/aws-data-api/pg/session.cjs +4 -67
- package/aws-data-api/pg/session.cjs.map +1 -1
- package/aws-data-api/pg/session.d.cts +8 -13
- package/aws-data-api/pg/session.d.ts +8 -13
- package/aws-data-api/pg/session.js +4 -67
- package/aws-data-api/pg/session.js.map +1 -1
- package/better-sqlite3/driver.cjs +5 -12
- package/better-sqlite3/driver.cjs.map +1 -1
- package/better-sqlite3/driver.d.cts +6 -7
- package/better-sqlite3/driver.d.ts +6 -7
- package/better-sqlite3/driver.js +8 -12
- package/better-sqlite3/driver.js.map +1 -1
- package/better-sqlite3/migrator.cjs.map +1 -1
- package/better-sqlite3/migrator.d.cts +1 -2
- package/better-sqlite3/migrator.d.ts +1 -2
- package/better-sqlite3/migrator.js.map +1 -1
- package/better-sqlite3/session.cjs +4 -49
- package/better-sqlite3/session.cjs.map +1 -1
- package/better-sqlite3/session.d.cts +8 -14
- package/better-sqlite3/session.d.ts +8 -14
- package/better-sqlite3/session.js +4 -49
- package/better-sqlite3/session.js.map +1 -1
- package/bun-sqlite/driver.cjs +5 -22
- package/bun-sqlite/driver.cjs.map +1 -1
- package/bun-sqlite/driver.d.cts +6 -7
- package/bun-sqlite/driver.d.ts +6 -7
- package/bun-sqlite/driver.js +8 -12
- package/bun-sqlite/driver.js.map +1 -1
- package/bun-sqlite/migrator.cjs.map +1 -1
- package/bun-sqlite/migrator.d.cts +1 -2
- package/bun-sqlite/migrator.d.ts +1 -2
- package/bun-sqlite/migrator.js.map +1 -1
- package/bun-sqlite/session.cjs +4 -49
- package/bun-sqlite/session.cjs.map +1 -1
- package/bun-sqlite/session.d.cts +8 -14
- package/bun-sqlite/session.d.ts +8 -14
- package/bun-sqlite/session.js +4 -49
- package/bun-sqlite/session.js.map +1 -1
- package/d1/driver.cjs +5 -22
- package/d1/driver.cjs.map +1 -1
- package/d1/driver.d.cts +2 -3
- package/d1/driver.d.ts +2 -3
- package/d1/driver.js +8 -12
- package/d1/driver.js.map +1 -1
- package/d1/migrator.cjs.map +1 -1
- package/d1/migrator.d.cts +1 -2
- package/d1/migrator.d.ts +1 -2
- package/d1/migrator.js.map +1 -1
- package/d1/session.cjs +6 -48
- package/d1/session.cjs.map +1 -1
- package/d1/session.d.cts +8 -15
- package/d1/session.d.ts +8 -15
- package/d1/session.js +6 -48
- package/d1/session.js.map +1 -1
- package/durable-sqlite/driver.cjs +5 -16
- package/durable-sqlite/driver.cjs.map +1 -1
- package/durable-sqlite/driver.d.cts +2 -3
- package/durable-sqlite/driver.d.ts +2 -3
- package/durable-sqlite/driver.js +8 -6
- package/durable-sqlite/driver.js.map +1 -1
- package/durable-sqlite/migrator.cjs.map +1 -1
- package/durable-sqlite/migrator.d.cts +1 -2
- package/durable-sqlite/migrator.d.ts +1 -2
- package/durable-sqlite/migrator.js.map +1 -1
- package/durable-sqlite/session.cjs +4 -46
- package/durable-sqlite/session.cjs.map +1 -1
- package/durable-sqlite/session.d.cts +8 -14
- package/durable-sqlite/session.d.ts +8 -14
- package/durable-sqlite/session.js +4 -46
- package/durable-sqlite/session.js.map +1 -1
- package/expo-sqlite/driver.cjs +5 -22
- package/expo-sqlite/driver.cjs.map +1 -1
- package/expo-sqlite/driver.d.cts +2 -3
- package/expo-sqlite/driver.d.ts +2 -3
- package/expo-sqlite/driver.js +8 -12
- package/expo-sqlite/driver.js.map +1 -1
- package/expo-sqlite/migrator.cjs.map +1 -1
- package/expo-sqlite/migrator.d.cts +2 -3
- package/expo-sqlite/migrator.d.ts +2 -3
- package/expo-sqlite/migrator.js.map +1 -1
- package/expo-sqlite/query.cjs +2 -13
- package/expo-sqlite/query.cjs.map +1 -1
- package/expo-sqlite/query.d.cts +1 -2
- package/expo-sqlite/query.d.ts +1 -2
- package/expo-sqlite/query.js +2 -3
- package/expo-sqlite/query.js.map +1 -1
- package/expo-sqlite/session.cjs +4 -47
- package/expo-sqlite/session.cjs.map +1 -1
- package/expo-sqlite/session.d.cts +8 -14
- package/expo-sqlite/session.d.ts +8 -14
- package/expo-sqlite/session.js +4 -47
- package/expo-sqlite/session.js.map +1 -1
- package/libsql/driver-core.cjs +5 -22
- package/libsql/driver-core.cjs.map +1 -1
- package/libsql/driver-core.d.cts +1 -2
- package/libsql/driver-core.d.ts +1 -2
- package/libsql/driver-core.js +8 -12
- package/libsql/driver-core.js.map +1 -1
- package/libsql/driver.cjs.map +1 -1
- package/libsql/driver.d.cts +5 -6
- package/libsql/driver.d.ts +5 -6
- package/libsql/driver.js.map +1 -1
- package/libsql/http/index.cjs.map +1 -1
- package/libsql/http/index.d.cts +5 -6
- package/libsql/http/index.d.ts +5 -6
- package/libsql/http/index.js.map +1 -1
- package/libsql/migrator.cjs.map +1 -1
- package/libsql/migrator.d.cts +1 -2
- package/libsql/migrator.d.ts +1 -2
- package/libsql/migrator.js.map +1 -1
- package/libsql/node/index.cjs.map +1 -1
- package/libsql/node/index.d.cts +5 -6
- package/libsql/node/index.d.ts +5 -6
- package/libsql/node/index.js.map +1 -1
- package/libsql/session.cjs +4 -60
- package/libsql/session.cjs.map +1 -1
- package/libsql/session.d.cts +9 -15
- package/libsql/session.d.ts +9 -15
- package/libsql/session.js +4 -60
- package/libsql/session.js.map +1 -1
- package/libsql/sqlite3/index.cjs.map +1 -1
- package/libsql/sqlite3/index.d.cts +5 -6
- package/libsql/sqlite3/index.d.ts +5 -6
- package/libsql/sqlite3/index.js.map +1 -1
- package/libsql/wasm/index.cjs.map +1 -1
- package/libsql/wasm/index.d.cts +5 -6
- package/libsql/wasm/index.d.ts +5 -6
- package/libsql/wasm/index.js.map +1 -1
- package/libsql/web/index.cjs.map +1 -1
- package/libsql/web/index.d.cts +5 -6
- package/libsql/web/index.d.ts +5 -6
- package/libsql/web/index.js.map +1 -1
- package/libsql/ws/index.cjs.map +1 -1
- package/libsql/ws/index.d.cts +5 -6
- package/libsql/ws/index.d.ts +5 -6
- package/libsql/ws/index.js.map +1 -1
- package/mysql-core/db.cjs +8 -29
- package/mysql-core/db.cjs.map +1 -1
- package/mysql-core/db.d.cts +8 -15
- package/mysql-core/db.d.ts +8 -15
- package/mysql-core/db.js +7 -28
- package/mysql-core/db.js.map +1 -1
- package/mysql-core/dialect.cjs +15 -176
- package/mysql-core/dialect.cjs.map +1 -1
- package/mysql-core/dialect.d.cts +13 -31
- package/mysql-core/dialect.d.ts +13 -31
- package/mysql-core/dialect.js +21 -173
- package/mysql-core/dialect.js.map +1 -1
- 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 +31 -18
- package/mysql-core/query-builders/query.cjs.map +1 -1
- package/mysql-core/query-builders/query.d.cts +10 -8
- package/mysql-core/query-builders/query.d.ts +10 -8
- package/mysql-core/query-builders/query.js +31 -18
- package/mysql-core/query-builders/query.js.map +1 -1
- package/mysql-core/session.cjs +2 -3
- package/mysql-core/session.cjs.map +1 -1
- package/mysql-core/session.d.cts +7 -10
- package/mysql-core/session.d.ts +7 -10
- package/mysql-core/session.js +2 -3
- package/mysql-core/session.js.map +1 -1
- package/mysql-proxy/driver.cjs +5 -22
- package/mysql-proxy/driver.cjs.map +1 -1
- package/mysql-proxy/driver.d.cts +2 -3
- package/mysql-proxy/driver.d.ts +2 -3
- package/mysql-proxy/driver.js +8 -12
- package/mysql-proxy/driver.js.map +1 -1
- package/mysql-proxy/migrator.cjs.map +1 -1
- package/mysql-proxy/migrator.d.cts +1 -2
- package/mysql-proxy/migrator.d.ts +1 -2
- package/mysql-proxy/migrator.js.map +1 -1
- package/mysql-proxy/session.cjs +2 -47
- package/mysql-proxy/session.cjs.map +1 -1
- package/mysql-proxy/session.d.cts +8 -13
- package/mysql-proxy/session.d.ts +8 -13
- package/mysql-proxy/session.js +2 -47
- package/mysql-proxy/session.js.map +1 -1
- package/mysql2/driver.cjs +7 -24
- package/mysql2/driver.cjs.map +1 -1
- package/mysql2/driver.d.cts +9 -10
- package/mysql2/driver.d.ts +9 -10
- package/mysql2/driver.js +10 -14
- package/mysql2/driver.js.map +1 -1
- package/mysql2/migrator.cjs.map +1 -1
- package/mysql2/migrator.d.cts +1 -2
- package/mysql2/migrator.d.ts +1 -2
- package/mysql2/migrator.js.map +1 -1
- package/mysql2/session.cjs +2 -51
- package/mysql2/session.cjs.map +1 -1
- package/mysql2/session.d.cts +8 -13
- package/mysql2/session.d.ts +8 -13
- package/mysql2/session.js +2 -51
- package/mysql2/session.js.map +1 -1
- package/neon-http/driver.cjs +7 -21
- package/neon-http/driver.cjs.map +1 -1
- package/neon-http/driver.d.cts +9 -10
- package/neon-http/driver.d.ts +9 -10
- package/neon-http/driver.js +7 -11
- package/neon-http/driver.js.map +1 -1
- package/neon-http/migrator.cjs.map +1 -1
- package/neon-http/migrator.d.cts +1 -2
- package/neon-http/migrator.d.ts +1 -2
- package/neon-http/migrator.js.map +1 -1
- package/neon-http/session.cjs +2 -32
- package/neon-http/session.cjs.map +1 -1
- package/neon-http/session.d.cts +8 -13
- package/neon-http/session.d.ts +8 -13
- package/neon-http/session.js +2 -32
- package/neon-http/session.js.map +1 -1
- package/neon-serverless/driver.cjs +7 -18
- package/neon-serverless/driver.cjs.map +1 -1
- package/neon-serverless/driver.d.cts +8 -9
- package/neon-serverless/driver.d.ts +8 -9
- package/neon-serverless/driver.js +10 -8
- package/neon-serverless/driver.js.map +1 -1
- package/neon-serverless/migrator.cjs.map +1 -1
- package/neon-serverless/migrator.d.cts +1 -2
- package/neon-serverless/migrator.d.ts +1 -2
- package/neon-serverless/migrator.js.map +1 -1
- package/neon-serverless/session.cjs +5 -40
- package/neon-serverless/session.cjs.map +1 -1
- package/neon-serverless/session.d.cts +8 -13
- package/neon-serverless/session.d.ts +8 -13
- package/neon-serverless/session.js +5 -40
- package/neon-serverless/session.js.map +1 -1
- package/node-postgres/driver.cjs +7 -13
- package/node-postgres/driver.cjs.map +1 -1
- package/node-postgres/driver.d.cts +8 -9
- package/node-postgres/driver.d.ts +8 -9
- package/node-postgres/driver.js +10 -13
- package/node-postgres/driver.js.map +1 -1
- package/node-postgres/migrator.cjs.map +1 -1
- package/node-postgres/migrator.d.cts +1 -2
- package/node-postgres/migrator.d.ts +1 -2
- package/node-postgres/migrator.js.map +1 -1
- package/node-postgres/session.cjs +4 -45
- package/node-postgres/session.cjs.map +1 -1
- package/node-postgres/session.d.cts +8 -13
- package/node-postgres/session.d.ts +8 -13
- package/node-postgres/session.js +4 -45
- package/node-postgres/session.js.map +1 -1
- package/op-sqlite/driver.cjs +5 -22
- package/op-sqlite/driver.cjs.map +1 -1
- package/op-sqlite/driver.d.cts +2 -3
- package/op-sqlite/driver.d.ts +2 -3
- package/op-sqlite/driver.js +8 -12
- package/op-sqlite/driver.js.map +1 -1
- package/op-sqlite/migrator.cjs.map +1 -1
- package/op-sqlite/migrator.d.cts +2 -3
- package/op-sqlite/migrator.d.ts +2 -3
- package/op-sqlite/migrator.js.map +1 -1
- package/op-sqlite/session.cjs +4 -47
- package/op-sqlite/session.cjs.map +1 -1
- package/op-sqlite/session.d.cts +8 -14
- package/op-sqlite/session.d.ts +8 -14
- package/op-sqlite/session.js +4 -47
- package/op-sqlite/session.js.map +1 -1
- package/package.json +15 -51
- package/pg-core/db.cjs +7 -31
- package/pg-core/db.cjs.map +1 -1
- package/pg-core/db.d.cts +9 -16
- package/pg-core/db.d.ts +9 -16
- package/pg-core/db.js +6 -30
- package/pg-core/db.js.map +1 -1
- package/pg-core/dialect.cjs +488 -152
- package/pg-core/dialect.cjs.map +1 -1
- package/pg-core/dialect.d.cts +7 -23
- package/pg-core/dialect.d.ts +7 -23
- package/pg-core/dialect.js +494 -149
- package/pg-core/dialect.js.map +1 -1
- 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 +18 -15
- 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 +18 -15
- package/pg-core/query-builders/query.js.map +1 -1
- package/pg-core/session.cjs +2 -3
- package/pg-core/session.cjs.map +1 -1
- package/pg-core/session.d.cts +6 -9
- package/pg-core/session.d.ts +6 -9
- package/pg-core/session.js +2 -3
- package/pg-core/session.js.map +1 -1
- package/pg-proxy/driver.cjs +5 -21
- package/pg-proxy/driver.cjs.map +1 -1
- package/pg-proxy/driver.d.cts +2 -3
- package/pg-proxy/driver.d.ts +2 -3
- package/pg-proxy/driver.js +8 -11
- package/pg-proxy/driver.js.map +1 -1
- package/pg-proxy/migrator.cjs.map +1 -1
- package/pg-proxy/migrator.d.cts +1 -2
- package/pg-proxy/migrator.d.ts +1 -2
- package/pg-proxy/migrator.js.map +1 -1
- package/pg-proxy/session.cjs +2 -37
- package/pg-proxy/session.cjs.map +1 -1
- package/pg-proxy/session.d.cts +8 -13
- package/pg-proxy/session.d.ts +8 -13
- package/pg-proxy/session.js +2 -37
- package/pg-proxy/session.js.map +1 -1
- package/pglite/driver.cjs +7 -23
- package/pglite/driver.cjs.map +1 -1
- package/pglite/driver.d.cts +8 -9
- package/pglite/driver.d.ts +8 -9
- package/pglite/driver.js +10 -13
- package/pglite/driver.js.map +1 -1
- package/pglite/migrator.cjs.map +1 -1
- package/pglite/migrator.d.cts +1 -2
- package/pglite/migrator.d.ts +1 -2
- package/pglite/migrator.js.map +1 -1
- package/pglite/session.cjs +3 -34
- package/pglite/session.cjs.map +1 -1
- package/pglite/session.d.cts +8 -13
- package/pglite/session.d.ts +8 -13
- package/pglite/session.js +3 -34
- package/pglite/session.js.map +1 -1
- package/planetscale-serverless/driver.cjs +5 -22
- package/planetscale-serverless/driver.cjs.map +1 -1
- package/planetscale-serverless/driver.d.cts +6 -7
- package/planetscale-serverless/driver.d.ts +6 -7
- package/planetscale-serverless/driver.js +8 -12
- package/planetscale-serverless/driver.js.map +1 -1
- package/planetscale-serverless/migrator.cjs.map +1 -1
- package/planetscale-serverless/migrator.d.cts +1 -2
- package/planetscale-serverless/migrator.d.ts +1 -2
- package/planetscale-serverless/migrator.js.map +1 -1
- package/planetscale-serverless/session.cjs +5 -68
- package/planetscale-serverless/session.cjs.map +1 -1
- package/planetscale-serverless/session.d.cts +9 -14
- package/planetscale-serverless/session.d.ts +9 -14
- package/planetscale-serverless/session.js +5 -68
- package/planetscale-serverless/session.js.map +1 -1
- package/postgres-js/driver.cjs +5 -6
- package/postgres-js/driver.cjs.map +1 -1
- package/postgres-js/driver.d.cts +6 -7
- package/postgres-js/driver.d.ts +6 -7
- package/postgres-js/driver.js +8 -6
- package/postgres-js/driver.js.map +1 -1
- package/postgres-js/migrator.cjs.map +1 -1
- package/postgres-js/migrator.d.cts +1 -2
- package/postgres-js/migrator.d.ts +1 -2
- package/postgres-js/migrator.js.map +1 -1
- package/postgres-js/session.cjs +6 -51
- package/postgres-js/session.cjs.map +1 -1
- package/postgres-js/session.d.cts +9 -15
- package/postgres-js/session.d.ts +9 -15
- package/postgres-js/session.js +6 -51
- 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 +0 -3
- package/prisma/mysql/session.cjs.map +1 -1
- package/prisma/mysql/session.d.cts +1 -3
- package/prisma/mysql/session.d.ts +1 -3
- package/prisma/mysql/session.js +0 -3
- 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 +0 -3
- package/prisma/pg/session.cjs.map +1 -1
- package/prisma/pg/session.d.cts +1 -3
- package/prisma/pg/session.d.ts +1 -3
- package/prisma/pg/session.js +0 -3
- 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 +0 -3
- package/prisma/sqlite/session.cjs.map +1 -1
- package/prisma/sqlite/session.d.cts +2 -4
- package/prisma/sqlite/session.d.ts +2 -4
- package/prisma/sqlite/session.js +0 -3
- package/prisma/sqlite/session.js.map +1 -1
- package/relations.cjs +246 -477
- package/relations.cjs.map +1 -1
- package/relations.d.cts +131 -263
- package/relations.d.ts +131 -263
- package/relations.js +241 -466
- 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/columns/all.cjs +2 -0
- package/singlestore-core/columns/all.cjs.map +1 -1
- package/singlestore-core/columns/all.d.cts +2 -0
- package/singlestore-core/columns/all.d.ts +2 -0
- package/singlestore-core/columns/all.js +2 -0
- package/singlestore-core/columns/all.js.map +1 -1
- package/singlestore-core/columns/index.cjs +2 -0
- package/singlestore-core/columns/index.cjs.map +1 -1
- package/singlestore-core/columns/index.d.cts +1 -0
- package/singlestore-core/columns/index.d.ts +1 -0
- package/singlestore-core/columns/index.js +1 -0
- package/singlestore-core/columns/index.js.map +1 -1
- package/singlestore-core/columns/vector.cjs +72 -0
- package/singlestore-core/columns/vector.cjs.map +1 -0
- package/singlestore-core/columns/vector.d.cts +32 -0
- package/singlestore-core/columns/vector.d.ts +32 -0
- package/singlestore-core/columns/vector.js +46 -0
- package/singlestore-core/columns/vector.js.map +1 -0
- 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 +6 -16
- 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 +12 -6
- package/singlestore-core/dialect.js.map +1 -1
- package/singlestore-core/expressions.cjs +10 -0
- package/singlestore-core/expressions.cjs.map +1 -1
- package/singlestore-core/expressions.d.cts +2 -0
- package/singlestore-core/expressions.d.ts +2 -0
- package/singlestore-core/expressions.js +8 -0
- package/singlestore-core/expressions.js.map +1 -1
- package/singlestore-core/query-builders/query.cjs +2 -12
- 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 +4 -2
- 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/sql.cjs.map +1 -1
- package/sql/sql.d.cts +8 -8
- package/sql/sql.d.ts +8 -8
- package/sql/sql.js.map +1 -1
- package/sql-js/driver.cjs +5 -16
- package/sql-js/driver.cjs.map +1 -1
- package/sql-js/driver.d.cts +2 -3
- package/sql-js/driver.d.ts +2 -3
- package/sql-js/driver.js +8 -6
- package/sql-js/driver.js.map +1 -1
- package/sql-js/migrator.cjs.map +1 -1
- package/sql-js/migrator.d.cts +1 -2
- package/sql-js/migrator.d.ts +1 -2
- package/sql-js/migrator.js.map +1 -1
- package/sql-js/session.cjs +4 -58
- package/sql-js/session.cjs.map +1 -1
- package/sql-js/session.d.cts +8 -14
- package/sql-js/session.d.ts +8 -14
- package/sql-js/session.js +4 -58
- package/sql-js/session.js.map +1 -1
- package/sqlite-core/db.cjs +14 -36
- package/sqlite-core/db.cjs.map +1 -1
- package/sqlite-core/db.d.cts +8 -15
- package/sqlite-core/db.d.ts +8 -15
- package/sqlite-core/db.js +13 -35
- package/sqlite-core/db.js.map +1 -1
- package/sqlite-core/dialect.cjs +7 -171
- package/sqlite-core/dialect.cjs.map +1 -1
- package/sqlite-core/dialect.d.cts +9 -27
- package/sqlite-core/dialect.d.ts +9 -27
- package/sqlite-core/dialect.js +13 -168
- package/sqlite-core/dialect.js.map +1 -1
- 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 +29 -32
- package/sqlite-core/query-builders/query.cjs.map +1 -1
- package/sqlite-core/query-builders/query.d.cts +16 -15
- package/sqlite-core/query-builders/query.d.ts +16 -15
- package/sqlite-core/query-builders/query.js +29 -32
- 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 +2 -6
- package/sqlite-core/session.cjs.map +1 -1
- package/sqlite-core/session.d.cts +6 -14
- package/sqlite-core/session.d.ts +6 -14
- package/sqlite-core/session.js +2 -6
- package/sqlite-core/session.js.map +1 -1
- package/sqlite-proxy/driver.cjs +5 -22
- package/sqlite-proxy/driver.cjs.map +1 -1
- package/sqlite-proxy/driver.d.cts +3 -4
- package/sqlite-proxy/driver.d.ts +3 -4
- package/sqlite-proxy/driver.js +5 -12
- package/sqlite-proxy/driver.js.map +1 -1
- package/sqlite-proxy/migrator.cjs.map +1 -1
- package/sqlite-proxy/migrator.d.cts +1 -2
- package/sqlite-proxy/migrator.d.ts +1 -2
- package/sqlite-proxy/migrator.js.map +1 -1
- package/sqlite-proxy/session.cjs +4 -47
- package/sqlite-proxy/session.cjs.map +1 -1
- package/sqlite-proxy/session.d.cts +8 -14
- package/sqlite-proxy/session.d.ts +8 -14
- package/sqlite-proxy/session.js +4 -47
- package/sqlite-proxy/session.js.map +1 -1
- package/table.cjs.map +1 -1
- package/table.d.cts +1 -1
- package/table.d.ts +1 -1
- package/table.js.map +1 -1
- package/tidb-serverless/driver.cjs +5 -22
- package/tidb-serverless/driver.cjs.map +1 -1
- package/tidb-serverless/driver.d.cts +6 -7
- package/tidb-serverless/driver.d.ts +6 -7
- package/tidb-serverless/driver.js +8 -12
- package/tidb-serverless/driver.js.map +1 -1
- package/tidb-serverless/migrator.cjs.map +1 -1
- package/tidb-serverless/migrator.d.cts +1 -2
- package/tidb-serverless/migrator.d.ts +1 -2
- package/tidb-serverless/migrator.js.map +1 -1
- package/tidb-serverless/session.cjs +5 -62
- package/tidb-serverless/session.cjs.map +1 -1
- package/tidb-serverless/session.d.cts +9 -14
- package/tidb-serverless/session.d.ts +9 -14
- package/tidb-serverless/session.js +5 -62
- package/tidb-serverless/session.js.map +1 -1
- package/utils.cjs +2 -2
- package/utils.cjs.map +1 -1
- package/utils.d.cts +1 -3
- package/utils.d.ts +1 -3
- package/utils.js +2 -2
- package/utils.js.map +1 -1
- package/vercel-postgres/driver.cjs +7 -23
- package/vercel-postgres/driver.cjs.map +1 -1
- package/vercel-postgres/driver.d.cts +8 -9
- package/vercel-postgres/driver.d.ts +8 -9
- package/vercel-postgres/driver.js +10 -13
- package/vercel-postgres/driver.js.map +1 -1
- package/vercel-postgres/migrator.cjs.map +1 -1
- package/vercel-postgres/migrator.d.cts +1 -2
- package/vercel-postgres/migrator.d.ts +1 -2
- package/vercel-postgres/migrator.js.map +1 -1
- package/vercel-postgres/session.cjs +4 -34
- package/vercel-postgres/session.cjs.map +1 -1
- package/vercel-postgres/session.d.cts +8 -13
- package/vercel-postgres/session.d.ts +8 -13
- package/vercel-postgres/session.js +4 -34
- 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 +5 -17
- package/xata-http/driver.cjs.map +1 -1
- package/xata-http/driver.d.cts +4 -5
- package/xata-http/driver.d.ts +4 -5
- package/xata-http/driver.js +5 -7
- package/xata-http/driver.js.map +1 -1
- package/xata-http/migrator.cjs.map +1 -1
- package/xata-http/migrator.d.cts +1 -2
- package/xata-http/migrator.d.ts +1 -2
- package/xata-http/migrator.js.map +1 -1
- package/xata-http/session.cjs +2 -30
- package/xata-http/session.cjs.map +1 -1
- package/xata-http/session.d.cts +8 -13
- package/xata-http/session.d.ts +8 -13
- package/xata-http/session.js +2 -30
- package/xata-http/session.js.map +1 -1
- package/_relations.cjs +0 -328
- package/_relations.cjs.map +0 -1
- package/_relations.d.cts +0 -215
- package/_relations.d.ts +0 -215
- package/_relations.js +0 -316
- package/_relations.js.map +0 -1
- package/mysql-core/query-builders/_query.cjs +0 -149
- package/mysql-core/query-builders/_query.cjs.map +0 -1
- package/mysql-core/query-builders/_query.d.cts +0 -44
- package/mysql-core/query-builders/_query.d.ts +0 -44
- package/mysql-core/query-builders/_query.js +0 -114
- package/mysql-core/query-builders/_query.js.map +0 -1
- package/pg-core/query-builders/_query.cjs +0 -155
- package/pg-core/query-builders/_query.cjs.map +0 -1
- package/pg-core/query-builders/_query.d.cts +0 -47
- package/pg-core/query-builders/_query.d.ts +0 -47
- package/pg-core/query-builders/_query.js +0 -120
- package/pg-core/query-builders/_query.js.map +0 -1
- package/sqlite-core/query-builders/_query.cjs +0 -187
- package/sqlite-core/query-builders/_query.cjs.map +0 -1
- package/sqlite-core/query-builders/_query.d.cts +0 -55
- package/sqlite-core/query-builders/_query.d.ts +0 -55
- package/sqlite-core/query-builders/_query.js +0 -151
- package/sqlite-core/query-builders/_query.js.map +0 -1
|
@@ -3,31 +3,30 @@ import { Client } from '@planetscale/database';
|
|
|
3
3
|
import { entityKind } from "../entity.cjs";
|
|
4
4
|
import type { Logger } from "../logger.cjs";
|
|
5
5
|
import { MySqlDatabase } from "../mysql-core/db.cjs";
|
|
6
|
-
import type { AnyRelations, EmptyRelations } from "../relations.cjs";
|
|
7
6
|
import { type DrizzleConfig } from "../utils.cjs";
|
|
8
7
|
import type { PlanetScalePreparedQueryHKT, PlanetscaleQueryResultHKT } from "./session.cjs";
|
|
9
8
|
export interface PlanetscaleSDriverOptions {
|
|
10
9
|
logger?: Logger;
|
|
11
10
|
}
|
|
12
|
-
export declare class PlanetScaleDatabase<TSchema extends Record<string, unknown> = Record<string, never
|
|
11
|
+
export declare class PlanetScaleDatabase<TSchema extends Record<string, unknown> = Record<string, never>> extends MySqlDatabase<PlanetscaleQueryResultHKT, PlanetScalePreparedQueryHKT, TSchema> {
|
|
13
12
|
static readonly [entityKind]: string;
|
|
14
13
|
}
|
|
15
|
-
export declare function drizzle<TSchema extends Record<string, unknown> = Record<string, never>,
|
|
14
|
+
export declare function drizzle<TSchema extends Record<string, unknown> = Record<string, never>, TClient extends Client = Client>(...params: [
|
|
16
15
|
TClient | string
|
|
17
16
|
] | [
|
|
18
17
|
TClient | string,
|
|
19
|
-
DrizzleConfig<TSchema
|
|
18
|
+
DrizzleConfig<TSchema>
|
|
20
19
|
] | [
|
|
21
|
-
(DrizzleConfig<TSchema
|
|
20
|
+
(DrizzleConfig<TSchema> & ({
|
|
22
21
|
connection: string | Config;
|
|
23
22
|
} | {
|
|
24
23
|
client: TClient;
|
|
25
24
|
}))
|
|
26
|
-
]): PlanetScaleDatabase<TSchema
|
|
25
|
+
]): PlanetScaleDatabase<TSchema> & {
|
|
27
26
|
$client: TClient;
|
|
28
27
|
};
|
|
29
28
|
export declare namespace drizzle {
|
|
30
|
-
function mock<TSchema extends Record<string, unknown> = Record<string, never
|
|
29
|
+
function mock<TSchema extends Record<string, unknown> = Record<string, never>>(config?: DrizzleConfig<TSchema>): PlanetScaleDatabase<TSchema> & {
|
|
31
30
|
$client: '$client is not available on drizzle.mock()';
|
|
32
31
|
};
|
|
33
32
|
}
|
|
@@ -3,31 +3,30 @@ import { Client } from '@planetscale/database';
|
|
|
3
3
|
import { entityKind } from "../entity.js";
|
|
4
4
|
import type { Logger } from "../logger.js";
|
|
5
5
|
import { MySqlDatabase } from "../mysql-core/db.js";
|
|
6
|
-
import type { AnyRelations, EmptyRelations } from "../relations.js";
|
|
7
6
|
import { type DrizzleConfig } from "../utils.js";
|
|
8
7
|
import type { PlanetScalePreparedQueryHKT, PlanetscaleQueryResultHKT } from "./session.js";
|
|
9
8
|
export interface PlanetscaleSDriverOptions {
|
|
10
9
|
logger?: Logger;
|
|
11
10
|
}
|
|
12
|
-
export declare class PlanetScaleDatabase<TSchema extends Record<string, unknown> = Record<string, never
|
|
11
|
+
export declare class PlanetScaleDatabase<TSchema extends Record<string, unknown> = Record<string, never>> extends MySqlDatabase<PlanetscaleQueryResultHKT, PlanetScalePreparedQueryHKT, TSchema> {
|
|
13
12
|
static readonly [entityKind]: string;
|
|
14
13
|
}
|
|
15
|
-
export declare function drizzle<TSchema extends Record<string, unknown> = Record<string, never>,
|
|
14
|
+
export declare function drizzle<TSchema extends Record<string, unknown> = Record<string, never>, TClient extends Client = Client>(...params: [
|
|
16
15
|
TClient | string
|
|
17
16
|
] | [
|
|
18
17
|
TClient | string,
|
|
19
|
-
DrizzleConfig<TSchema
|
|
18
|
+
DrizzleConfig<TSchema>
|
|
20
19
|
] | [
|
|
21
|
-
(DrizzleConfig<TSchema
|
|
20
|
+
(DrizzleConfig<TSchema> & ({
|
|
22
21
|
connection: string | Config;
|
|
23
22
|
} | {
|
|
24
23
|
client: TClient;
|
|
25
24
|
}))
|
|
26
|
-
]): PlanetScaleDatabase<TSchema
|
|
25
|
+
]): PlanetScaleDatabase<TSchema> & {
|
|
27
26
|
$client: TClient;
|
|
28
27
|
};
|
|
29
28
|
export declare namespace drizzle {
|
|
30
|
-
function mock<TSchema extends Record<string, unknown> = Record<string, never
|
|
29
|
+
function mock<TSchema extends Record<string, unknown> = Record<string, never>>(config?: DrizzleConfig<TSchema>): PlanetScaleDatabase<TSchema> & {
|
|
31
30
|
$client: '$client is not available on drizzle.mock()';
|
|
32
31
|
};
|
|
33
32
|
}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { Client } from "@planetscale/database";
|
|
2
|
-
import * as V1 from "../_relations.js";
|
|
3
2
|
import { entityKind } from "../entity.js";
|
|
4
3
|
import { DefaultLogger } from "../logger.js";
|
|
5
4
|
import { MySqlDatabase } from "../mysql-core/db.js";
|
|
6
5
|
import { MySqlDialect } from "../mysql-core/dialect.js";
|
|
6
|
+
import {
|
|
7
|
+
createTableRelationsHelpers,
|
|
8
|
+
extractTablesRelationalConfig
|
|
9
|
+
} from "../relations.js";
|
|
7
10
|
import { isConfig } from "../utils.js";
|
|
8
11
|
import { PlanetscaleSession } from "./session.js";
|
|
9
12
|
class PlanetScaleDatabase extends MySqlDatabase {
|
|
@@ -33,9 +36,9 @@ const db = drizzle(client);
|
|
|
33
36
|
}
|
|
34
37
|
let schema;
|
|
35
38
|
if (config.schema) {
|
|
36
|
-
const tablesConfig =
|
|
39
|
+
const tablesConfig = extractTablesRelationalConfig(
|
|
37
40
|
config.schema,
|
|
38
|
-
|
|
41
|
+
createTableRelationsHelpers
|
|
39
42
|
);
|
|
40
43
|
schema = {
|
|
41
44
|
fullSchema: config.schema,
|
|
@@ -43,15 +46,8 @@ const db = drizzle(client);
|
|
|
43
46
|
tableNamesMap: tablesConfig.tableNamesMap
|
|
44
47
|
};
|
|
45
48
|
}
|
|
46
|
-
const
|
|
47
|
-
const
|
|
48
|
-
const db = new PlanetScaleDatabase(
|
|
49
|
-
dialect,
|
|
50
|
-
session,
|
|
51
|
-
relations,
|
|
52
|
-
schema,
|
|
53
|
-
"planetscale"
|
|
54
|
-
);
|
|
49
|
+
const session = new PlanetscaleSession(client, dialect, void 0, schema, { logger });
|
|
50
|
+
const db = new PlanetScaleDatabase(dialect, session, schema, "planetscale");
|
|
55
51
|
db.$client = client;
|
|
56
52
|
return db;
|
|
57
53
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/planetscale-serverless/driver.ts"],"sourcesContent":["import type { Config } from '@planetscale/database';\nimport { Client } from '@planetscale/database';\nimport
|
|
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 {\n\tcreateTableRelationsHelpers,\n\textractTablesRelationalConfig,\n\ttype RelationalSchemaConfig,\n\ttype TablesRelationalConfig,\n} 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> extends MySqlDatabase<PlanetscaleQueryResultHKT, PlanetScalePreparedQueryHKT, TSchema> {\n\tstatic override readonly [entityKind]: string = 'PlanetScaleDatabase';\n}\n\nfunction construct<\n\tTSchema extends Record<string, unknown> = Record<string, never>,\n\tTClient extends Client = Client,\n>(\n\tclient: TClient,\n\tconfig: DrizzleConfig<TSchema> = {},\n): PlanetScaleDatabase<TSchema> & {\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: RelationalSchemaConfig<TablesRelationalConfig> | undefined;\n\tif (config.schema) {\n\t\tconst tablesConfig = extractTablesRelationalConfig(\n\t\t\tconfig.schema,\n\t\t\tcreateTableRelationsHelpers,\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 session = new PlanetscaleSession(client, dialect, undefined, schema, { logger });\n\tconst db = new PlanetScaleDatabase(dialect, session, schema as any, 'planetscale') as PlanetScaleDatabase<TSchema>;\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\tTClient extends Client = Client,\n>(\n\t...params: [\n\t\tTClient | string,\n\t] | [\n\t\tTClient | string,\n\t\tDrizzleConfig<TSchema>,\n\t] | [\n\t\t(\n\t\t\t& DrizzleConfig<TSchema>\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> & {\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> | undefined) as any;\n}\n\nexport namespace drizzle {\n\texport function mock<TSchema extends Record<string, unknown> = Record<string, never>>(\n\t\tconfig?: DrizzleConfig<TSchema>,\n\t): PlanetScaleDatabase<TSchema> & {\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,SAAS,kBAAkB;AAE3B,SAAS,qBAAqB;AAC9B,SAAS,qBAAqB;AAC9B,SAAS,oBAAoB;AAC7B;AAAA,EACC;AAAA,EACA;AAAA,OAGM;AACP,SAA6B,gBAAgB;AAE7C,SAAS,0BAA0B;AAM5B,MAAM,4BAEH,cAA+E;AAAA,EACxF,QAA0B,UAAU,IAAY;AACjD;AAEA,SAAS,UAIR,QACA,SAAiC,CAAC,GAGjC;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,OAAO,WAAW,OAAO;AACnC,aAAS,OAAO;AAAA,EACjB;AAEA,MAAI;AACJ,MAAI,OAAO,QAAQ;AAClB,UAAM,eAAe;AAAA,MACpB,OAAO;AAAA,MACP;AAAA,IACD;AACA,aAAS;AAAA,MACR,YAAY,OAAO;AAAA,MACnB,QAAQ,aAAa;AAAA,MACrB,eAAe,aAAa;AAAA,IAC7B;AAAA,EACD;AAEA,QAAM,UAAU,IAAI,mBAAmB,QAAQ,SAAS,QAAW,QAAQ,EAAE,OAAO,CAAC;AACrF,QAAM,KAAK,IAAI,oBAAoB,SAAS,SAAS,QAAe,aAAa;AACjF,EAAO,GAAI,UAAU;AAErB,SAAO;AACR;AAEO,SAAS,WAIZ,QAiBF;AACD,MAAI,OAAO,OAAO,CAAC,MAAM,UAAU;AAClC,UAAM,WAAW,IAAI,OAAO;AAAA,MAC3B,KAAK,OAAO,CAAC;AAAA,IACd,CAAC;AAED,WAAO,UAAU,UAAU,OAAO,CAAC,CAAC;AAAA,EACrC;AAEA,MAAI,SAAS,OAAO,CAAC,CAAC,GAAG;AACxB,UAAM,EAAE,YAAY,QAAQ,GAAG,cAAc,IAAI,OAAO,CAAC;AAIzD,QAAI;AAAQ,aAAO,UAAU,QAAQ,aAAa;AAElD,UAAM,WAAW,OAAO,eAAe,WACpC,IAAI,OAAO;AAAA,MACZ,KAAK;AAAA,IACN,CAAC,IACC,IAAI;AAAA,MACL;AAAA,IACD;AAED,WAAO,UAAU,UAAU,aAAa;AAAA,EACzC;AAEA,SAAO,UAAU,OAAO,CAAC,GAAc,OAAO,CAAC,CAAuC;AACvF;AAAA,CAEO,CAAUA,aAAV;AACC,WAAS,KACf,QAGC;AACD,WAAO,UAAU,CAAC,GAAU,MAAM;AAAA,EACnC;AANO,EAAAA,SAAS;AAAA,GADA;","names":["drizzle"]}
|
|
@@ -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 {
|
|
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>>(\n\tdb: PlanetScaleDatabase<TSchema>,\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;AAGnC,eAAsB,QACrB,IACA,QACC;AACD,QAAM,iBAAa,oCAAmB,MAAM;AAE5C,QAAM,GAAG,QAAQ,QAAQ,YAAY,GAAG,SAAS,MAAM;AACxD;","names":[]}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import type { MigrationConfig } from "../migrator.cjs";
|
|
2
|
-
import type { AnyRelations } from "../relations.cjs";
|
|
3
2
|
import type { PlanetScaleDatabase } from "./driver.cjs";
|
|
4
|
-
export declare function migrate<TSchema extends Record<string, unknown
|
|
3
|
+
export declare function migrate<TSchema extends Record<string, unknown>>(db: PlanetScaleDatabase<TSchema>, config: MigrationConfig): Promise<void>;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import type { MigrationConfig } from "../migrator.js";
|
|
2
|
-
import type { AnyRelations } from "../relations.js";
|
|
3
2
|
import type { PlanetScaleDatabase } from "./driver.js";
|
|
4
|
-
export declare function migrate<TSchema extends Record<string, unknown
|
|
3
|
+
export declare function migrate<TSchema extends Record<string, unknown>>(db: PlanetScaleDatabase<TSchema>, 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 {
|
|
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>>(\n\tdb: PlanetScaleDatabase<TSchema>,\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;AAGnC,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) {
|
|
34
34
|
super();
|
|
35
35
|
this.client = client;
|
|
36
36
|
this.queryString = queryString;
|
|
@@ -40,14 +40,11 @@ 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;
|
|
44
43
|
}
|
|
45
44
|
static [import_entity.entityKind] = "PlanetScalePreparedQuery";
|
|
46
45
|
rawQuery = { as: "object" };
|
|
47
46
|
query = { as: "array" };
|
|
48
47
|
async execute(placeholderValues = {}) {
|
|
49
|
-
if (this.isRqbV2Query)
|
|
50
|
-
return this.executeRqbV2(placeholderValues);
|
|
51
48
|
const params = (0, import_sql.fillPlaceholders)(this.params, placeholderValues);
|
|
52
49
|
this.logger.logQuery(this.queryString, params);
|
|
53
50
|
const {
|
|
@@ -92,52 +89,14 @@ class PlanetScalePreparedQuery extends import_session.MySqlPreparedQuery {
|
|
|
92
89
|
}
|
|
93
90
|
return rows.map((row) => (0, import_utils.mapResultRow)(fields, row, joinsNotNullableMap));
|
|
94
91
|
}
|
|
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
|
-
returningIds,
|
|
104
|
-
generatedIds
|
|
105
|
-
} = this;
|
|
106
|
-
const res = await client.execute(queryString, params, rawQuery);
|
|
107
|
-
const insertId = Number.parseFloat(res.insertId);
|
|
108
|
-
const affectedRows = res.rowsAffected;
|
|
109
|
-
if (returningIds) {
|
|
110
|
-
const returningResponse = [];
|
|
111
|
-
let j = 0;
|
|
112
|
-
for (let i = insertId; i < insertId + affectedRows; i++) {
|
|
113
|
-
for (const column of returningIds) {
|
|
114
|
-
const key = returningIds[0].path[0];
|
|
115
|
-
if ((0, import_entity.is)(column.field, import_column.Column)) {
|
|
116
|
-
if (column.field.primary && column.field.autoIncrement) {
|
|
117
|
-
returningResponse.push({ [key]: i });
|
|
118
|
-
}
|
|
119
|
-
if (column.field.defaultFn && generatedIds) {
|
|
120
|
-
returningResponse.push({ [key]: generatedIds[j][key] });
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
j++;
|
|
125
|
-
}
|
|
126
|
-
return customResultMapper(returningResponse);
|
|
127
|
-
}
|
|
128
|
-
return customResultMapper(
|
|
129
|
-
res.rows
|
|
130
|
-
);
|
|
131
|
-
}
|
|
132
92
|
iterator(_placeholderValues) {
|
|
133
93
|
throw new Error("Streaming is not supported by the PlanetScale Serverless driver");
|
|
134
94
|
}
|
|
135
95
|
}
|
|
136
96
|
class PlanetscaleSession extends import_session.MySqlSession {
|
|
137
|
-
constructor(baseClient, dialect, tx,
|
|
97
|
+
constructor(baseClient, dialect, tx, schema, options = {}) {
|
|
138
98
|
super(dialect);
|
|
139
99
|
this.baseClient = baseClient;
|
|
140
|
-
this.relations = relations;
|
|
141
100
|
this.schema = schema;
|
|
142
101
|
this.options = options;
|
|
143
102
|
this.client = tx ?? baseClient;
|
|
@@ -158,19 +117,6 @@ class PlanetscaleSession extends import_session.MySqlSession {
|
|
|
158
117
|
returningIds
|
|
159
118
|
);
|
|
160
119
|
}
|
|
161
|
-
prepareRelationalQuery(query, fields, customResultMapper, generatedIds, returningIds) {
|
|
162
|
-
return new PlanetScalePreparedQuery(
|
|
163
|
-
this.client,
|
|
164
|
-
query.sql,
|
|
165
|
-
query.params,
|
|
166
|
-
this.logger,
|
|
167
|
-
fields,
|
|
168
|
-
customResultMapper,
|
|
169
|
-
generatedIds,
|
|
170
|
-
returningIds,
|
|
171
|
-
true
|
|
172
|
-
);
|
|
173
|
-
}
|
|
174
120
|
async query(query, params) {
|
|
175
121
|
this.logger.logQuery(query, params);
|
|
176
122
|
return await this.client.execute(query, params, { as: "array" });
|
|
@@ -191,18 +137,10 @@ class PlanetscaleSession extends import_session.MySqlSession {
|
|
|
191
137
|
}
|
|
192
138
|
transaction(transaction) {
|
|
193
139
|
return this.baseClient.transaction((pstx) => {
|
|
194
|
-
const session = new PlanetscaleSession(
|
|
195
|
-
this.baseClient,
|
|
196
|
-
this.dialect,
|
|
197
|
-
pstx,
|
|
198
|
-
this.relations,
|
|
199
|
-
this.schema,
|
|
200
|
-
this.options
|
|
201
|
-
);
|
|
140
|
+
const session = new PlanetscaleSession(this.baseClient, this.dialect, pstx, this.schema, this.options);
|
|
202
141
|
const tx = new PlanetScaleTransaction(
|
|
203
142
|
this.dialect,
|
|
204
143
|
session,
|
|
205
|
-
this.relations,
|
|
206
144
|
this.schema
|
|
207
145
|
);
|
|
208
146
|
return transaction(tx);
|
|
@@ -211,15 +149,14 @@ class PlanetscaleSession extends import_session.MySqlSession {
|
|
|
211
149
|
}
|
|
212
150
|
class PlanetScaleTransaction extends import_session.MySqlTransaction {
|
|
213
151
|
static [import_entity.entityKind] = "PlanetScaleTransaction";
|
|
214
|
-
constructor(dialect, session,
|
|
215
|
-
super(dialect, session,
|
|
152
|
+
constructor(dialect, session, schema, nestedIndex = 0) {
|
|
153
|
+
super(dialect, session, schema, nestedIndex, "planetscale");
|
|
216
154
|
}
|
|
217
155
|
async transaction(transaction) {
|
|
218
156
|
const savepointName = `sp${this.nestedIndex + 1}`;
|
|
219
157
|
const tx = new PlanetScaleTransaction(
|
|
220
158
|
this.dialect,
|
|
221
159
|
this.session,
|
|
222
|
-
this.relations,
|
|
223
160
|
this.schema,
|
|
224
161
|
this.nestedIndex + 1
|
|
225
162
|
);
|
|
@@ -1 +1 @@
|
|
|
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\treturningIds,\n\t\t\tgeneratedIds,\n\t\t} = this;\n\n\t\tconst res = await client.execute(queryString, params, rawQuery);\n\n\t\tconst insertId = Number.parseFloat(res.insertId);\n\t\tconst affectedRows = res.rowsAffected;\n\n\t\t// for each row, I need to check keys from\n\t\tif (returningIds) {\n\t\t\tconst returningResponse = [];\n\t\t\tlet j = 0;\n\t\t\tfor (let i = insertId; i < insertId + affectedRows; i++) {\n\t\t\t\tfor (const column of returningIds) {\n\t\t\t\t\tconst key = returningIds[0]!.path[0]!;\n\t\t\t\t\tif (is(column.field, Column)) {\n\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\tif (column.field.primary && column.field.autoIncrement) {\n\t\t\t\t\t\t\treturningResponse.push({ [key]: i });\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (column.field.defaultFn && generatedIds) {\n\t\t\t\t\t\t\t// generatedIds[rowIdx][key]\n\t\t\t\t\t\t\treturningResponse.push({ [key]: generatedIds[j]![key] });\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tj++;\n\t\t\t}\n\t\t\treturn (customResultMapper as (rows: Record<string, unknown>[]) => T['execute'])(returningResponse);\n\t\t}\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":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,oBAAuB;AACvB,oBAA+B;AAE/B,oBAA2B;AAG3B,qBAOO;AAEP,iBAA4D;AAC5D,mBAA0C;AAEnC,MAAM,iCACJ,kCACT;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,wBAAU,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,aAAS,6BAAiB,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,MACA;AAAA,MACA;AAAA,IACD,IAAI;AACJ,QAAI,CAAC,UAAU,CAAC,oBAAoB;AACnC,YAAM,MAAM,MAAM,OAAO,QAAQ,aAAa,QAAQ,QAAQ;AAE9D,YAAM,WAAW,OAAO,WAAW,IAAI,QAAQ;AAC/C,YAAM,eAAe,IAAI;AAGzB,UAAI,cAAc;AACjB,cAAM,oBAAoB,CAAC;AAC3B,YAAI,IAAI;AACR,iBAAS,IAAI,UAAU,IAAI,WAAW,cAAc,KAAK;AACxD,qBAAW,UAAU,cAAc;AAClC,kBAAM,MAA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AAA,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 { 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,SAAS,KAAK,aAAa,MAAM;AAE7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K;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,14 +1,13 @@
|
|
|
1
1
|
import type { Client, Connection, ExecutedQuery, Transaction } from '@planetscale/database';
|
|
2
|
-
import type * as V1 from "../_relations.cjs";
|
|
3
2
|
import { entityKind } from "../entity.cjs";
|
|
4
3
|
import type { Logger } from "../logger.cjs";
|
|
5
4
|
import type { MySqlDialect } from "../mysql-core/dialect.cjs";
|
|
6
5
|
import type { SelectedFieldsOrdered } from "../mysql-core/query-builders/select.types.cjs";
|
|
7
6
|
import { MySqlPreparedQuery, type MySqlPreparedQueryConfig, type MySqlPreparedQueryHKT, type MySqlQueryResultHKT, MySqlSession, MySqlTransaction } from "../mysql-core/session.cjs";
|
|
8
|
-
import type {
|
|
7
|
+
import type { RelationalSchemaConfig, TablesRelationalConfig } from "../relations.cjs";
|
|
9
8
|
import { type Query, type SQL } from "../sql/sql.cjs";
|
|
10
9
|
import { type Assume } from "../utils.cjs";
|
|
11
|
-
export declare class PlanetScalePreparedQuery<T extends MySqlPreparedQueryConfig
|
|
10
|
+
export declare class PlanetScalePreparedQuery<T extends MySqlPreparedQueryConfig> extends MySqlPreparedQuery<T> {
|
|
12
11
|
private client;
|
|
13
12
|
private queryString;
|
|
14
13
|
private params;
|
|
@@ -17,39 +16,35 @@ export declare class PlanetScalePreparedQuery<T extends MySqlPreparedQueryConfig
|
|
|
17
16
|
private customResultMapper?;
|
|
18
17
|
private generatedIds?;
|
|
19
18
|
private returningIds?;
|
|
20
|
-
private isRqbV2Query?;
|
|
21
19
|
static readonly [entityKind]: string;
|
|
22
20
|
private rawQuery;
|
|
23
21
|
private query;
|
|
24
|
-
constructor(client: Client | Transaction | Connection, queryString: string, params: unknown[], logger: Logger, fields: SelectedFieldsOrdered | undefined, customResultMapper?: ((rows:
|
|
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);
|
|
25
23
|
execute(placeholderValues?: Record<string, unknown> | undefined): Promise<T['execute']>;
|
|
26
|
-
private executeRqbV2;
|
|
27
24
|
iterator(_placeholderValues?: Record<string, unknown>): AsyncGenerator<T['iterator']>;
|
|
28
25
|
}
|
|
29
26
|
export interface PlanetscaleSessionOptions {
|
|
30
27
|
logger?: Logger;
|
|
31
28
|
}
|
|
32
|
-
export declare class PlanetscaleSession<TFullSchema extends Record<string, unknown>,
|
|
29
|
+
export declare class PlanetscaleSession<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends MySqlSession<MySqlQueryResultHKT, PlanetScalePreparedQueryHKT, TFullSchema, TSchema> {
|
|
33
30
|
private baseClient;
|
|
34
|
-
private relations;
|
|
35
31
|
private schema;
|
|
36
32
|
private options;
|
|
37
33
|
static readonly [entityKind]: string;
|
|
38
34
|
private logger;
|
|
39
35
|
private client;
|
|
40
|
-
constructor(baseClient: Client | Connection, dialect: MySqlDialect, tx: Transaction | undefined,
|
|
36
|
+
constructor(baseClient: Client | Connection, dialect: MySqlDialect, tx: Transaction | undefined, schema: RelationalSchemaConfig<TSchema> | undefined, options?: PlanetscaleSessionOptions);
|
|
41
37
|
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>;
|
|
43
38
|
query(query: string, params: unknown[]): Promise<ExecutedQuery>;
|
|
44
39
|
queryObjects(query: string, params: unknown[]): Promise<ExecutedQuery>;
|
|
45
40
|
all<T = unknown>(query: SQL): Promise<T[]>;
|
|
46
41
|
count(sql: SQL): Promise<number>;
|
|
47
|
-
transaction<T>(transaction: (tx: PlanetScaleTransaction<TFullSchema,
|
|
42
|
+
transaction<T>(transaction: (tx: PlanetScaleTransaction<TFullSchema, TSchema>) => Promise<T>): Promise<T>;
|
|
48
43
|
}
|
|
49
|
-
export declare class PlanetScaleTransaction<TFullSchema extends Record<string, unknown>,
|
|
44
|
+
export declare class PlanetScaleTransaction<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends MySqlTransaction<PlanetscaleQueryResultHKT, PlanetScalePreparedQueryHKT, TFullSchema, TSchema> {
|
|
50
45
|
static readonly [entityKind]: string;
|
|
51
|
-
constructor(dialect: MySqlDialect, session: MySqlSession,
|
|
52
|
-
transaction<T>(transaction: (tx: PlanetScaleTransaction<TFullSchema,
|
|
46
|
+
constructor(dialect: MySqlDialect, session: MySqlSession, schema: RelationalSchemaConfig<TSchema> | undefined, nestedIndex?: number);
|
|
47
|
+
transaction<T>(transaction: (tx: PlanetScaleTransaction<TFullSchema, TSchema>) => Promise<T>): Promise<T>;
|
|
53
48
|
}
|
|
54
49
|
export interface PlanetscaleQueryResultHKT extends MySqlQueryResultHKT {
|
|
55
50
|
type: ExecutedQuery;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import type { Client, Connection, ExecutedQuery, Transaction } from '@planetscale/database';
|
|
2
|
-
import type * as V1 from "../_relations.js";
|
|
3
2
|
import { entityKind } from "../entity.js";
|
|
4
3
|
import type { Logger } from "../logger.js";
|
|
5
4
|
import type { MySqlDialect } from "../mysql-core/dialect.js";
|
|
6
5
|
import type { SelectedFieldsOrdered } from "../mysql-core/query-builders/select.types.js";
|
|
7
6
|
import { MySqlPreparedQuery, type MySqlPreparedQueryConfig, type MySqlPreparedQueryHKT, type MySqlQueryResultHKT, MySqlSession, MySqlTransaction } from "../mysql-core/session.js";
|
|
8
|
-
import type {
|
|
7
|
+
import type { RelationalSchemaConfig, TablesRelationalConfig } from "../relations.js";
|
|
9
8
|
import { type Query, type SQL } from "../sql/sql.js";
|
|
10
9
|
import { type Assume } from "../utils.js";
|
|
11
|
-
export declare class PlanetScalePreparedQuery<T extends MySqlPreparedQueryConfig
|
|
10
|
+
export declare class PlanetScalePreparedQuery<T extends MySqlPreparedQueryConfig> extends MySqlPreparedQuery<T> {
|
|
12
11
|
private client;
|
|
13
12
|
private queryString;
|
|
14
13
|
private params;
|
|
@@ -17,39 +16,35 @@ export declare class PlanetScalePreparedQuery<T extends MySqlPreparedQueryConfig
|
|
|
17
16
|
private customResultMapper?;
|
|
18
17
|
private generatedIds?;
|
|
19
18
|
private returningIds?;
|
|
20
|
-
private isRqbV2Query?;
|
|
21
19
|
static readonly [entityKind]: string;
|
|
22
20
|
private rawQuery;
|
|
23
21
|
private query;
|
|
24
|
-
constructor(client: Client | Transaction | Connection, queryString: string, params: unknown[], logger: Logger, fields: SelectedFieldsOrdered | undefined, customResultMapper?: ((rows:
|
|
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);
|
|
25
23
|
execute(placeholderValues?: Record<string, unknown> | undefined): Promise<T['execute']>;
|
|
26
|
-
private executeRqbV2;
|
|
27
24
|
iterator(_placeholderValues?: Record<string, unknown>): AsyncGenerator<T['iterator']>;
|
|
28
25
|
}
|
|
29
26
|
export interface PlanetscaleSessionOptions {
|
|
30
27
|
logger?: Logger;
|
|
31
28
|
}
|
|
32
|
-
export declare class PlanetscaleSession<TFullSchema extends Record<string, unknown>,
|
|
29
|
+
export declare class PlanetscaleSession<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends MySqlSession<MySqlQueryResultHKT, PlanetScalePreparedQueryHKT, TFullSchema, TSchema> {
|
|
33
30
|
private baseClient;
|
|
34
|
-
private relations;
|
|
35
31
|
private schema;
|
|
36
32
|
private options;
|
|
37
33
|
static readonly [entityKind]: string;
|
|
38
34
|
private logger;
|
|
39
35
|
private client;
|
|
40
|
-
constructor(baseClient: Client | Connection, dialect: MySqlDialect, tx: Transaction | undefined,
|
|
36
|
+
constructor(baseClient: Client | Connection, dialect: MySqlDialect, tx: Transaction | undefined, schema: RelationalSchemaConfig<TSchema> | undefined, options?: PlanetscaleSessionOptions);
|
|
41
37
|
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>;
|
|
43
38
|
query(query: string, params: unknown[]): Promise<ExecutedQuery>;
|
|
44
39
|
queryObjects(query: string, params: unknown[]): Promise<ExecutedQuery>;
|
|
45
40
|
all<T = unknown>(query: SQL): Promise<T[]>;
|
|
46
41
|
count(sql: SQL): Promise<number>;
|
|
47
|
-
transaction<T>(transaction: (tx: PlanetScaleTransaction<TFullSchema,
|
|
42
|
+
transaction<T>(transaction: (tx: PlanetScaleTransaction<TFullSchema, TSchema>) => Promise<T>): Promise<T>;
|
|
48
43
|
}
|
|
49
|
-
export declare class PlanetScaleTransaction<TFullSchema extends Record<string, unknown>,
|
|
44
|
+
export declare class PlanetScaleTransaction<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends MySqlTransaction<PlanetscaleQueryResultHKT, PlanetScalePreparedQueryHKT, TFullSchema, TSchema> {
|
|
50
45
|
static readonly [entityKind]: string;
|
|
51
|
-
constructor(dialect: MySqlDialect, session: MySqlSession,
|
|
52
|
-
transaction<T>(transaction: (tx: PlanetScaleTransaction<TFullSchema,
|
|
46
|
+
constructor(dialect: MySqlDialect, session: MySqlSession, schema: RelationalSchemaConfig<TSchema> | undefined, nestedIndex?: number);
|
|
47
|
+
transaction<T>(transaction: (tx: PlanetScaleTransaction<TFullSchema, TSchema>) => Promise<T>): Promise<T>;
|
|
53
48
|
}
|
|
54
49
|
export interface PlanetscaleQueryResultHKT extends MySqlQueryResultHKT {
|
|
55
50
|
type: ExecutedQuery;
|