drizzle-orm 0.39.0-19ccabb → 0.39.0-2c67783
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 +96 -0
- package/bun-sql/driver.cjs.map +1 -0
- package/bun-sql/driver.d.cts +30 -0
- package/bun-sql/driver.d.ts +30 -0
- package/bun-sql/driver.js +74 -0
- package/bun-sql/driver.js.map +1 -0
- package/bun-sql/index.cjs +25 -0
- package/bun-sql/index.cjs.map +1 -0
- package/bun-sql/index.d.cts +2 -0
- package/bun-sql/index.d.ts +2 -0
- package/bun-sql/index.js +3 -0
- package/bun-sql/index.js.map +1 -0
- package/bun-sql/migrator.cjs +33 -0
- package/bun-sql/migrator.cjs.map +1 -0
- package/bun-sql/migrator.d.cts +3 -0
- package/bun-sql/migrator.d.ts +3 -0
- package/bun-sql/migrator.js +9 -0
- package/bun-sql/migrator.js.map +1 -0
- package/bun-sql/session.cjs +162 -0
- package/bun-sql/session.cjs.map +1 -0
- package/bun-sql/session.d.cts +50 -0
- package/bun-sql/session.d.ts +50 -0
- package/bun-sql/session.js +136 -0
- package/bun-sql/session.js.map +1 -0
- 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 +9 -15
- package/bun-sqlite/session.d.ts +9 -15
- 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 -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 +25 -40
- package/mysql-core/db.cjs.map +1 -1
- package/mysql-core/db.d.cts +12 -22
- package/mysql-core/db.d.ts +12 -22
- package/mysql-core/db.js +24 -39
- package/mysql-core/db.js.map +1 -1
- package/mysql-core/dialect.cjs +15 -194
- package/mysql-core/dialect.cjs.map +1 -1
- package/mysql-core/dialect.d.cts +13 -33
- package/mysql-core/dialect.d.ts +13 -33
- package/mysql-core/dialect.js +21 -191
- 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-builder.cjs +15 -11
- package/mysql-core/query-builders/query-builder.cjs.map +1 -1
- package/mysql-core/query-builders/query-builder.d.cts +2 -6
- package/mysql-core/query-builders/query-builder.d.ts +2 -6
- package/mysql-core/query-builders/query-builder.js +15 -11
- package/mysql-core/query-builders/query-builder.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-core/subquery.cjs.map +1 -1
- package/mysql-core/subquery.d.cts +15 -2
- package/mysql-core/subquery.d.ts +15 -2
- 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/index.cjs +2 -0
- package/neon/index.cjs.map +1 -1
- package/neon/index.d.cts +1 -0
- package/neon/index.d.ts +1 -0
- package/neon/index.js +1 -0
- package/neon/index.js.map +1 -1
- package/neon/neon-identity.cjs +38 -0
- package/neon/neon-identity.cjs.map +1 -0
- package/neon/neon-identity.d.cts +116 -0
- package/neon/neon-identity.d.ts +116 -0
- package/neon/neon-identity.js +14 -0
- package/neon/neon-identity.js.map +1 -0
- 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 +64 -52
- package/pg-core/db.cjs +24 -42
- package/pg-core/db.cjs.map +1 -1
- package/pg-core/db.d.cts +13 -23
- package/pg-core/db.d.ts +13 -23
- package/pg-core/db.js +23 -41
- package/pg-core/db.js.map +1 -1
- package/pg-core/dialect.cjs +488 -161
- package/pg-core/dialect.cjs.map +1 -1
- package/pg-core/dialect.d.cts +7 -24
- package/pg-core/dialect.d.ts +7 -24
- package/pg-core/dialect.js +494 -158
- 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/delete.cjs +13 -0
- package/pg-core/query-builders/delete.cjs.map +1 -1
- package/pg-core/query-builders/delete.d.cts +13 -10
- package/pg-core/query-builders/delete.d.ts +13 -10
- package/pg-core/query-builders/delete.js +14 -1
- package/pg-core/query-builders/delete.js.map +1 -1
- package/pg-core/query-builders/insert.cjs +13 -0
- package/pg-core/query-builders/insert.cjs.map +1 -1
- package/pg-core/query-builders/insert.d.cts +10 -8
- package/pg-core/query-builders/insert.d.ts +10 -8
- package/pg-core/query-builders/insert.js +14 -1
- package/pg-core/query-builders/insert.js.map +1 -1
- package/pg-core/query-builders/query-builder.cjs +15 -11
- package/pg-core/query-builders/query-builder.cjs.map +1 -1
- package/pg-core/query-builders/query-builder.d.cts +3 -6
- package/pg-core/query-builders/query-builder.d.ts +3 -6
- package/pg-core/query-builders/query-builder.js +15 -11
- package/pg-core/query-builders/query-builder.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/query-builders/select.cjs +8 -7
- package/pg-core/query-builders/select.cjs.map +1 -1
- package/pg-core/query-builders/select.d.cts +3 -3
- package/pg-core/query-builders/select.d.ts +3 -3
- package/pg-core/query-builders/select.js +8 -7
- package/pg-core/query-builders/select.js.map +1 -1
- package/pg-core/query-builders/select.types.cjs.map +1 -1
- package/pg-core/query-builders/select.types.d.cts +3 -2
- package/pg-core/query-builders/select.types.d.ts +3 -2
- package/pg-core/query-builders/update.cjs +15 -2
- package/pg-core/query-builders/update.cjs.map +1 -1
- package/pg-core/query-builders/update.d.cts +18 -13
- package/pg-core/query-builders/update.d.ts +18 -13
- package/pg-core/query-builders/update.js +16 -3
- package/pg-core/query-builders/update.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-core/subquery.cjs.map +1 -1
- package/pg-core/subquery.d.cts +15 -2
- package/pg-core/subquery.d.ts +15 -2
- 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/query-builders/select.types.cjs.map +1 -1
- package/query-builders/select.types.d.cts +1 -1
- package/query-builders/select.types.d.ts +1 -1
- package/relations.cjs +245 -595
- package/relations.cjs.map +1 -1
- package/relations.d.cts +131 -276
- package/relations.d.ts +131 -276
- package/relations.js +239 -589
- 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 +17 -11
- package/singlestore-core/db.cjs.map +1 -1
- package/singlestore-core/db.d.cts +7 -10
- package/singlestore-core/db.d.ts +7 -10
- package/singlestore-core/db.js +17 -11
- 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-builder.cjs +15 -11
- package/singlestore-core/query-builders/query-builder.cjs.map +1 -1
- package/singlestore-core/query-builders/query-builder.d.cts +2 -6
- package/singlestore-core/query-builders/query-builder.d.ts +2 -6
- package/singlestore-core/query-builders/query-builder.js +15 -11
- package/singlestore-core/query-builders/query-builder.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-core/subquery.cjs.map +1 -1
- package/singlestore-core/subquery.d.cts +15 -2
- package/singlestore-core/subquery.d.ts +15 -2
- package/singlestore-core/table.cjs.map +1 -1
- package/singlestore-core/table.d.cts +12 -12
- package/singlestore-core/table.d.ts +12 -12
- package/singlestore-core/table.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 +6 -1
- package/sql/sql.cjs.map +1 -1
- package/sql/sql.d.cts +9 -8
- package/sql/sql.d.ts +9 -8
- package/sql/sql.js +5 -1
- 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 +31 -49
- package/sqlite-core/db.cjs.map +1 -1
- package/sqlite-core/db.d.cts +12 -23
- package/sqlite-core/db.d.ts +12 -23
- package/sqlite-core/db.js +30 -48
- package/sqlite-core/db.js.map +1 -1
- package/sqlite-core/dialect.cjs +8 -184
- package/sqlite-core/dialect.cjs.map +1 -1
- package/sqlite-core/dialect.d.cts +9 -28
- package/sqlite-core/dialect.d.ts +9 -28
- package/sqlite-core/dialect.js +14 -181
- 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 +9 -3
- package/sqlite-core/query-builders/insert.cjs.map +1 -1
- package/sqlite-core/query-builders/insert.d.cts +4 -4
- package/sqlite-core/query-builders/insert.d.ts +4 -4
- package/sqlite-core/query-builders/insert.js +9 -3
- package/sqlite-core/query-builders/insert.js.map +1 -1
- package/sqlite-core/query-builders/query-builder.cjs +15 -11
- package/sqlite-core/query-builders/query-builder.cjs.map +1 -1
- package/sqlite-core/query-builders/query-builder.d.cts +2 -6
- package/sqlite-core/query-builders/query-builder.d.ts +2 -6
- package/sqlite-core/query-builders/query-builder.js +15 -11
- package/sqlite-core/query-builders/query-builder.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-core/subquery.cjs.map +1 -1
- package/sqlite-core/subquery.d.cts +15 -2
- package/sqlite-core/subquery.d.ts +15 -2
- 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/subquery.cjs.map +1 -1
- package/subquery.d.cts +1 -0
- package/subquery.d.ts +1 -0
- package/subquery.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 +8 -34
- package/vercel-postgres/session.cjs.map +1 -1
- package/vercel-postgres/session.d.cts +10 -14
- package/vercel-postgres/session.d.ts +10 -14
- package/vercel-postgres/session.js +8 -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
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { sql } from '@vercel/postgres';
|
|
2
|
-
import * as V1 from "../_relations.cjs";
|
|
3
2
|
import { entityKind } from "../entity.cjs";
|
|
4
3
|
import type { Logger } from "../logger.cjs";
|
|
5
4
|
import { PgDatabase } from "../pg-core/db.cjs";
|
|
6
5
|
import { PgDialect } from "../pg-core/index.cjs";
|
|
7
|
-
import
|
|
6
|
+
import { type RelationalSchemaConfig, type TablesRelationalConfig } from "../relations.cjs";
|
|
8
7
|
import { type DrizzleConfig } from "../utils.cjs";
|
|
9
8
|
import { type VercelPgClient, type VercelPgQueryResultHKT, VercelPgSession } from "./session.cjs";
|
|
10
9
|
export interface VercelPgDriverOptions {
|
|
@@ -16,25 +15,25 @@ export declare class VercelPgDriver {
|
|
|
16
15
|
private options;
|
|
17
16
|
static readonly [entityKind]: string;
|
|
18
17
|
constructor(client: VercelPgClient, dialect: PgDialect, options?: VercelPgDriverOptions);
|
|
19
|
-
createSession(
|
|
18
|
+
createSession(schema: RelationalSchemaConfig<TablesRelationalConfig> | undefined): VercelPgSession<Record<string, unknown>, TablesRelationalConfig>;
|
|
20
19
|
}
|
|
21
|
-
export declare class VercelPgDatabase<TSchema extends Record<string, unknown> = Record<string, never
|
|
20
|
+
export declare class VercelPgDatabase<TSchema extends Record<string, unknown> = Record<string, never>> extends PgDatabase<VercelPgQueryResultHKT, TSchema> {
|
|
22
21
|
static readonly [entityKind]: string;
|
|
23
22
|
}
|
|
24
|
-
export declare function drizzle<TSchema extends Record<string, unknown> = Record<string, never>,
|
|
23
|
+
export declare function drizzle<TSchema extends Record<string, unknown> = Record<string, never>, TClient extends VercelPgClient = typeof sql>(...params: [] | [
|
|
25
24
|
TClient
|
|
26
25
|
] | [
|
|
27
26
|
TClient,
|
|
28
|
-
DrizzleConfig<TSchema
|
|
27
|
+
DrizzleConfig<TSchema>
|
|
29
28
|
] | [
|
|
30
|
-
(DrizzleConfig<TSchema
|
|
29
|
+
(DrizzleConfig<TSchema> & ({
|
|
31
30
|
client?: TClient;
|
|
32
31
|
}))
|
|
33
|
-
]): VercelPgDatabase<TSchema
|
|
32
|
+
]): VercelPgDatabase<TSchema> & {
|
|
34
33
|
$client: TClient;
|
|
35
34
|
};
|
|
36
35
|
export declare namespace drizzle {
|
|
37
|
-
function mock<TSchema extends Record<string, unknown> = Record<string, never
|
|
36
|
+
function mock<TSchema extends Record<string, unknown> = Record<string, never>>(config?: DrizzleConfig<TSchema>): VercelPgDatabase<TSchema> & {
|
|
38
37
|
$client: '$client is not available on drizzle.mock()';
|
|
39
38
|
};
|
|
40
39
|
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { sql } from '@vercel/postgres';
|
|
2
|
-
import * as V1 from "../_relations.js";
|
|
3
2
|
import { entityKind } from "../entity.js";
|
|
4
3
|
import type { Logger } from "../logger.js";
|
|
5
4
|
import { PgDatabase } from "../pg-core/db.js";
|
|
6
5
|
import { PgDialect } from "../pg-core/index.js";
|
|
7
|
-
import
|
|
6
|
+
import { type RelationalSchemaConfig, type TablesRelationalConfig } from "../relations.js";
|
|
8
7
|
import { type DrizzleConfig } from "../utils.js";
|
|
9
8
|
import { type VercelPgClient, type VercelPgQueryResultHKT, VercelPgSession } from "./session.js";
|
|
10
9
|
export interface VercelPgDriverOptions {
|
|
@@ -16,25 +15,25 @@ export declare class VercelPgDriver {
|
|
|
16
15
|
private options;
|
|
17
16
|
static readonly [entityKind]: string;
|
|
18
17
|
constructor(client: VercelPgClient, dialect: PgDialect, options?: VercelPgDriverOptions);
|
|
19
|
-
createSession(
|
|
18
|
+
createSession(schema: RelationalSchemaConfig<TablesRelationalConfig> | undefined): VercelPgSession<Record<string, unknown>, TablesRelationalConfig>;
|
|
20
19
|
}
|
|
21
|
-
export declare class VercelPgDatabase<TSchema extends Record<string, unknown> = Record<string, never
|
|
20
|
+
export declare class VercelPgDatabase<TSchema extends Record<string, unknown> = Record<string, never>> extends PgDatabase<VercelPgQueryResultHKT, TSchema> {
|
|
22
21
|
static readonly [entityKind]: string;
|
|
23
22
|
}
|
|
24
|
-
export declare function drizzle<TSchema extends Record<string, unknown> = Record<string, never>,
|
|
23
|
+
export declare function drizzle<TSchema extends Record<string, unknown> = Record<string, never>, TClient extends VercelPgClient = typeof sql>(...params: [] | [
|
|
25
24
|
TClient
|
|
26
25
|
] | [
|
|
27
26
|
TClient,
|
|
28
|
-
DrizzleConfig<TSchema
|
|
27
|
+
DrizzleConfig<TSchema>
|
|
29
28
|
] | [
|
|
30
|
-
(DrizzleConfig<TSchema
|
|
29
|
+
(DrizzleConfig<TSchema> & ({
|
|
31
30
|
client?: TClient;
|
|
32
31
|
}))
|
|
33
|
-
]): VercelPgDatabase<TSchema
|
|
32
|
+
]): VercelPgDatabase<TSchema> & {
|
|
34
33
|
$client: TClient;
|
|
35
34
|
};
|
|
36
35
|
export declare namespace drizzle {
|
|
37
|
-
function mock<TSchema extends Record<string, unknown> = Record<string, never
|
|
36
|
+
function mock<TSchema extends Record<string, unknown> = Record<string, never>>(config?: DrizzleConfig<TSchema>): VercelPgDatabase<TSchema> & {
|
|
38
37
|
$client: '$client is not available on drizzle.mock()';
|
|
39
38
|
};
|
|
40
39
|
}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { sql } from "@vercel/postgres";
|
|
2
|
-
import * as V1 from "../_relations.js";
|
|
3
2
|
import { entityKind } from "../entity.js";
|
|
4
3
|
import { DefaultLogger } from "../logger.js";
|
|
5
4
|
import { PgDatabase } from "../pg-core/db.js";
|
|
6
5
|
import { PgDialect } from "../pg-core/index.js";
|
|
6
|
+
import {
|
|
7
|
+
createTableRelationsHelpers,
|
|
8
|
+
extractTablesRelationalConfig
|
|
9
|
+
} from "../relations.js";
|
|
7
10
|
import { isConfig } from "../utils.js";
|
|
8
11
|
import { VercelPgSession } from "./session.js";
|
|
9
12
|
class VercelPgDriver {
|
|
@@ -13,8 +16,8 @@ class VercelPgDriver {
|
|
|
13
16
|
this.options = options;
|
|
14
17
|
}
|
|
15
18
|
static [entityKind] = "VercelPgDriver";
|
|
16
|
-
createSession(
|
|
17
|
-
return new VercelPgSession(this.client, this.dialect,
|
|
19
|
+
createSession(schema) {
|
|
20
|
+
return new VercelPgSession(this.client, this.dialect, schema, { logger: this.options.logger });
|
|
18
21
|
}
|
|
19
22
|
}
|
|
20
23
|
class VercelPgDatabase extends PgDatabase {
|
|
@@ -30,9 +33,9 @@ function construct(client, config = {}) {
|
|
|
30
33
|
}
|
|
31
34
|
let schema;
|
|
32
35
|
if (config.schema) {
|
|
33
|
-
const tablesConfig =
|
|
36
|
+
const tablesConfig = extractTablesRelationalConfig(
|
|
34
37
|
config.schema,
|
|
35
|
-
|
|
38
|
+
createTableRelationsHelpers
|
|
36
39
|
);
|
|
37
40
|
schema = {
|
|
38
41
|
fullSchema: config.schema,
|
|
@@ -40,15 +43,9 @@ function construct(client, config = {}) {
|
|
|
40
43
|
tableNamesMap: tablesConfig.tableNamesMap
|
|
41
44
|
};
|
|
42
45
|
}
|
|
43
|
-
const relations = config.relations;
|
|
44
46
|
const driver = new VercelPgDriver(client, dialect, { logger });
|
|
45
|
-
const session = driver.createSession(
|
|
46
|
-
const db = new VercelPgDatabase(
|
|
47
|
-
dialect,
|
|
48
|
-
session,
|
|
49
|
-
relations,
|
|
50
|
-
schema
|
|
51
|
-
);
|
|
47
|
+
const session = driver.createSession(schema);
|
|
48
|
+
const db = new VercelPgDatabase(dialect, session, schema);
|
|
52
49
|
db.$client = client;
|
|
53
50
|
return db;
|
|
54
51
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/vercel-postgres/driver.ts"],"sourcesContent":["import { sql } from '@vercel/postgres';\nimport
|
|
1
|
+
{"version":3,"sources":["../../src/vercel-postgres/driver.ts"],"sourcesContent":["import { sql } from '@vercel/postgres';\nimport { entityKind } from '~/entity.ts';\nimport type { Logger } from '~/logger.ts';\nimport { DefaultLogger } from '~/logger.ts';\nimport { PgDatabase } from '~/pg-core/db.ts';\nimport { PgDialect } from '~/pg-core/index.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 VercelPgClient, type VercelPgQueryResultHKT, VercelPgSession } from './session.ts';\n\nexport interface VercelPgDriverOptions {\n\tlogger?: Logger;\n}\n\nexport class VercelPgDriver {\n\tstatic readonly [entityKind]: string = 'VercelPgDriver';\n\n\tconstructor(\n\t\tprivate client: VercelPgClient,\n\t\tprivate dialect: PgDialect,\n\t\tprivate options: VercelPgDriverOptions = {},\n\t) {\n\t}\n\n\tcreateSession(\n\t\tschema: RelationalSchemaConfig<TablesRelationalConfig> | undefined,\n\t): VercelPgSession<Record<string, unknown>, TablesRelationalConfig> {\n\t\treturn new VercelPgSession(this.client, this.dialect, schema, { logger: this.options.logger });\n\t}\n}\n\nexport class VercelPgDatabase<\n\tTSchema extends Record<string, unknown> = Record<string, never>,\n> extends PgDatabase<VercelPgQueryResultHKT, TSchema> {\n\tstatic override readonly [entityKind]: string = 'VercelPgDatabase';\n}\n\nfunction construct<TSchema extends Record<string, unknown> = Record<string, never>>(\n\tclient: VercelPgClient,\n\tconfig: DrizzleConfig<TSchema> = {},\n): VercelPgDatabase<TSchema> & {\n\t$client: VercelPgClient;\n} {\n\tconst dialect = new PgDialect({ 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 driver = new VercelPgDriver(client, dialect, { logger });\n\tconst session = driver.createSession(schema);\n\tconst db = new VercelPgDatabase(dialect, session, schema as any) as VercelPgDatabase<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 VercelPgClient = typeof sql,\n>(\n\t...params: [] | [\n\t\tTClient,\n\t] | [\n\t\tTClient,\n\t\tDrizzleConfig<TSchema>,\n\t] | [\n\t\t(\n\t\t\t& DrizzleConfig<TSchema>\n\t\t\t& ({\n\t\t\t\tclient?: TClient;\n\t\t\t})\n\t\t),\n\t]\n): VercelPgDatabase<TSchema> & {\n\t$client: TClient;\n} {\n\tif (isConfig(params[0])) {\n\t\tconst { client, ...drizzleConfig } = params[0] as ({ client?: TClient } & DrizzleConfig<TSchema>);\n\t\treturn construct(client ?? sql, drizzleConfig) as any;\n\t}\n\n\treturn construct((params[0] ?? sql) 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): VercelPgDatabase<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":"AAAA,SAAS,WAAW;AACpB,SAAS,kBAAkB;AAE3B,SAAS,qBAAqB;AAC9B,SAAS,kBAAkB;AAC3B,SAAS,iBAAiB;AAC1B;AAAA,EACC;AAAA,EACA;AAAA,OAGM;AACP,SAA6B,gBAAgB;AAC7C,SAA2D,uBAAuB;AAM3E,MAAM,eAAe;AAAA,EAG3B,YACS,QACA,SACA,UAAiC,CAAC,GACzC;AAHO;AACA;AACA;AAAA,EAET;AAAA,EAPA,QAAiB,UAAU,IAAY;AAAA,EASvC,cACC,QACmE;AACnE,WAAO,IAAI,gBAAgB,KAAK,QAAQ,KAAK,SAAS,QAAQ,EAAE,QAAQ,KAAK,QAAQ,OAAO,CAAC;AAAA,EAC9F;AACD;AAEO,MAAM,yBAEH,WAA4C;AAAA,EACrD,QAA0B,UAAU,IAAY;AACjD;AAEA,SAAS,UACR,QACA,SAAiC,CAAC,GAGjC;AACD,QAAM,UAAU,IAAI,UAAU,EAAE,QAAQ,OAAO,OAAO,CAAC;AACvD,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,SAAS,IAAI,eAAe,QAAQ,SAAS,EAAE,OAAO,CAAC;AAC7D,QAAM,UAAU,OAAO,cAAc,MAAM;AAC3C,QAAM,KAAK,IAAI,iBAAiB,SAAS,SAAS,MAAa;AAC/D,EAAO,GAAI,UAAU;AAErB,SAAO;AACR;AAEO,SAAS,WAIZ,QAeF;AACD,MAAI,SAAS,OAAO,CAAC,CAAC,GAAG;AACxB,UAAM,EAAE,QAAQ,GAAG,cAAc,IAAI,OAAO,CAAC;AAC7C,WAAO,UAAU,UAAU,KAAK,aAAa;AAAA,EAC9C;AAEA,SAAO,UAAW,OAAO,CAAC,KAAK,KAAiB,OAAO,CAAC,CAAuC;AAChG;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/vercel-postgres/migrator.ts"],"sourcesContent":["import type { MigrationConfig } from '~/migrator.ts';\nimport { readMigrationFiles } from '~/migrator.ts';\nimport type {
|
|
1
|
+
{"version":3,"sources":["../../src/vercel-postgres/migrator.ts"],"sourcesContent":["import type { MigrationConfig } from '~/migrator.ts';\nimport { readMigrationFiles } from '~/migrator.ts';\nimport type { VercelPgDatabase } from './driver.ts';\n\nexport async function migrate<TSchema extends Record<string, unknown>>(\n\tdb: VercelPgDatabase<TSchema>,\n\tconfig: MigrationConfig,\n) {\n\tconst migrations = readMigrationFiles(config);\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;AAC5C,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 { VercelPgDatabase } from "./driver.cjs";
|
|
4
|
-
export declare function migrate<TSchema extends Record<string, unknown
|
|
3
|
+
export declare function migrate<TSchema extends Record<string, unknown>>(db: VercelPgDatabase<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 { VercelPgDatabase } from "./driver.js";
|
|
4
|
-
export declare function migrate<TSchema extends Record<string, unknown
|
|
3
|
+
export declare function migrate<TSchema extends Record<string, unknown>>(db: VercelPgDatabase<TSchema>, config: MigrationConfig): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/vercel-postgres/migrator.ts"],"sourcesContent":["import type { MigrationConfig } from '~/migrator.ts';\nimport { readMigrationFiles } from '~/migrator.ts';\nimport type {
|
|
1
|
+
{"version":3,"sources":["../../src/vercel-postgres/migrator.ts"],"sourcesContent":["import type { MigrationConfig } from '~/migrator.ts';\nimport { readMigrationFiles } from '~/migrator.ts';\nimport type { VercelPgDatabase } from './driver.ts';\n\nexport async function migrate<TSchema extends Record<string, unknown>>(\n\tdb: VercelPgDatabase<TSchema>,\n\tconfig: MigrationConfig,\n) {\n\tconst migrations = readMigrationFiles(config);\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;AAC5C,QAAM,GAAG,QAAQ,QAAQ,YAAY,GAAG,SAAS,MAAM;AACxD;","names":[]}
|
|
@@ -31,7 +31,7 @@ var import_session = require("../pg-core/session.cjs");
|
|
|
31
31
|
var import_sql = require("../sql/sql.cjs");
|
|
32
32
|
var import_utils = require("../utils.cjs");
|
|
33
33
|
class VercelPgPreparedQuery extends import_session.PgPreparedQuery {
|
|
34
|
-
constructor(client, queryString, params, logger, fields, name, _isResponseInArrayMode, customResultMapper
|
|
34
|
+
constructor(client, queryString, params, logger, fields, name, _isResponseInArrayMode, customResultMapper) {
|
|
35
35
|
super({ sql: queryString, params });
|
|
36
36
|
this.client = client;
|
|
37
37
|
this.params = params;
|
|
@@ -39,7 +39,6 @@ class VercelPgPreparedQuery extends import_session.PgPreparedQuery {
|
|
|
39
39
|
this.fields = fields;
|
|
40
40
|
this._isResponseInArrayMode = _isResponseInArrayMode;
|
|
41
41
|
this.customResultMapper = customResultMapper;
|
|
42
|
-
this.isRqbV2Query = isRqbV2Query;
|
|
43
42
|
this.rawQuery = {
|
|
44
43
|
name,
|
|
45
44
|
text: queryString,
|
|
@@ -90,8 +89,6 @@ class VercelPgPreparedQuery extends import_session.PgPreparedQuery {
|
|
|
90
89
|
rawQuery;
|
|
91
90
|
queryConfig;
|
|
92
91
|
async execute(placeholderValues = {}) {
|
|
93
|
-
if (this.isRqbV2Query)
|
|
94
|
-
return this.executeRqbV2(placeholderValues);
|
|
95
92
|
const params = (0, import_sql.fillPlaceholders)(this.params, placeholderValues);
|
|
96
93
|
this.logger.logQuery(this.rawQuery.text, params);
|
|
97
94
|
const { fields, rawQuery, client, queryConfig: query, joinsNotNullableMap, customResultMapper } = this;
|
|
@@ -104,13 +101,6 @@ class VercelPgPreparedQuery extends import_session.PgPreparedQuery {
|
|
|
104
101
|
}
|
|
105
102
|
return rows.map((row) => (0, import_utils.mapResultRow)(fields, row, joinsNotNullableMap));
|
|
106
103
|
}
|
|
107
|
-
async executeRqbV2(placeholderValues = {}) {
|
|
108
|
-
const params = (0, import_sql.fillPlaceholders)(this.params, placeholderValues);
|
|
109
|
-
this.logger.logQuery(this.rawQuery.text, params);
|
|
110
|
-
const { rawQuery, client, customResultMapper } = this;
|
|
111
|
-
const { rows } = await client.query(rawQuery, params);
|
|
112
|
-
return customResultMapper(rows);
|
|
113
|
-
}
|
|
114
104
|
all(placeholderValues = {}) {
|
|
115
105
|
const params = (0, import_sql.fillPlaceholders)(this.params, placeholderValues);
|
|
116
106
|
this.logger.logQuery(this.rawQuery.text, params);
|
|
@@ -127,10 +117,9 @@ class VercelPgPreparedQuery extends import_session.PgPreparedQuery {
|
|
|
127
117
|
}
|
|
128
118
|
}
|
|
129
119
|
class VercelPgSession extends import_session.PgSession {
|
|
130
|
-
constructor(client, dialect,
|
|
120
|
+
constructor(client, dialect, schema, options = {}) {
|
|
131
121
|
super(dialect);
|
|
132
122
|
this.client = client;
|
|
133
|
-
this.relations = relations;
|
|
134
123
|
this.schema = schema;
|
|
135
124
|
this.options = options;
|
|
136
125
|
this.logger = options.logger ?? new import_logger.NoopLogger();
|
|
@@ -149,19 +138,6 @@ class VercelPgSession extends import_session.PgSession {
|
|
|
149
138
|
customResultMapper
|
|
150
139
|
);
|
|
151
140
|
}
|
|
152
|
-
prepareRelationalQuery(query, fields, name, customResultMapper) {
|
|
153
|
-
return new VercelPgPreparedQuery(
|
|
154
|
-
this.client,
|
|
155
|
-
query.sql,
|
|
156
|
-
query.params,
|
|
157
|
-
this.logger,
|
|
158
|
-
fields,
|
|
159
|
-
name,
|
|
160
|
-
false,
|
|
161
|
-
customResultMapper,
|
|
162
|
-
true
|
|
163
|
-
);
|
|
164
|
-
}
|
|
165
141
|
async query(query, params) {
|
|
166
142
|
this.logger.logQuery(query, params);
|
|
167
143
|
const result = await this.client.query({
|
|
@@ -174,14 +150,13 @@ class VercelPgSession extends import_session.PgSession {
|
|
|
174
150
|
async queryObjects(query, params) {
|
|
175
151
|
return this.client.query(query, params);
|
|
176
152
|
}
|
|
153
|
+
async count(sql2) {
|
|
154
|
+
const result = await this.execute(sql2);
|
|
155
|
+
return Number(result["rows"][0]["count"]);
|
|
156
|
+
}
|
|
177
157
|
async transaction(transaction, config) {
|
|
178
|
-
const session = this.client instanceof import_postgres.VercelPool ? new VercelPgSession(await this.client.connect(), this.dialect, this.
|
|
179
|
-
const tx = new VercelPgTransaction(
|
|
180
|
-
this.dialect,
|
|
181
|
-
session,
|
|
182
|
-
this.relations,
|
|
183
|
-
this.schema
|
|
184
|
-
);
|
|
158
|
+
const session = this.client instanceof import_postgres.VercelPool ? new VercelPgSession(await this.client.connect(), this.dialect, this.schema, this.options) : this;
|
|
159
|
+
const tx = new VercelPgTransaction(this.dialect, session, this.schema);
|
|
185
160
|
await tx.execute(import_sql.sql`begin${config ? import_sql.sql` ${tx.getTransactionConfigSQL(config)}` : void 0}`);
|
|
186
161
|
try {
|
|
187
162
|
const result = await transaction(tx);
|
|
@@ -204,7 +179,6 @@ class VercelPgTransaction extends import_pg_core.PgTransaction {
|
|
|
204
179
|
const tx = new VercelPgTransaction(
|
|
205
180
|
this.dialect,
|
|
206
181
|
this.session,
|
|
207
|
-
this.relations,
|
|
208
182
|
this.schema,
|
|
209
183
|
this.nestedIndex + 1
|
|
210
184
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/vercel-postgres/session.ts"],"sourcesContent":["import {\n\ttype QueryArrayConfig,\n\ttype QueryConfig,\n\ttype QueryResult,\n\ttype QueryResultRow,\n\ttypes,\n\ttype VercelClient,\n\tVercelPool,\n\ttype VercelPoolClient,\n} from '@vercel/postgres';\nimport type * as V1 from '~/_relations.ts';\nimport { entityKind } from '~/entity.ts';\nimport { type Logger, NoopLogger } from '~/logger.ts';\nimport { type PgDialect, PgTransaction } from '~/pg-core/index.ts';\nimport type { SelectedFieldsOrdered } from '~/pg-core/query-builders/select.types.ts';\nimport type { PgQueryResultHKT, PgTransactionConfig, PreparedQueryConfig } from '~/pg-core/session.ts';\nimport { PgPreparedQuery, PgSession } from '~/pg-core/session.ts';\nimport type { AnyRelations, TablesRelationalConfig } from '~/relations.ts';\nimport { fillPlaceholders, type Query, sql } from '~/sql/sql.ts';\nimport { type Assume, mapResultRow } from '~/utils.ts';\n\nexport type VercelPgClient = VercelPool | VercelClient | VercelPoolClient;\n\nexport class VercelPgPreparedQuery<T extends PreparedQueryConfig, TIsRqbV2 extends boolean = false>\n\textends PgPreparedQuery<T>\n{\n\tstatic override readonly [entityKind]: string = 'VercelPgPreparedQuery';\n\n\tprivate rawQuery: QueryConfig;\n\tprivate queryConfig: QueryArrayConfig;\n\n\tconstructor(\n\t\tprivate client: VercelPgClient,\n\t\tqueryString: string,\n\t\tprivate params: unknown[],\n\t\tprivate logger: Logger,\n\t\tprivate fields: SelectedFieldsOrdered | undefined,\n\t\tname: string | undefined,\n\t\tprivate _isResponseInArrayMode: boolean,\n\t\tprivate customResultMapper?: (\n\t\t\trows: TIsRqbV2 extends true ? Record<string, unknown>[] : unknown[][],\n\t\t) => T['execute'],\n\t\tprivate isRqbV2Query?: TIsRqbV2,\n\t) {\n\t\tsuper({ sql: queryString, params });\n\t\tthis.rawQuery = {\n\t\t\tname,\n\t\t\ttext: queryString,\n\t\t\ttypes: {\n\t\t\t\t// @ts-ignore\n\t\t\t\tgetTypeParser: (typeId, format) => {\n\t\t\t\t\tif (typeId === types.builtins.TIMESTAMPTZ) {\n\t\t\t\t\t\treturn (val: any) => val;\n\t\t\t\t\t}\n\t\t\t\t\tif (typeId === types.builtins.TIMESTAMP) {\n\t\t\t\t\t\treturn (val: any) => val;\n\t\t\t\t\t}\n\t\t\t\t\tif (typeId === types.builtins.DATE) {\n\t\t\t\t\t\treturn (val: any) => val;\n\t\t\t\t\t}\n\t\t\t\t\tif (typeId === types.builtins.INTERVAL) {\n\t\t\t\t\t\treturn (val: any) => val;\n\t\t\t\t\t}\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\treturn types.getTypeParser(typeId, format);\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t\tthis.queryConfig = {\n\t\t\tname,\n\t\t\ttext: queryString,\n\t\t\trowMode: 'array',\n\t\t\ttypes: {\n\t\t\t\t// @ts-ignore\n\t\t\t\tgetTypeParser: (typeId, format) => {\n\t\t\t\t\tif (typeId === types.builtins.TIMESTAMPTZ) {\n\t\t\t\t\t\treturn (val: any) => val;\n\t\t\t\t\t}\n\t\t\t\t\tif (typeId === types.builtins.TIMESTAMP) {\n\t\t\t\t\t\treturn (val: any) => val;\n\t\t\t\t\t}\n\t\t\t\t\tif (typeId === types.builtins.DATE) {\n\t\t\t\t\t\treturn (val: any) => val;\n\t\t\t\t\t}\n\t\t\t\t\tif (typeId === types.builtins.INTERVAL) {\n\t\t\t\t\t\treturn (val: any) => val;\n\t\t\t\t\t}\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\treturn types.getTypeParser(typeId, format);\n\t\t\t\t},\n\t\t\t},\n\t\t};\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.rawQuery.text, params);\n\n\t\tconst { fields, rawQuery, client, queryConfig: query, joinsNotNullableMap, customResultMapper } = this;\n\t\tif (!fields && !customResultMapper) {\n\t\t\treturn client.query(rawQuery, params);\n\t\t}\n\n\t\tconst { rows } = await client.query(query, params);\n\n\t\tif (customResultMapper) {\n\t\t\treturn (customResultMapper as (rows: unknown[][]) => T['execute'])(rows);\n\t\t}\n\n\t\treturn rows.map((row) => mapResultRow<T['execute']>(fields!, row, 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.rawQuery.text, params);\n\n\t\tconst { rawQuery, client, customResultMapper } = this;\n\n\t\tconst { rows } = await client.query(rawQuery, params);\n\n\t\treturn (customResultMapper as (rows: Record<string, unknown>[]) => T['execute'])(rows);\n\t}\n\n\tall(placeholderValues: Record<string, unknown> | undefined = {}): Promise<T['all']> {\n\t\tconst params = fillPlaceholders(this.params, placeholderValues);\n\t\tthis.logger.logQuery(this.rawQuery.text, params);\n\t\treturn this.client.query(this.rawQuery, params).then((result) => result.rows);\n\t}\n\n\tvalues(placeholderValues: Record<string, unknown> | undefined = {}): Promise<T['values']> {\n\t\tconst params = fillPlaceholders(this.params, placeholderValues);\n\t\tthis.logger.logQuery(this.rawQuery.text, params);\n\t\treturn this.client.query(this.queryConfig, params).then((result) => result.rows);\n\t}\n\n\t/** @internal */\n\tisResponseInArrayMode(): boolean {\n\t\treturn this._isResponseInArrayMode;\n\t}\n}\n\nexport interface VercelPgSessionOptions {\n\tlogger?: Logger;\n}\n\nexport class VercelPgSession<\n\tTFullSchema extends Record<string, unknown>,\n\tTRelations extends AnyRelations,\n\tTTablesConfig extends TablesRelationalConfig,\n\tTSchema extends V1.TablesRelationalConfig,\n> extends PgSession<VercelPgQueryResultHKT, TFullSchema, TRelations, TTablesConfig, TSchema> {\n\tstatic override readonly [entityKind]: string = 'VercelPgSession';\n\n\tprivate logger: Logger;\n\n\tconstructor(\n\t\tprivate client: VercelPgClient,\n\t\tdialect: PgDialect,\n\t\tprivate relations: AnyRelations | undefined,\n\t\tprivate schema: V1.RelationalSchemaConfig<TSchema> | undefined,\n\t\tprivate options: VercelPgSessionOptions = {},\n\t) {\n\t\tsuper(dialect);\n\t\tthis.logger = options.logger ?? new NoopLogger();\n\t}\n\n\tprepareQuery<T extends PreparedQueryConfig = PreparedQueryConfig>(\n\t\tquery: Query,\n\t\tfields: SelectedFieldsOrdered | undefined,\n\t\tname: string | undefined,\n\t\tisResponseInArrayMode: boolean,\n\t\tcustomResultMapper?: (rows: unknown[][]) => T['execute'],\n\t): PgPreparedQuery<T> {\n\t\treturn new VercelPgPreparedQuery(\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\tname,\n\t\t\tisResponseInArrayMode,\n\t\t\tcustomResultMapper,\n\t\t);\n\t}\n\n\tprepareRelationalQuery<T extends PreparedQueryConfig = PreparedQueryConfig>(\n\t\tquery: Query,\n\t\tfields: SelectedFieldsOrdered | undefined,\n\t\tname: string | undefined,\n\t\tcustomResultMapper: (rows: Record<string, unknown>[]) => T['execute'],\n\t): PgPreparedQuery<T> {\n\t\treturn new VercelPgPreparedQuery(\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\tname,\n\t\t\tfalse,\n\t\t\tcustomResultMapper,\n\t\t\ttrue,\n\t\t);\n\t}\n\n\tasync query(query: string, params: unknown[]): Promise<QueryResult> {\n\t\tthis.logger.logQuery(query, params);\n\t\tconst result = await this.client.query({\n\t\t\trowMode: 'array',\n\t\t\ttext: query,\n\t\t\tvalues: params,\n\t\t});\n\t\treturn result;\n\t}\n\n\tasync queryObjects<T extends QueryResultRow>(\n\t\tquery: string,\n\t\tparams: unknown[],\n\t): Promise<QueryResult<T>> {\n\t\treturn this.client.query<T>(query, params);\n\t}\n\n\toverride async transaction<T>(\n\t\ttransaction: (tx: VercelPgTransaction<TFullSchema, TRelations, TTablesConfig, TSchema>) => Promise<T>,\n\t\tconfig?: PgTransactionConfig | undefined,\n\t): Promise<T> {\n\t\tconst session = this.client instanceof VercelPool // eslint-disable-line no-instanceof/no-instanceof\n\t\t\t? new VercelPgSession(await this.client.connect(), this.dialect, this.relations, this.schema, this.options)\n\t\t\t: this;\n\t\tconst tx = new VercelPgTransaction<TFullSchema, TRelations, TTablesConfig, TSchema>(\n\t\t\tthis.dialect,\n\t\t\tsession,\n\t\t\tthis.relations,\n\t\t\tthis.schema,\n\t\t);\n\t\tawait tx.execute(sql`begin${config ? sql` ${tx.getTransactionConfigSQL(config)}` : undefined}`);\n\t\ttry {\n\t\t\tconst result = await transaction(tx);\n\t\t\tawait tx.execute(sql`commit`);\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tawait tx.execute(sql`rollback`);\n\t\t\tthrow error;\n\t\t} finally {\n\t\t\tif (this.client instanceof VercelPool) { // eslint-disable-line no-instanceof/no-instanceof\n\t\t\t\t(session.client as VercelPoolClient).release();\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport class VercelPgTransaction<\n\tTFullSchema extends Record<string, unknown>,\n\tTRelations extends AnyRelations,\n\tTTablesConfig extends TablesRelationalConfig,\n\tTSchema extends V1.TablesRelationalConfig,\n> extends PgTransaction<VercelPgQueryResultHKT, TFullSchema, TRelations, TTablesConfig, TSchema> {\n\tstatic override readonly [entityKind]: string = 'VercelPgTransaction';\n\n\toverride async transaction<T>(\n\t\ttransaction: (tx: VercelPgTransaction<TFullSchema, TRelations, TTablesConfig, TSchema>) => Promise<T>,\n\t): Promise<T> {\n\t\tconst savepointName = `sp${this.nestedIndex + 1}`;\n\t\tconst tx = new VercelPgTransaction<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 VercelPgQueryResultHKT extends PgQueryResultHKT {\n\ttype: QueryResult<Assume<this['row'], QueryResultRow>>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBASO;AAEP,oBAA2B;AAC3B,oBAAwC;AACxC,qBAA8C;AAG9C,qBAA2C;AAE3C,iBAAkD;AAClD,mBAA0C;AAInC,MAAM,8BACJ,+BACT;AAAA,EAMC,YACS,QACR,aACQ,QACA,QACA,QACR,MACQ,wBACA,oBAGA,cACP;AACD,UAAM,EAAE,KAAK,aAAa,OAAO,CAAC;AAZ1B;AAEA;AACA;AACA;AAEA;AACA;AAGA;AAGR,SAAK,WAAW;AAAA,MACf;AAAA,MACA,MAAM;AAAA,MACN,OAAO;AAAA;AAAA,QAEN,eAAe,CAAC,QAAQ,WAAW;AAClC,cAAI,WAAW,sBAAM,SAAS,aAAa;AAC1C,mBAAO,CAAC,QAAa;AAAA,UACtB;AACA,cAAI,WAAW,sBAAM,SAAS,WAAW;AACxC,mBAAO,CAAC,QAAa;AAAA,UACtB;AACA,cAAI,WAAW,sBAAM,SAAS,MAAM;AACnC,mBAAO,CAAC,QAAa;AAAA,UACtB;AACA,cAAI,WAAW,sBAAM,SAAS,UAAU;AACvC,mBAAO,CAAC,QAAa;AAAA,UACtB;AAEA,iBAAO,sBAAM,cAAc,QAAQ,MAAM;AAAA,QAC1C;AAAA,MACD;AAAA,IACD;AACA,SAAK,cAAc;AAAA,MAClB;AAAA,MACA,MAAM;AAAA,MACN,SAAS;AAAA,MACT,OAAO;AAAA;AAAA,QAEN,eAAe,CAAC,QAAQ,WAAW;AAClC,cAAI,WAAW,sBAAM,SAAS,aAAa;AAC1C,mBAAO,CAAC,QAAa;AAAA,UACtB;AACA,cAAI,WAAW,sBAAM,SAAS,WAAW;AACxC,m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AAC9D,aAAO;AAAA,IACR,SAAS,KAAK;AACb,YAAM,GAAG,QAAQ,eAAI,IAAI,yBAAyB,aAAa,EAAE,CAAC;AAClE,YAAM;AAAA,IACP;AAAA,EACD;AACD;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/vercel-postgres/session.ts"],"sourcesContent":["import {\n\ttype QueryArrayConfig,\n\ttype QueryConfig,\n\ttype QueryResult,\n\ttype QueryResultRow,\n\ttypes,\n\ttype VercelClient,\n\tVercelPool,\n\ttype VercelPoolClient,\n} from '@vercel/postgres';\nimport { entityKind } from '~/entity.ts';\nimport { type Logger, NoopLogger } from '~/logger.ts';\nimport { type PgDialect, PgTransaction } from '~/pg-core/index.ts';\nimport type { SelectedFieldsOrdered } from '~/pg-core/query-builders/select.types.ts';\nimport type { PgQueryResultHKT, PgTransactionConfig, PreparedQueryConfig } from '~/pg-core/session.ts';\nimport { PgPreparedQuery, PgSession } from '~/pg-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 type VercelPgClient = VercelPool | VercelClient | VercelPoolClient;\n\nexport class VercelPgPreparedQuery<T extends PreparedQueryConfig> extends PgPreparedQuery<T> {\n\tstatic override readonly [entityKind]: string = 'VercelPgPreparedQuery';\n\n\tprivate rawQuery: QueryConfig;\n\tprivate queryConfig: QueryArrayConfig;\n\n\tconstructor(\n\t\tprivate client: VercelPgClient,\n\t\tqueryString: string,\n\t\tprivate params: unknown[],\n\t\tprivate logger: Logger,\n\t\tprivate fields: SelectedFieldsOrdered | undefined,\n\t\tname: string | undefined,\n\t\tprivate _isResponseInArrayMode: boolean,\n\t\tprivate customResultMapper?: (rows: unknown[][]) => T['execute'],\n\t) {\n\t\tsuper({ sql: queryString, params });\n\t\tthis.rawQuery = {\n\t\t\tname,\n\t\t\ttext: queryString,\n\t\t\ttypes: {\n\t\t\t\t// @ts-ignore\n\t\t\t\tgetTypeParser: (typeId, format) => {\n\t\t\t\t\tif (typeId === types.builtins.TIMESTAMPTZ) {\n\t\t\t\t\t\treturn (val: any) => val;\n\t\t\t\t\t}\n\t\t\t\t\tif (typeId === types.builtins.TIMESTAMP) {\n\t\t\t\t\t\treturn (val: any) => val;\n\t\t\t\t\t}\n\t\t\t\t\tif (typeId === types.builtins.DATE) {\n\t\t\t\t\t\treturn (val: any) => val;\n\t\t\t\t\t}\n\t\t\t\t\tif (typeId === types.builtins.INTERVAL) {\n\t\t\t\t\t\treturn (val: any) => val;\n\t\t\t\t\t}\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\treturn types.getTypeParser(typeId, format);\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t\tthis.queryConfig = {\n\t\t\tname,\n\t\t\ttext: queryString,\n\t\t\trowMode: 'array',\n\t\t\ttypes: {\n\t\t\t\t// @ts-ignore\n\t\t\t\tgetTypeParser: (typeId, format) => {\n\t\t\t\t\tif (typeId === types.builtins.TIMESTAMPTZ) {\n\t\t\t\t\t\treturn (val: any) => val;\n\t\t\t\t\t}\n\t\t\t\t\tif (typeId === types.builtins.TIMESTAMP) {\n\t\t\t\t\t\treturn (val: any) => val;\n\t\t\t\t\t}\n\t\t\t\t\tif (typeId === types.builtins.DATE) {\n\t\t\t\t\t\treturn (val: any) => val;\n\t\t\t\t\t}\n\t\t\t\t\tif (typeId === types.builtins.INTERVAL) {\n\t\t\t\t\t\treturn (val: any) => val;\n\t\t\t\t\t}\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\treturn types.getTypeParser(typeId, format);\n\t\t\t\t},\n\t\t\t},\n\t\t};\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.rawQuery.text, params);\n\n\t\tconst { fields, rawQuery, client, queryConfig: query, joinsNotNullableMap, customResultMapper } = this;\n\t\tif (!fields && !customResultMapper) {\n\t\t\treturn client.query(rawQuery, params);\n\t\t}\n\n\t\tconst { rows } = await client.query(query, params);\n\n\t\tif (customResultMapper) {\n\t\t\treturn customResultMapper(rows);\n\t\t}\n\n\t\treturn rows.map((row) => mapResultRow<T['execute']>(fields!, row, joinsNotNullableMap));\n\t}\n\n\tall(placeholderValues: Record<string, unknown> | undefined = {}): Promise<T['all']> {\n\t\tconst params = fillPlaceholders(this.params, placeholderValues);\n\t\tthis.logger.logQuery(this.rawQuery.text, params);\n\t\treturn this.client.query(this.rawQuery, params).then((result) => result.rows);\n\t}\n\n\tvalues(placeholderValues: Record<string, unknown> | undefined = {}): Promise<T['values']> {\n\t\tconst params = fillPlaceholders(this.params, placeholderValues);\n\t\tthis.logger.logQuery(this.rawQuery.text, params);\n\t\treturn this.client.query(this.queryConfig, params).then((result) => result.rows);\n\t}\n\n\t/** @internal */\n\tisResponseInArrayMode(): boolean {\n\t\treturn this._isResponseInArrayMode;\n\t}\n}\n\nexport interface VercelPgSessionOptions {\n\tlogger?: Logger;\n}\n\nexport class VercelPgSession<\n\tTFullSchema extends Record<string, unknown>,\n\tTSchema extends TablesRelationalConfig,\n> extends PgSession<VercelPgQueryResultHKT, TFullSchema, TSchema> {\n\tstatic override readonly [entityKind]: string = 'VercelPgSession';\n\n\tprivate logger: Logger;\n\n\tconstructor(\n\t\tprivate client: VercelPgClient,\n\t\tdialect: PgDialect,\n\t\tprivate schema: RelationalSchemaConfig<TSchema> | undefined,\n\t\tprivate options: VercelPgSessionOptions = {},\n\t) {\n\t\tsuper(dialect);\n\t\tthis.logger = options.logger ?? new NoopLogger();\n\t}\n\n\tprepareQuery<T extends PreparedQueryConfig = PreparedQueryConfig>(\n\t\tquery: Query,\n\t\tfields: SelectedFieldsOrdered | undefined,\n\t\tname: string | undefined,\n\t\tisResponseInArrayMode: boolean,\n\t\tcustomResultMapper?: (rows: unknown[][]) => T['execute'],\n\t): PgPreparedQuery<T> {\n\t\treturn new VercelPgPreparedQuery(\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\tname,\n\t\t\tisResponseInArrayMode,\n\t\t\tcustomResultMapper,\n\t\t);\n\t}\n\n\tasync query(query: string, params: unknown[]): Promise<QueryResult> {\n\t\tthis.logger.logQuery(query, params);\n\t\tconst result = await this.client.query({\n\t\t\trowMode: 'array',\n\t\t\ttext: query,\n\t\t\tvalues: params,\n\t\t});\n\t\treturn result;\n\t}\n\n\tasync queryObjects<T extends QueryResultRow>(\n\t\tquery: string,\n\t\tparams: unknown[],\n\t): Promise<QueryResult<T>> {\n\t\treturn this.client.query<T>(query, params);\n\t}\n\n\toverride async count(sql: SQL): Promise<number> {\n\t\tconst result = await this.execute(sql);\n\n\t\treturn Number((result as any)['rows'][0]['count']);\n\t}\n\n\toverride async transaction<T>(\n\t\ttransaction: (tx: VercelPgTransaction<TFullSchema, TSchema>) => Promise<T>,\n\t\tconfig?: PgTransactionConfig | undefined,\n\t): Promise<T> {\n\t\tconst session = this.client instanceof VercelPool // eslint-disable-line no-instanceof/no-instanceof\n\t\t\t? new VercelPgSession(await this.client.connect(), this.dialect, this.schema, this.options)\n\t\t\t: this;\n\t\tconst tx = new VercelPgTransaction<TFullSchema, TSchema>(this.dialect, session, this.schema);\n\t\tawait tx.execute(sql`begin${config ? sql` ${tx.getTransactionConfigSQL(config)}` : undefined}`);\n\t\ttry {\n\t\t\tconst result = await transaction(tx);\n\t\t\tawait tx.execute(sql`commit`);\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tawait tx.execute(sql`rollback`);\n\t\t\tthrow error;\n\t\t} finally {\n\t\t\tif (this.client instanceof VercelPool) { // eslint-disable-line no-instanceof/no-instanceof\n\t\t\t\t(session.client as VercelPoolClient).release();\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport class VercelPgTransaction<\n\tTFullSchema extends Record<string, unknown>,\n\tTSchema extends TablesRelationalConfig,\n> extends PgTransaction<VercelPgQueryResultHKT, TFullSchema, TSchema> {\n\tstatic override readonly [entityKind]: string = 'VercelPgTransaction';\n\n\toverride async transaction<T>(\n\t\ttransaction: (tx: VercelPgTransaction<TFullSchema, TSchema>) => Promise<T>,\n\t): Promise<T> {\n\t\tconst savepointName = `sp${this.nestedIndex + 1}`;\n\t\tconst tx = new VercelPgTransaction<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 VercelPgQueryResultHKT extends PgQueryResultHKT {\n\ttype: QueryResult<Assume<this['row'], QueryResultRow>>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBASO;AACP,oBAA2B;AAC3B,oBAAwC;AACxC,qBAA8C;AAG9C,qBAA2C;AAE3C,iBAA4D;AAC5D,mBAA0C;AAInC,MAAM,8BAA6D,+BAAmB;AAAA,EAM5F,YACS,QACR,aACQ,QACA,QACA,QACR,MACQ,wBACA,oBACP;AACD,UAAM,EAAE,KAAK,aAAa,OAAO,CAAC;AAT1B;AAEA;AACA;AACA;AAEA;AACA;AAGR,SAAK,WAAW;AAAA,MACf;AAAA,MACA,MAAM;AAAA,MACN,OAAO;AAAA;AAAA,QAEN,eAAe,CAAC,QAAQ,WAAW;AAClC,cAAI,WAAW,sBAAM,SAAS,aAAa;AAC1C,mBAAO,CAAC,QAAa;AAAA,UACtB;AACA,cAAI,WAAW,sBAAM,SAAS,WAAW;AACxC,mBAAO,C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qB,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,52 +1,48 @@
|
|
|
1
1
|
import { type QueryResult, type QueryResultRow, type VercelClient, VercelPool, type VercelPoolClient } from '@vercel/postgres';
|
|
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 PgDialect, PgTransaction } from "../pg-core/index.cjs";
|
|
6
5
|
import type { SelectedFieldsOrdered } from "../pg-core/query-builders/select.types.cjs";
|
|
7
6
|
import type { PgQueryResultHKT, PgTransactionConfig, PreparedQueryConfig } from "../pg-core/session.cjs";
|
|
8
7
|
import { PgPreparedQuery, PgSession } from "../pg-core/session.cjs";
|
|
9
|
-
import type {
|
|
10
|
-
import { type Query } from "../sql/sql.cjs";
|
|
8
|
+
import type { RelationalSchemaConfig, TablesRelationalConfig } from "../relations.cjs";
|
|
9
|
+
import { type Query, type SQL } from "../sql/sql.cjs";
|
|
11
10
|
import { type Assume } from "../utils.cjs";
|
|
12
11
|
export type VercelPgClient = VercelPool | VercelClient | VercelPoolClient;
|
|
13
|
-
export declare class VercelPgPreparedQuery<T extends PreparedQueryConfig
|
|
12
|
+
export declare class VercelPgPreparedQuery<T extends PreparedQueryConfig> extends PgPreparedQuery<T> {
|
|
14
13
|
private client;
|
|
15
14
|
private params;
|
|
16
15
|
private logger;
|
|
17
16
|
private fields;
|
|
18
17
|
private _isResponseInArrayMode;
|
|
19
18
|
private customResultMapper?;
|
|
20
|
-
private isRqbV2Query?;
|
|
21
19
|
static readonly [entityKind]: string;
|
|
22
20
|
private rawQuery;
|
|
23
21
|
private queryConfig;
|
|
24
|
-
constructor(client: VercelPgClient, queryString: string, params: unknown[], logger: Logger, fields: SelectedFieldsOrdered | undefined, name: string | undefined, _isResponseInArrayMode: boolean, customResultMapper?: ((rows:
|
|
22
|
+
constructor(client: VercelPgClient, queryString: string, params: unknown[], logger: Logger, fields: SelectedFieldsOrdered | undefined, name: string | undefined, _isResponseInArrayMode: boolean, customResultMapper?: ((rows: unknown[][]) => T["execute"]) | undefined);
|
|
25
23
|
execute(placeholderValues?: Record<string, unknown> | undefined): Promise<T['execute']>;
|
|
26
|
-
private executeRqbV2;
|
|
27
24
|
all(placeholderValues?: Record<string, unknown> | undefined): Promise<T['all']>;
|
|
28
25
|
values(placeholderValues?: Record<string, unknown> | undefined): Promise<T['values']>;
|
|
29
26
|
}
|
|
30
27
|
export interface VercelPgSessionOptions {
|
|
31
28
|
logger?: Logger;
|
|
32
29
|
}
|
|
33
|
-
export declare class VercelPgSession<TFullSchema extends Record<string, unknown>,
|
|
30
|
+
export declare class VercelPgSession<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends PgSession<VercelPgQueryResultHKT, TFullSchema, TSchema> {
|
|
34
31
|
private client;
|
|
35
|
-
private relations;
|
|
36
32
|
private schema;
|
|
37
33
|
private options;
|
|
38
34
|
static readonly [entityKind]: string;
|
|
39
35
|
private logger;
|
|
40
|
-
constructor(client: VercelPgClient, dialect: PgDialect,
|
|
36
|
+
constructor(client: VercelPgClient, dialect: PgDialect, schema: RelationalSchemaConfig<TSchema> | undefined, options?: VercelPgSessionOptions);
|
|
41
37
|
prepareQuery<T extends PreparedQueryConfig = PreparedQueryConfig>(query: Query, fields: SelectedFieldsOrdered | undefined, name: string | undefined, isResponseInArrayMode: boolean, customResultMapper?: (rows: unknown[][]) => T['execute']): PgPreparedQuery<T>;
|
|
42
|
-
prepareRelationalQuery<T extends PreparedQueryConfig = PreparedQueryConfig>(query: Query, fields: SelectedFieldsOrdered | undefined, name: string | undefined, customResultMapper: (rows: Record<string, unknown>[]) => T['execute']): PgPreparedQuery<T>;
|
|
43
38
|
query(query: string, params: unknown[]): Promise<QueryResult>;
|
|
44
39
|
queryObjects<T extends QueryResultRow>(query: string, params: unknown[]): Promise<QueryResult<T>>;
|
|
45
|
-
|
|
40
|
+
count(sql: SQL): Promise<number>;
|
|
41
|
+
transaction<T>(transaction: (tx: VercelPgTransaction<TFullSchema, TSchema>) => Promise<T>, config?: PgTransactionConfig | undefined): Promise<T>;
|
|
46
42
|
}
|
|
47
|
-
export declare class VercelPgTransaction<TFullSchema extends Record<string, unknown>,
|
|
43
|
+
export declare class VercelPgTransaction<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends PgTransaction<VercelPgQueryResultHKT, TFullSchema, TSchema> {
|
|
48
44
|
static readonly [entityKind]: string;
|
|
49
|
-
transaction<T>(transaction: (tx: VercelPgTransaction<TFullSchema,
|
|
45
|
+
transaction<T>(transaction: (tx: VercelPgTransaction<TFullSchema, TSchema>) => Promise<T>): Promise<T>;
|
|
50
46
|
}
|
|
51
47
|
export interface VercelPgQueryResultHKT extends PgQueryResultHKT {
|
|
52
48
|
type: QueryResult<Assume<this['row'], QueryResultRow>>;
|
|
@@ -1,52 +1,48 @@
|
|
|
1
1
|
import { type QueryResult, type QueryResultRow, type VercelClient, VercelPool, type VercelPoolClient } from '@vercel/postgres';
|
|
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 PgDialect, PgTransaction } from "../pg-core/index.js";
|
|
6
5
|
import type { SelectedFieldsOrdered } from "../pg-core/query-builders/select.types.js";
|
|
7
6
|
import type { PgQueryResultHKT, PgTransactionConfig, PreparedQueryConfig } from "../pg-core/session.js";
|
|
8
7
|
import { PgPreparedQuery, PgSession } from "../pg-core/session.js";
|
|
9
|
-
import type {
|
|
10
|
-
import { type Query } from "../sql/sql.js";
|
|
8
|
+
import type { RelationalSchemaConfig, TablesRelationalConfig } from "../relations.js";
|
|
9
|
+
import { type Query, type SQL } from "../sql/sql.js";
|
|
11
10
|
import { type Assume } from "../utils.js";
|
|
12
11
|
export type VercelPgClient = VercelPool | VercelClient | VercelPoolClient;
|
|
13
|
-
export declare class VercelPgPreparedQuery<T extends PreparedQueryConfig
|
|
12
|
+
export declare class VercelPgPreparedQuery<T extends PreparedQueryConfig> extends PgPreparedQuery<T> {
|
|
14
13
|
private client;
|
|
15
14
|
private params;
|
|
16
15
|
private logger;
|
|
17
16
|
private fields;
|
|
18
17
|
private _isResponseInArrayMode;
|
|
19
18
|
private customResultMapper?;
|
|
20
|
-
private isRqbV2Query?;
|
|
21
19
|
static readonly [entityKind]: string;
|
|
22
20
|
private rawQuery;
|
|
23
21
|
private queryConfig;
|
|
24
|
-
constructor(client: VercelPgClient, queryString: string, params: unknown[], logger: Logger, fields: SelectedFieldsOrdered | undefined, name: string | undefined, _isResponseInArrayMode: boolean, customResultMapper?: ((rows:
|
|
22
|
+
constructor(client: VercelPgClient, queryString: string, params: unknown[], logger: Logger, fields: SelectedFieldsOrdered | undefined, name: string | undefined, _isResponseInArrayMode: boolean, customResultMapper?: ((rows: unknown[][]) => T["execute"]) | undefined);
|
|
25
23
|
execute(placeholderValues?: Record<string, unknown> | undefined): Promise<T['execute']>;
|
|
26
|
-
private executeRqbV2;
|
|
27
24
|
all(placeholderValues?: Record<string, unknown> | undefined): Promise<T['all']>;
|
|
28
25
|
values(placeholderValues?: Record<string, unknown> | undefined): Promise<T['values']>;
|
|
29
26
|
}
|
|
30
27
|
export interface VercelPgSessionOptions {
|
|
31
28
|
logger?: Logger;
|
|
32
29
|
}
|
|
33
|
-
export declare class VercelPgSession<TFullSchema extends Record<string, unknown>,
|
|
30
|
+
export declare class VercelPgSession<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends PgSession<VercelPgQueryResultHKT, TFullSchema, TSchema> {
|
|
34
31
|
private client;
|
|
35
|
-
private relations;
|
|
36
32
|
private schema;
|
|
37
33
|
private options;
|
|
38
34
|
static readonly [entityKind]: string;
|
|
39
35
|
private logger;
|
|
40
|
-
constructor(client: VercelPgClient, dialect: PgDialect,
|
|
36
|
+
constructor(client: VercelPgClient, dialect: PgDialect, schema: RelationalSchemaConfig<TSchema> | undefined, options?: VercelPgSessionOptions);
|
|
41
37
|
prepareQuery<T extends PreparedQueryConfig = PreparedQueryConfig>(query: Query, fields: SelectedFieldsOrdered | undefined, name: string | undefined, isResponseInArrayMode: boolean, customResultMapper?: (rows: unknown[][]) => T['execute']): PgPreparedQuery<T>;
|
|
42
|
-
prepareRelationalQuery<T extends PreparedQueryConfig = PreparedQueryConfig>(query: Query, fields: SelectedFieldsOrdered | undefined, name: string | undefined, customResultMapper: (rows: Record<string, unknown>[]) => T['execute']): PgPreparedQuery<T>;
|
|
43
38
|
query(query: string, params: unknown[]): Promise<QueryResult>;
|
|
44
39
|
queryObjects<T extends QueryResultRow>(query: string, params: unknown[]): Promise<QueryResult<T>>;
|
|
45
|
-
|
|
40
|
+
count(sql: SQL): Promise<number>;
|
|
41
|
+
transaction<T>(transaction: (tx: VercelPgTransaction<TFullSchema, TSchema>) => Promise<T>, config?: PgTransactionConfig | undefined): Promise<T>;
|
|
46
42
|
}
|
|
47
|
-
export declare class VercelPgTransaction<TFullSchema extends Record<string, unknown>,
|
|
43
|
+
export declare class VercelPgTransaction<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends PgTransaction<VercelPgQueryResultHKT, TFullSchema, TSchema> {
|
|
48
44
|
static readonly [entityKind]: string;
|
|
49
|
-
transaction<T>(transaction: (tx: VercelPgTransaction<TFullSchema,
|
|
45
|
+
transaction<T>(transaction: (tx: VercelPgTransaction<TFullSchema, TSchema>) => Promise<T>): Promise<T>;
|
|
50
46
|
}
|
|
51
47
|
export interface VercelPgQueryResultHKT extends PgQueryResultHKT {
|
|
52
48
|
type: QueryResult<Assume<this['row'], QueryResultRow>>;
|
|
@@ -9,7 +9,7 @@ import { PgPreparedQuery, PgSession } from "../pg-core/session.js";
|
|
|
9
9
|
import { fillPlaceholders, sql } from "../sql/sql.js";
|
|
10
10
|
import { mapResultRow } from "../utils.js";
|
|
11
11
|
class VercelPgPreparedQuery extends PgPreparedQuery {
|
|
12
|
-
constructor(client, queryString, params, logger, fields, name, _isResponseInArrayMode, customResultMapper
|
|
12
|
+
constructor(client, queryString, params, logger, fields, name, _isResponseInArrayMode, customResultMapper) {
|
|
13
13
|
super({ sql: queryString, params });
|
|
14
14
|
this.client = client;
|
|
15
15
|
this.params = params;
|
|
@@ -17,7 +17,6 @@ class VercelPgPreparedQuery extends PgPreparedQuery {
|
|
|
17
17
|
this.fields = fields;
|
|
18
18
|
this._isResponseInArrayMode = _isResponseInArrayMode;
|
|
19
19
|
this.customResultMapper = customResultMapper;
|
|
20
|
-
this.isRqbV2Query = isRqbV2Query;
|
|
21
20
|
this.rawQuery = {
|
|
22
21
|
name,
|
|
23
22
|
text: queryString,
|
|
@@ -68,8 +67,6 @@ class VercelPgPreparedQuery extends PgPreparedQuery {
|
|
|
68
67
|
rawQuery;
|
|
69
68
|
queryConfig;
|
|
70
69
|
async execute(placeholderValues = {}) {
|
|
71
|
-
if (this.isRqbV2Query)
|
|
72
|
-
return this.executeRqbV2(placeholderValues);
|
|
73
70
|
const params = fillPlaceholders(this.params, placeholderValues);
|
|
74
71
|
this.logger.logQuery(this.rawQuery.text, params);
|
|
75
72
|
const { fields, rawQuery, client, queryConfig: query, joinsNotNullableMap, customResultMapper } = this;
|
|
@@ -82,13 +79,6 @@ class VercelPgPreparedQuery extends PgPreparedQuery {
|
|
|
82
79
|
}
|
|
83
80
|
return rows.map((row) => mapResultRow(fields, row, joinsNotNullableMap));
|
|
84
81
|
}
|
|
85
|
-
async executeRqbV2(placeholderValues = {}) {
|
|
86
|
-
const params = fillPlaceholders(this.params, placeholderValues);
|
|
87
|
-
this.logger.logQuery(this.rawQuery.text, params);
|
|
88
|
-
const { rawQuery, client, customResultMapper } = this;
|
|
89
|
-
const { rows } = await client.query(rawQuery, params);
|
|
90
|
-
return customResultMapper(rows);
|
|
91
|
-
}
|
|
92
82
|
all(placeholderValues = {}) {
|
|
93
83
|
const params = fillPlaceholders(this.params, placeholderValues);
|
|
94
84
|
this.logger.logQuery(this.rawQuery.text, params);
|
|
@@ -105,10 +95,9 @@ class VercelPgPreparedQuery extends PgPreparedQuery {
|
|
|
105
95
|
}
|
|
106
96
|
}
|
|
107
97
|
class VercelPgSession extends PgSession {
|
|
108
|
-
constructor(client, dialect,
|
|
98
|
+
constructor(client, dialect, schema, options = {}) {
|
|
109
99
|
super(dialect);
|
|
110
100
|
this.client = client;
|
|
111
|
-
this.relations = relations;
|
|
112
101
|
this.schema = schema;
|
|
113
102
|
this.options = options;
|
|
114
103
|
this.logger = options.logger ?? new NoopLogger();
|
|
@@ -127,19 +116,6 @@ class VercelPgSession extends PgSession {
|
|
|
127
116
|
customResultMapper
|
|
128
117
|
);
|
|
129
118
|
}
|
|
130
|
-
prepareRelationalQuery(query, fields, name, customResultMapper) {
|
|
131
|
-
return new VercelPgPreparedQuery(
|
|
132
|
-
this.client,
|
|
133
|
-
query.sql,
|
|
134
|
-
query.params,
|
|
135
|
-
this.logger,
|
|
136
|
-
fields,
|
|
137
|
-
name,
|
|
138
|
-
false,
|
|
139
|
-
customResultMapper,
|
|
140
|
-
true
|
|
141
|
-
);
|
|
142
|
-
}
|
|
143
119
|
async query(query, params) {
|
|
144
120
|
this.logger.logQuery(query, params);
|
|
145
121
|
const result = await this.client.query({
|
|
@@ -152,14 +128,13 @@ class VercelPgSession extends PgSession {
|
|
|
152
128
|
async queryObjects(query, params) {
|
|
153
129
|
return this.client.query(query, params);
|
|
154
130
|
}
|
|
131
|
+
async count(sql2) {
|
|
132
|
+
const result = await this.execute(sql2);
|
|
133
|
+
return Number(result["rows"][0]["count"]);
|
|
134
|
+
}
|
|
155
135
|
async transaction(transaction, config) {
|
|
156
|
-
const session = this.client instanceof VercelPool ? new VercelPgSession(await this.client.connect(), this.dialect, this.
|
|
157
|
-
const tx = new VercelPgTransaction(
|
|
158
|
-
this.dialect,
|
|
159
|
-
session,
|
|
160
|
-
this.relations,
|
|
161
|
-
this.schema
|
|
162
|
-
);
|
|
136
|
+
const session = this.client instanceof VercelPool ? new VercelPgSession(await this.client.connect(), this.dialect, this.schema, this.options) : this;
|
|
137
|
+
const tx = new VercelPgTransaction(this.dialect, session, this.schema);
|
|
163
138
|
await tx.execute(sql`begin${config ? sql` ${tx.getTransactionConfigSQL(config)}` : void 0}`);
|
|
164
139
|
try {
|
|
165
140
|
const result = await transaction(tx);
|
|
@@ -182,7 +157,6 @@ class VercelPgTransaction extends PgTransaction {
|
|
|
182
157
|
const tx = new VercelPgTransaction(
|
|
183
158
|
this.dialect,
|
|
184
159
|
this.session,
|
|
185
|
-
this.relations,
|
|
186
160
|
this.schema,
|
|
187
161
|
this.nestedIndex + 1
|
|
188
162
|
);
|