drizzle-orm 0.39.2-c7c31ad → 0.39.2-dc3b366
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-sql/driver.cjs +5 -16
- package/bun-sql/driver.cjs.map +1 -1
- package/bun-sql/driver.d.cts +6 -7
- package/bun-sql/driver.d.ts +6 -7
- package/bun-sql/driver.js +8 -6
- package/bun-sql/driver.js.map +1 -1
- package/bun-sql/migrator.cjs.map +1 -1
- package/bun-sql/migrator.d.cts +1 -2
- package/bun-sql/migrator.d.ts +1 -2
- package/bun-sql/migrator.js.map +1 -1
- package/bun-sql/session.cjs +6 -50
- package/bun-sql/session.cjs.map +1 -1
- package/bun-sql/session.d.cts +9 -14
- package/bun-sql/session.d.ts +9 -14
- package/bun-sql/session.js +6 -50
- package/bun-sql/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 +8 -50
- 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 +8 -50
- 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 -56
- 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 -56
- 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 +6 -30
- 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 +5 -29
- package/mysql-core/db.js.map +1 -1
- package/mysql-core/dialect.cjs +15 -187
- package/mysql-core/dialect.cjs.map +1 -1
- package/mysql-core/dialect.d.cts +13 -36
- package/mysql-core/dialect.d.ts +13 -36
- package/mysql-core/dialect.js +22 -185
- 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 -27
- 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 -27
- 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 -30
- 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 -30
- 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 +3 -51
- package/pg-core/db.cjs +5 -32
- 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 +4 -31
- package/pg-core/db.js.map +1 -1
- package/pg-core/dialect.cjs +488 -162
- package/pg-core/dialect.cjs.map +1 -1
- package/pg-core/dialect.d.cts +8 -27
- package/pg-core/dialect.d.ts +8 -27
- package/pg-core/dialect.js +495 -160
- 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 -45
- 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 -45
- 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 +245 -626
- package/relations.cjs.map +1 -1
- package/relations.d.cts +140 -305
- package/relations.d.ts +140 -305
- package/relations.js +240 -619
- 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 +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/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/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 +0 -21
- 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 +1 -22
- 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 +36 -71
- package/sql-js/session.cjs.map +1 -1
- package/sql-js/session.d.cts +13 -16
- package/sql-js/session.d.ts +13 -16
- package/sql-js/session.js +36 -71
- package/sql-js/session.js.map +1 -1
- package/sqlite-core/db.cjs +12 -39
- package/sqlite-core/db.cjs.map +1 -1
- package/sqlite-core/db.d.cts +8 -16
- package/sqlite-core/db.d.ts +8 -16
- package/sqlite-core/db.js +11 -38
- package/sqlite-core/db.js.map +1 -1
- package/sqlite-core/dialect.cjs +7 -176
- package/sqlite-core/dialect.cjs.map +1 -1
- package/sqlite-core/dialect.d.cts +9 -31
- package/sqlite-core/dialect.d.ts +9 -31
- package/sqlite-core/dialect.js +14 -174
- 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 +35 -56
- package/sqlite-core/query-builders/query.cjs.map +1 -1
- package/sqlite-core/query-builders/query.d.cts +17 -18
- package/sqlite-core/query-builders/query.d.ts +17 -18
- package/sqlite-core/query-builders/query.js +35 -56
- 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 +7 -15
- package/sqlite-core/session.d.ts +7 -15
- package/sqlite-core/session.js +2 -6
- package/sqlite-core/session.js.map +1 -1
- package/sqlite-proxy/driver.cjs +5 -23
- 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 -13
- 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 +6 -50
- 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 +6 -50
- 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 +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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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,29 +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
|
-
} = this;
|
|
104
|
-
const res = await client.execute(queryString, params, rawQuery);
|
|
105
|
-
return customResultMapper(
|
|
106
|
-
res.rows
|
|
107
|
-
);
|
|
108
|
-
}
|
|
109
92
|
iterator(_placeholderValues) {
|
|
110
93
|
throw new Error("Streaming is not supported by the PlanetScale Serverless driver");
|
|
111
94
|
}
|
|
112
95
|
}
|
|
113
96
|
class PlanetscaleSession extends import_session.MySqlSession {
|
|
114
|
-
constructor(baseClient, dialect, tx,
|
|
97
|
+
constructor(baseClient, dialect, tx, schema, options = {}) {
|
|
115
98
|
super(dialect);
|
|
116
99
|
this.baseClient = baseClient;
|
|
117
|
-
this.relations = relations;
|
|
118
100
|
this.schema = schema;
|
|
119
101
|
this.options = options;
|
|
120
102
|
this.client = tx ?? baseClient;
|
|
@@ -135,19 +117,6 @@ class PlanetscaleSession extends import_session.MySqlSession {
|
|
|
135
117
|
returningIds
|
|
136
118
|
);
|
|
137
119
|
}
|
|
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
|
-
}
|
|
151
120
|
async query(query, params) {
|
|
152
121
|
this.logger.logQuery(query, params);
|
|
153
122
|
return await this.client.execute(query, params, { as: "array" });
|
|
@@ -168,18 +137,10 @@ class PlanetscaleSession extends import_session.MySqlSession {
|
|
|
168
137
|
}
|
|
169
138
|
transaction(transaction) {
|
|
170
139
|
return this.baseClient.transaction((pstx) => {
|
|
171
|
-
const session = new PlanetscaleSession(
|
|
172
|
-
this.baseClient,
|
|
173
|
-
this.dialect,
|
|
174
|
-
pstx,
|
|
175
|
-
this.relations,
|
|
176
|
-
this.schema,
|
|
177
|
-
this.options
|
|
178
|
-
);
|
|
140
|
+
const session = new PlanetscaleSession(this.baseClient, this.dialect, pstx, this.schema, this.options);
|
|
179
141
|
const tx = new PlanetScaleTransaction(
|
|
180
142
|
this.dialect,
|
|
181
143
|
session,
|
|
182
|
-
this.relations,
|
|
183
144
|
this.schema
|
|
184
145
|
);
|
|
185
146
|
return transaction(tx);
|
|
@@ -188,15 +149,14 @@ class PlanetscaleSession extends import_session.MySqlSession {
|
|
|
188
149
|
}
|
|
189
150
|
class PlanetScaleTransaction extends import_session.MySqlTransaction {
|
|
190
151
|
static [import_entity.entityKind] = "PlanetScaleTransaction";
|
|
191
|
-
constructor(dialect, session,
|
|
192
|
-
super(dialect, session,
|
|
152
|
+
constructor(dialect, session, schema, nestedIndex = 0) {
|
|
153
|
+
super(dialect, session, schema, nestedIndex, "planetscale");
|
|
193
154
|
}
|
|
194
155
|
async transaction(transaction) {
|
|
195
156
|
const savepointName = `sp${this.nestedIndex + 1}`;
|
|
196
157
|
const tx = new PlanetScaleTransaction(
|
|
197
158
|
this.dialect,
|
|
198
159
|
this.session,
|
|
199
|
-
this.relations,
|
|
200
160
|
this.schema,
|
|
201
161
|
this.nestedIndex + 1
|
|
202
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} = 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":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA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AY,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
|
+
{"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,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OAAO,IAAW;AAAA,EACxB;AAAA,EAEA,MAAe,MAAMA,MAA2B;AAC/C,UAAM,MAAM,MAAM,KAAK,QAAuCA,IAAG;AAEjE,WAAO;AAAA,MACN,IAAI,MAAM,EAAE,CAAC,EAAE,OAAO;AAAA,IACvB;AAAA,EACD;AAAA,EAES,YACR,aACa;AACb,WAAO,KAAK,WAAW,YAAY,CAAC,SAAS;AAC5C,YAAM,UAAU,IAAI,mBAAmB,KAAK,YAAY,KAAK,SAAS,MAAM,KAAK,QAAQ,KAAK,OAAO;AACrG,YAAM,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,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;
|
|
@@ -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) {
|
|
13
13
|
super();
|
|
14
14
|
this.client = client;
|
|
15
15
|
this.queryString = queryString;
|
|
@@ -19,14 +19,11 @@ class PlanetScalePreparedQuery extends MySqlPreparedQuery {
|
|
|
19
19
|
this.customResultMapper = customResultMapper;
|
|
20
20
|
this.generatedIds = generatedIds;
|
|
21
21
|
this.returningIds = returningIds;
|
|
22
|
-
this.isRqbV2Query = isRqbV2Query;
|
|
23
22
|
}
|
|
24
23
|
static [entityKind] = "PlanetScalePreparedQuery";
|
|
25
24
|
rawQuery = { as: "object" };
|
|
26
25
|
query = { as: "array" };
|
|
27
26
|
async execute(placeholderValues = {}) {
|
|
28
|
-
if (this.isRqbV2Query)
|
|
29
|
-
return this.executeRqbV2(placeholderValues);
|
|
30
27
|
const params = fillPlaceholders(this.params, placeholderValues);
|
|
31
28
|
this.logger.logQuery(this.queryString, params);
|
|
32
29
|
const {
|
|
@@ -71,29 +68,14 @@ class PlanetScalePreparedQuery extends MySqlPreparedQuery {
|
|
|
71
68
|
}
|
|
72
69
|
return rows.map((row) => mapResultRow(fields, row, joinsNotNullableMap));
|
|
73
70
|
}
|
|
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
|
-
}
|
|
88
71
|
iterator(_placeholderValues) {
|
|
89
72
|
throw new Error("Streaming is not supported by the PlanetScale Serverless driver");
|
|
90
73
|
}
|
|
91
74
|
}
|
|
92
75
|
class PlanetscaleSession extends MySqlSession {
|
|
93
|
-
constructor(baseClient, dialect, tx,
|
|
76
|
+
constructor(baseClient, dialect, tx, schema, options = {}) {
|
|
94
77
|
super(dialect);
|
|
95
78
|
this.baseClient = baseClient;
|
|
96
|
-
this.relations = relations;
|
|
97
79
|
this.schema = schema;
|
|
98
80
|
this.options = options;
|
|
99
81
|
this.client = tx ?? baseClient;
|
|
@@ -114,19 +96,6 @@ class PlanetscaleSession extends MySqlSession {
|
|
|
114
96
|
returningIds
|
|
115
97
|
);
|
|
116
98
|
}
|
|
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
|
-
}
|
|
130
99
|
async query(query, params) {
|
|
131
100
|
this.logger.logQuery(query, params);
|
|
132
101
|
return await this.client.execute(query, params, { as: "array" });
|
|
@@ -147,18 +116,10 @@ class PlanetscaleSession extends MySqlSession {
|
|
|
147
116
|
}
|
|
148
117
|
transaction(transaction) {
|
|
149
118
|
return this.baseClient.transaction((pstx) => {
|
|
150
|
-
const session = new PlanetscaleSession(
|
|
151
|
-
this.baseClient,
|
|
152
|
-
this.dialect,
|
|
153
|
-
pstx,
|
|
154
|
-
this.relations,
|
|
155
|
-
this.schema,
|
|
156
|
-
this.options
|
|
157
|
-
);
|
|
119
|
+
const session = new PlanetscaleSession(this.baseClient, this.dialect, pstx, this.schema, this.options);
|
|
158
120
|
const tx = new PlanetScaleTransaction(
|
|
159
121
|
this.dialect,
|
|
160
122
|
session,
|
|
161
|
-
this.relations,
|
|
162
123
|
this.schema
|
|
163
124
|
);
|
|
164
125
|
return transaction(tx);
|
|
@@ -167,15 +128,14 @@ class PlanetscaleSession extends MySqlSession {
|
|
|
167
128
|
}
|
|
168
129
|
class PlanetScaleTransaction extends MySqlTransaction {
|
|
169
130
|
static [entityKind] = "PlanetScaleTransaction";
|
|
170
|
-
constructor(dialect, session,
|
|
171
|
-
super(dialect, session,
|
|
131
|
+
constructor(dialect, session, schema, nestedIndex = 0) {
|
|
132
|
+
super(dialect, session, schema, nestedIndex, "planetscale");
|
|
172
133
|
}
|
|
173
134
|
async transaction(transaction) {
|
|
174
135
|
const savepointName = `sp${this.nestedIndex + 1}`;
|
|
175
136
|
const tx = new PlanetScaleTransaction(
|
|
176
137
|
this.dialect,
|
|
177
138
|
this.session,
|
|
178
|
-
this.relations,
|
|
179
139
|
this.schema,
|
|
180
140
|
this.nestedIndex + 1
|
|
181
141
|
);
|