drizzle-orm 0.38.3-7db411e → 0.38.3-8e428d1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/alias.cjs.map +1 -1
- package/alias.d.cts +3 -3
- package/alias.d.ts +3 -3
- package/alias.js.map +1 -1
- package/aws-data-api/pg/driver.cjs +5 -19
- package/aws-data-api/pg/driver.cjs.map +1 -1
- package/aws-data-api/pg/driver.d.cts +8 -9
- package/aws-data-api/pg/driver.d.ts +8 -9
- package/aws-data-api/pg/driver.js +8 -9
- package/aws-data-api/pg/driver.js.map +1 -1
- package/aws-data-api/pg/migrator.cjs.map +1 -1
- package/aws-data-api/pg/migrator.d.cts +1 -2
- package/aws-data-api/pg/migrator.d.ts +1 -2
- package/aws-data-api/pg/migrator.js.map +1 -1
- package/aws-data-api/pg/session.cjs +4 -67
- package/aws-data-api/pg/session.cjs.map +1 -1
- package/aws-data-api/pg/session.d.cts +8 -13
- package/aws-data-api/pg/session.d.ts +8 -13
- package/aws-data-api/pg/session.js +4 -67
- package/aws-data-api/pg/session.js.map +1 -1
- package/better-sqlite3/driver.cjs +5 -12
- package/better-sqlite3/driver.cjs.map +1 -1
- package/better-sqlite3/driver.d.cts +6 -7
- package/better-sqlite3/driver.d.ts +6 -7
- package/better-sqlite3/driver.js +8 -12
- package/better-sqlite3/driver.js.map +1 -1
- package/better-sqlite3/migrator.cjs.map +1 -1
- package/better-sqlite3/migrator.d.cts +1 -2
- package/better-sqlite3/migrator.d.ts +1 -2
- package/better-sqlite3/migrator.js.map +1 -1
- package/better-sqlite3/session.cjs +4 -49
- package/better-sqlite3/session.cjs.map +1 -1
- package/better-sqlite3/session.d.cts +8 -14
- package/better-sqlite3/session.d.ts +8 -14
- package/better-sqlite3/session.js +4 -49
- package/better-sqlite3/session.js.map +1 -1
- package/bun-sqlite/driver.cjs +5 -22
- package/bun-sqlite/driver.cjs.map +1 -1
- package/bun-sqlite/driver.d.cts +6 -7
- package/bun-sqlite/driver.d.ts +6 -7
- package/bun-sqlite/driver.js +8 -12
- package/bun-sqlite/driver.js.map +1 -1
- package/bun-sqlite/migrator.cjs.map +1 -1
- package/bun-sqlite/migrator.d.cts +1 -2
- package/bun-sqlite/migrator.d.ts +1 -2
- package/bun-sqlite/migrator.js.map +1 -1
- package/bun-sqlite/session.cjs +4 -49
- package/bun-sqlite/session.cjs.map +1 -1
- package/bun-sqlite/session.d.cts +8 -14
- package/bun-sqlite/session.d.ts +8 -14
- package/bun-sqlite/session.js +4 -49
- package/bun-sqlite/session.js.map +1 -1
- package/d1/driver.cjs +5 -22
- package/d1/driver.cjs.map +1 -1
- package/d1/driver.d.cts +2 -3
- package/d1/driver.d.ts +2 -3
- package/d1/driver.js +8 -12
- package/d1/driver.js.map +1 -1
- package/d1/migrator.cjs.map +1 -1
- package/d1/migrator.d.cts +1 -2
- package/d1/migrator.d.ts +1 -2
- package/d1/migrator.js.map +1 -1
- package/d1/session.cjs +6 -48
- package/d1/session.cjs.map +1 -1
- package/d1/session.d.cts +8 -15
- package/d1/session.d.ts +8 -15
- package/d1/session.js +6 -48
- package/d1/session.js.map +1 -1
- package/durable-sqlite/driver.cjs +5 -16
- package/durable-sqlite/driver.cjs.map +1 -1
- package/durable-sqlite/driver.d.cts +2 -3
- package/durable-sqlite/driver.d.ts +2 -3
- package/durable-sqlite/driver.js +8 -6
- package/durable-sqlite/driver.js.map +1 -1
- package/durable-sqlite/migrator.cjs.map +1 -1
- package/durable-sqlite/migrator.d.cts +1 -2
- package/durable-sqlite/migrator.d.ts +1 -2
- package/durable-sqlite/migrator.js.map +1 -1
- package/durable-sqlite/session.cjs +4 -46
- package/durable-sqlite/session.cjs.map +1 -1
- package/durable-sqlite/session.d.cts +8 -14
- package/durable-sqlite/session.d.ts +8 -14
- package/durable-sqlite/session.js +4 -46
- package/durable-sqlite/session.js.map +1 -1
- package/expo-sqlite/driver.cjs +5 -22
- package/expo-sqlite/driver.cjs.map +1 -1
- package/expo-sqlite/driver.d.cts +2 -3
- package/expo-sqlite/driver.d.ts +2 -3
- package/expo-sqlite/driver.js +8 -12
- package/expo-sqlite/driver.js.map +1 -1
- package/expo-sqlite/migrator.cjs.map +1 -1
- package/expo-sqlite/migrator.d.cts +2 -3
- package/expo-sqlite/migrator.d.ts +2 -3
- package/expo-sqlite/migrator.js.map +1 -1
- package/expo-sqlite/query.cjs +2 -13
- package/expo-sqlite/query.cjs.map +1 -1
- package/expo-sqlite/query.d.cts +1 -2
- package/expo-sqlite/query.d.ts +1 -2
- package/expo-sqlite/query.js +2 -3
- package/expo-sqlite/query.js.map +1 -1
- package/expo-sqlite/session.cjs +4 -47
- package/expo-sqlite/session.cjs.map +1 -1
- package/expo-sqlite/session.d.cts +8 -14
- package/expo-sqlite/session.d.ts +8 -14
- package/expo-sqlite/session.js +4 -47
- package/expo-sqlite/session.js.map +1 -1
- package/libsql/driver-core.cjs +5 -22
- package/libsql/driver-core.cjs.map +1 -1
- package/libsql/driver-core.d.cts +1 -2
- package/libsql/driver-core.d.ts +1 -2
- package/libsql/driver-core.js +8 -12
- package/libsql/driver-core.js.map +1 -1
- package/libsql/driver.cjs.map +1 -1
- package/libsql/driver.d.cts +5 -6
- package/libsql/driver.d.ts +5 -6
- package/libsql/driver.js.map +1 -1
- package/libsql/http/index.cjs.map +1 -1
- package/libsql/http/index.d.cts +5 -6
- package/libsql/http/index.d.ts +5 -6
- package/libsql/http/index.js.map +1 -1
- package/libsql/migrator.cjs.map +1 -1
- package/libsql/migrator.d.cts +1 -2
- package/libsql/migrator.d.ts +1 -2
- package/libsql/migrator.js.map +1 -1
- package/libsql/node/index.cjs.map +1 -1
- package/libsql/node/index.d.cts +5 -6
- package/libsql/node/index.d.ts +5 -6
- package/libsql/node/index.js.map +1 -1
- package/libsql/session.cjs +4 -60
- package/libsql/session.cjs.map +1 -1
- package/libsql/session.d.cts +9 -15
- package/libsql/session.d.ts +9 -15
- package/libsql/session.js +4 -60
- package/libsql/session.js.map +1 -1
- package/libsql/sqlite3/index.cjs.map +1 -1
- package/libsql/sqlite3/index.d.cts +5 -6
- package/libsql/sqlite3/index.d.ts +5 -6
- package/libsql/sqlite3/index.js.map +1 -1
- package/libsql/wasm/index.cjs.map +1 -1
- package/libsql/wasm/index.d.cts +5 -6
- package/libsql/wasm/index.d.ts +5 -6
- package/libsql/wasm/index.js.map +1 -1
- package/libsql/web/index.cjs.map +1 -1
- package/libsql/web/index.d.cts +5 -6
- package/libsql/web/index.d.ts +5 -6
- package/libsql/web/index.js.map +1 -1
- package/libsql/ws/index.cjs.map +1 -1
- package/libsql/ws/index.d.cts +5 -6
- package/libsql/ws/index.d.ts +5 -6
- package/libsql/ws/index.js.map +1 -1
- package/mysql-core/db.cjs +8 -29
- package/mysql-core/db.cjs.map +1 -1
- package/mysql-core/db.d.cts +8 -15
- package/mysql-core/db.d.ts +8 -15
- package/mysql-core/db.js +7 -28
- package/mysql-core/db.js.map +1 -1
- package/mysql-core/dialect.cjs +15 -176
- package/mysql-core/dialect.cjs.map +1 -1
- package/mysql-core/dialect.d.cts +13 -31
- package/mysql-core/dialect.d.ts +13 -31
- package/mysql-core/dialect.js +21 -173
- package/mysql-core/dialect.js.map +1 -1
- package/mysql-core/query-builders/count.cjs.map +1 -1
- package/mysql-core/query-builders/count.d.cts +1 -1
- package/mysql-core/query-builders/count.d.ts +1 -1
- package/mysql-core/query-builders/count.js.map +1 -1
- package/mysql-core/query-builders/query.cjs +31 -18
- package/mysql-core/query-builders/query.cjs.map +1 -1
- package/mysql-core/query-builders/query.d.cts +10 -8
- package/mysql-core/query-builders/query.d.ts +10 -8
- package/mysql-core/query-builders/query.js +31 -18
- package/mysql-core/query-builders/query.js.map +1 -1
- package/mysql-core/session.cjs +2 -3
- package/mysql-core/session.cjs.map +1 -1
- package/mysql-core/session.d.cts +7 -10
- package/mysql-core/session.d.ts +7 -10
- package/mysql-core/session.js +2 -3
- package/mysql-core/session.js.map +1 -1
- package/mysql-proxy/driver.cjs +5 -22
- package/mysql-proxy/driver.cjs.map +1 -1
- package/mysql-proxy/driver.d.cts +2 -3
- package/mysql-proxy/driver.d.ts +2 -3
- package/mysql-proxy/driver.js +8 -12
- package/mysql-proxy/driver.js.map +1 -1
- package/mysql-proxy/migrator.cjs.map +1 -1
- package/mysql-proxy/migrator.d.cts +1 -2
- package/mysql-proxy/migrator.d.ts +1 -2
- package/mysql-proxy/migrator.js.map +1 -1
- package/mysql-proxy/session.cjs +2 -47
- package/mysql-proxy/session.cjs.map +1 -1
- package/mysql-proxy/session.d.cts +8 -13
- package/mysql-proxy/session.d.ts +8 -13
- package/mysql-proxy/session.js +2 -47
- package/mysql-proxy/session.js.map +1 -1
- package/mysql2/driver.cjs +7 -24
- package/mysql2/driver.cjs.map +1 -1
- package/mysql2/driver.d.cts +9 -10
- package/mysql2/driver.d.ts +9 -10
- package/mysql2/driver.js +10 -14
- package/mysql2/driver.js.map +1 -1
- package/mysql2/migrator.cjs.map +1 -1
- package/mysql2/migrator.d.cts +1 -2
- package/mysql2/migrator.d.ts +1 -2
- package/mysql2/migrator.js.map +1 -1
- package/mysql2/session.cjs +2 -51
- package/mysql2/session.cjs.map +1 -1
- package/mysql2/session.d.cts +8 -13
- package/mysql2/session.d.ts +8 -13
- package/mysql2/session.js +2 -51
- package/mysql2/session.js.map +1 -1
- package/neon-http/driver.cjs +7 -21
- package/neon-http/driver.cjs.map +1 -1
- package/neon-http/driver.d.cts +9 -10
- package/neon-http/driver.d.ts +9 -10
- package/neon-http/driver.js +7 -11
- package/neon-http/driver.js.map +1 -1
- package/neon-http/migrator.cjs.map +1 -1
- package/neon-http/migrator.d.cts +1 -2
- package/neon-http/migrator.d.ts +1 -2
- package/neon-http/migrator.js.map +1 -1
- package/neon-http/session.cjs +2 -32
- package/neon-http/session.cjs.map +1 -1
- package/neon-http/session.d.cts +8 -13
- package/neon-http/session.d.ts +8 -13
- package/neon-http/session.js +2 -32
- package/neon-http/session.js.map +1 -1
- package/neon-serverless/driver.cjs +7 -18
- package/neon-serverless/driver.cjs.map +1 -1
- package/neon-serverless/driver.d.cts +8 -9
- package/neon-serverless/driver.d.ts +8 -9
- package/neon-serverless/driver.js +10 -8
- package/neon-serverless/driver.js.map +1 -1
- package/neon-serverless/migrator.cjs.map +1 -1
- package/neon-serverless/migrator.d.cts +1 -2
- package/neon-serverless/migrator.d.ts +1 -2
- package/neon-serverless/migrator.js.map +1 -1
- package/neon-serverless/session.cjs +5 -40
- package/neon-serverless/session.cjs.map +1 -1
- package/neon-serverless/session.d.cts +8 -13
- package/neon-serverless/session.d.ts +8 -13
- package/neon-serverless/session.js +5 -40
- package/neon-serverless/session.js.map +1 -1
- package/node-postgres/driver.cjs +7 -13
- package/node-postgres/driver.cjs.map +1 -1
- package/node-postgres/driver.d.cts +8 -9
- package/node-postgres/driver.d.ts +8 -9
- package/node-postgres/driver.js +10 -13
- package/node-postgres/driver.js.map +1 -1
- package/node-postgres/migrator.cjs.map +1 -1
- package/node-postgres/migrator.d.cts +1 -2
- package/node-postgres/migrator.d.ts +1 -2
- package/node-postgres/migrator.js.map +1 -1
- package/node-postgres/session.cjs +4 -45
- package/node-postgres/session.cjs.map +1 -1
- package/node-postgres/session.d.cts +8 -13
- package/node-postgres/session.d.ts +8 -13
- package/node-postgres/session.js +4 -45
- package/node-postgres/session.js.map +1 -1
- package/op-sqlite/driver.cjs +5 -22
- package/op-sqlite/driver.cjs.map +1 -1
- package/op-sqlite/driver.d.cts +2 -3
- package/op-sqlite/driver.d.ts +2 -3
- package/op-sqlite/driver.js +8 -12
- package/op-sqlite/driver.js.map +1 -1
- package/op-sqlite/migrator.cjs.map +1 -1
- package/op-sqlite/migrator.d.cts +2 -3
- package/op-sqlite/migrator.d.ts +2 -3
- package/op-sqlite/migrator.js.map +1 -1
- package/op-sqlite/session.cjs +4 -47
- package/op-sqlite/session.cjs.map +1 -1
- package/op-sqlite/session.d.cts +8 -14
- package/op-sqlite/session.d.ts +8 -14
- package/op-sqlite/session.js +4 -47
- package/op-sqlite/session.js.map +1 -1
- package/package.json +63 -99
- package/pg-core/db.cjs +7 -31
- package/pg-core/db.cjs.map +1 -1
- package/pg-core/db.d.cts +9 -16
- package/pg-core/db.d.ts +9 -16
- package/pg-core/db.js +6 -30
- package/pg-core/db.js.map +1 -1
- package/pg-core/dialect.cjs +488 -152
- package/pg-core/dialect.cjs.map +1 -1
- package/pg-core/dialect.d.cts +7 -23
- package/pg-core/dialect.d.ts +7 -23
- package/pg-core/dialect.js +494 -149
- package/pg-core/dialect.js.map +1 -1
- package/pg-core/query-builders/count.cjs.map +1 -1
- package/pg-core/query-builders/count.d.cts +1 -1
- package/pg-core/query-builders/count.d.ts +1 -1
- package/pg-core/query-builders/count.js.map +1 -1
- package/pg-core/query-builders/query.cjs +18 -15
- package/pg-core/query-builders/query.cjs.map +1 -1
- package/pg-core/query-builders/query.d.cts +6 -6
- package/pg-core/query-builders/query.d.ts +6 -6
- package/pg-core/query-builders/query.js +18 -15
- package/pg-core/query-builders/query.js.map +1 -1
- package/pg-core/session.cjs +2 -3
- package/pg-core/session.cjs.map +1 -1
- package/pg-core/session.d.cts +6 -9
- package/pg-core/session.d.ts +6 -9
- package/pg-core/session.js +2 -3
- package/pg-core/session.js.map +1 -1
- package/pg-proxy/driver.cjs +5 -21
- package/pg-proxy/driver.cjs.map +1 -1
- package/pg-proxy/driver.d.cts +2 -3
- package/pg-proxy/driver.d.ts +2 -3
- package/pg-proxy/driver.js +8 -11
- package/pg-proxy/driver.js.map +1 -1
- package/pg-proxy/migrator.cjs.map +1 -1
- package/pg-proxy/migrator.d.cts +1 -2
- package/pg-proxy/migrator.d.ts +1 -2
- package/pg-proxy/migrator.js.map +1 -1
- package/pg-proxy/session.cjs +2 -37
- package/pg-proxy/session.cjs.map +1 -1
- package/pg-proxy/session.d.cts +8 -13
- package/pg-proxy/session.d.ts +8 -13
- package/pg-proxy/session.js +2 -37
- package/pg-proxy/session.js.map +1 -1
- package/pglite/driver.cjs +7 -23
- package/pglite/driver.cjs.map +1 -1
- package/pglite/driver.d.cts +8 -9
- package/pglite/driver.d.ts +8 -9
- package/pglite/driver.js +10 -13
- package/pglite/driver.js.map +1 -1
- package/pglite/migrator.cjs.map +1 -1
- package/pglite/migrator.d.cts +1 -2
- package/pglite/migrator.d.ts +1 -2
- package/pglite/migrator.js.map +1 -1
- package/pglite/session.cjs +3 -34
- package/pglite/session.cjs.map +1 -1
- package/pglite/session.d.cts +8 -13
- package/pglite/session.d.ts +8 -13
- package/pglite/session.js +3 -34
- package/pglite/session.js.map +1 -1
- package/planetscale-serverless/driver.cjs +5 -22
- package/planetscale-serverless/driver.cjs.map +1 -1
- package/planetscale-serverless/driver.d.cts +6 -7
- package/planetscale-serverless/driver.d.ts +6 -7
- package/planetscale-serverless/driver.js +8 -12
- package/planetscale-serverless/driver.js.map +1 -1
- package/planetscale-serverless/migrator.cjs.map +1 -1
- package/planetscale-serverless/migrator.d.cts +1 -2
- package/planetscale-serverless/migrator.d.ts +1 -2
- package/planetscale-serverless/migrator.js.map +1 -1
- package/planetscale-serverless/session.cjs +5 -68
- package/planetscale-serverless/session.cjs.map +1 -1
- package/planetscale-serverless/session.d.cts +9 -14
- package/planetscale-serverless/session.d.ts +9 -14
- package/planetscale-serverless/session.js +5 -68
- package/planetscale-serverless/session.js.map +1 -1
- package/postgres-js/driver.cjs +5 -6
- package/postgres-js/driver.cjs.map +1 -1
- package/postgres-js/driver.d.cts +6 -7
- package/postgres-js/driver.d.ts +6 -7
- package/postgres-js/driver.js +8 -6
- package/postgres-js/driver.js.map +1 -1
- package/postgres-js/migrator.cjs.map +1 -1
- package/postgres-js/migrator.d.cts +1 -2
- package/postgres-js/migrator.d.ts +1 -2
- package/postgres-js/migrator.js.map +1 -1
- package/postgres-js/session.cjs +6 -51
- package/postgres-js/session.cjs.map +1 -1
- package/postgres-js/session.d.cts +9 -15
- package/postgres-js/session.d.ts +9 -15
- package/postgres-js/session.js +6 -51
- package/postgres-js/session.js.map +1 -1
- package/prisma/mysql/driver.cjs +1 -1
- package/prisma/mysql/driver.cjs.map +1 -1
- package/prisma/mysql/driver.js +1 -1
- package/prisma/mysql/driver.js.map +1 -1
- package/prisma/mysql/session.cjs +0 -3
- package/prisma/mysql/session.cjs.map +1 -1
- package/prisma/mysql/session.d.cts +1 -3
- package/prisma/mysql/session.d.ts +1 -3
- package/prisma/mysql/session.js +0 -3
- package/prisma/mysql/session.js.map +1 -1
- package/prisma/pg/driver.cjs +1 -1
- package/prisma/pg/driver.cjs.map +1 -1
- package/prisma/pg/driver.js +1 -1
- package/prisma/pg/driver.js.map +1 -1
- package/prisma/pg/session.cjs +0 -3
- package/prisma/pg/session.cjs.map +1 -1
- package/prisma/pg/session.d.cts +1 -3
- package/prisma/pg/session.d.ts +1 -3
- package/prisma/pg/session.js +0 -3
- package/prisma/pg/session.js.map +1 -1
- package/prisma/sqlite/driver.cjs +1 -1
- package/prisma/sqlite/driver.cjs.map +1 -1
- package/prisma/sqlite/driver.js +1 -1
- package/prisma/sqlite/driver.js.map +1 -1
- package/prisma/sqlite/session.cjs +0 -3
- package/prisma/sqlite/session.cjs.map +1 -1
- package/prisma/sqlite/session.d.cts +2 -4
- package/prisma/sqlite/session.d.ts +2 -4
- package/prisma/sqlite/session.js +0 -3
- package/prisma/sqlite/session.js.map +1 -1
- package/relations.cjs +246 -477
- package/relations.cjs.map +1 -1
- package/relations.d.cts +131 -263
- package/relations.d.ts +131 -263
- package/relations.js +241 -466
- package/relations.js.map +1 -1
- package/singlestore/driver.cjs +1 -1
- package/singlestore/driver.cjs.map +1 -1
- package/singlestore/driver.d.cts +1 -1
- package/singlestore/driver.d.ts +1 -1
- package/singlestore/driver.js +3 -3
- package/singlestore/driver.js.map +1 -1
- package/singlestore/session.cjs.map +1 -1
- package/singlestore/session.d.cts +4 -4
- package/singlestore/session.d.ts +4 -4
- package/singlestore/session.js.map +1 -1
- package/singlestore-core/columns/all.cjs +2 -0
- package/singlestore-core/columns/all.cjs.map +1 -1
- package/singlestore-core/columns/all.d.cts +2 -0
- package/singlestore-core/columns/all.d.ts +2 -0
- package/singlestore-core/columns/all.js +2 -0
- package/singlestore-core/columns/all.js.map +1 -1
- package/singlestore-core/columns/index.cjs +2 -0
- package/singlestore-core/columns/index.cjs.map +1 -1
- package/singlestore-core/columns/index.d.cts +1 -0
- package/singlestore-core/columns/index.d.ts +1 -0
- package/singlestore-core/columns/index.js +1 -0
- package/singlestore-core/columns/index.js.map +1 -1
- package/singlestore-core/columns/vector.cjs +72 -0
- package/singlestore-core/columns/vector.cjs.map +1 -0
- package/singlestore-core/columns/vector.d.cts +32 -0
- package/singlestore-core/columns/vector.d.ts +32 -0
- package/singlestore-core/columns/vector.js +46 -0
- package/singlestore-core/columns/vector.js.map +1 -0
- package/singlestore-core/db.cjs.map +1 -1
- package/singlestore-core/db.d.cts +3 -3
- package/singlestore-core/db.d.ts +3 -3
- package/singlestore-core/db.js.map +1 -1
- package/singlestore-core/dialect.cjs +6 -16
- package/singlestore-core/dialect.cjs.map +1 -1
- package/singlestore-core/dialect.d.cts +6 -6
- package/singlestore-core/dialect.d.ts +6 -6
- package/singlestore-core/dialect.js +12 -6
- package/singlestore-core/dialect.js.map +1 -1
- package/singlestore-core/expressions.cjs +10 -0
- package/singlestore-core/expressions.cjs.map +1 -1
- package/singlestore-core/expressions.d.cts +2 -0
- package/singlestore-core/expressions.d.ts +2 -0
- package/singlestore-core/expressions.js +8 -0
- package/singlestore-core/expressions.js.map +1 -1
- package/singlestore-core/query-builders/query.cjs +2 -12
- package/singlestore-core/query-builders/query.cjs.map +1 -1
- package/singlestore-core/query-builders/query.d.cts +6 -6
- package/singlestore-core/query-builders/query.d.ts +6 -6
- package/singlestore-core/query-builders/query.js +4 -2
- package/singlestore-core/query-builders/query.js.map +1 -1
- package/singlestore-core/session.cjs.map +1 -1
- package/singlestore-core/session.d.cts +5 -5
- package/singlestore-core/session.d.ts +5 -5
- package/singlestore-core/session.js.map +1 -1
- package/singlestore-proxy/driver.cjs +1 -1
- package/singlestore-proxy/driver.cjs.map +1 -1
- package/singlestore-proxy/driver.js +3 -3
- package/singlestore-proxy/driver.js.map +1 -1
- package/singlestore-proxy/session.cjs.map +1 -1
- package/singlestore-proxy/session.d.cts +4 -4
- package/singlestore-proxy/session.d.ts +4 -4
- package/singlestore-proxy/session.js.map +1 -1
- package/sql/sql.cjs.map +1 -1
- package/sql/sql.d.cts +8 -8
- package/sql/sql.d.ts +8 -8
- package/sql/sql.js.map +1 -1
- package/sql-js/driver.cjs +5 -16
- package/sql-js/driver.cjs.map +1 -1
- package/sql-js/driver.d.cts +2 -3
- package/sql-js/driver.d.ts +2 -3
- package/sql-js/driver.js +8 -6
- package/sql-js/driver.js.map +1 -1
- package/sql-js/migrator.cjs.map +1 -1
- package/sql-js/migrator.d.cts +1 -2
- package/sql-js/migrator.d.ts +1 -2
- package/sql-js/migrator.js.map +1 -1
- package/sql-js/session.cjs +4 -58
- package/sql-js/session.cjs.map +1 -1
- package/sql-js/session.d.cts +8 -14
- package/sql-js/session.d.ts +8 -14
- package/sql-js/session.js +4 -58
- package/sql-js/session.js.map +1 -1
- package/sqlite-core/db.cjs +14 -36
- package/sqlite-core/db.cjs.map +1 -1
- package/sqlite-core/db.d.cts +8 -15
- package/sqlite-core/db.d.ts +8 -15
- package/sqlite-core/db.js +13 -35
- package/sqlite-core/db.js.map +1 -1
- package/sqlite-core/dialect.cjs +7 -171
- package/sqlite-core/dialect.cjs.map +1 -1
- package/sqlite-core/dialect.d.cts +9 -27
- package/sqlite-core/dialect.d.ts +9 -27
- package/sqlite-core/dialect.js +13 -168
- package/sqlite-core/dialect.js.map +1 -1
- package/sqlite-core/query-builders/count.cjs.map +1 -1
- package/sqlite-core/query-builders/count.d.cts +1 -1
- package/sqlite-core/query-builders/count.d.ts +1 -1
- package/sqlite-core/query-builders/count.js.map +1 -1
- package/sqlite-core/query-builders/delete.cjs.map +1 -1
- package/sqlite-core/query-builders/delete.d.cts +1 -1
- package/sqlite-core/query-builders/delete.d.ts +1 -1
- package/sqlite-core/query-builders/delete.js.map +1 -1
- package/sqlite-core/query-builders/insert.cjs.map +1 -1
- package/sqlite-core/query-builders/insert.d.cts +3 -3
- package/sqlite-core/query-builders/insert.d.ts +3 -3
- package/sqlite-core/query-builders/insert.js.map +1 -1
- package/sqlite-core/query-builders/query.cjs +29 -32
- package/sqlite-core/query-builders/query.cjs.map +1 -1
- package/sqlite-core/query-builders/query.d.cts +16 -15
- package/sqlite-core/query-builders/query.d.ts +16 -15
- package/sqlite-core/query-builders/query.js +29 -32
- package/sqlite-core/query-builders/query.js.map +1 -1
- package/sqlite-core/query-builders/select.cjs.map +1 -1
- package/sqlite-core/query-builders/select.d.cts +3 -3
- package/sqlite-core/query-builders/select.d.ts +3 -3
- package/sqlite-core/query-builders/select.js.map +1 -1
- package/sqlite-core/query-builders/update.cjs.map +1 -1
- package/sqlite-core/query-builders/update.d.cts +3 -3
- package/sqlite-core/query-builders/update.d.ts +3 -3
- package/sqlite-core/query-builders/update.js.map +1 -1
- package/sqlite-core/session.cjs +2 -6
- package/sqlite-core/session.cjs.map +1 -1
- package/sqlite-core/session.d.cts +6 -14
- package/sqlite-core/session.d.ts +6 -14
- package/sqlite-core/session.js +2 -6
- package/sqlite-core/session.js.map +1 -1
- package/sqlite-proxy/driver.cjs +5 -22
- package/sqlite-proxy/driver.cjs.map +1 -1
- package/sqlite-proxy/driver.d.cts +3 -4
- package/sqlite-proxy/driver.d.ts +3 -4
- package/sqlite-proxy/driver.js +5 -12
- package/sqlite-proxy/driver.js.map +1 -1
- package/sqlite-proxy/migrator.cjs.map +1 -1
- package/sqlite-proxy/migrator.d.cts +1 -2
- package/sqlite-proxy/migrator.d.ts +1 -2
- package/sqlite-proxy/migrator.js.map +1 -1
- package/sqlite-proxy/session.cjs +4 -47
- package/sqlite-proxy/session.cjs.map +1 -1
- package/sqlite-proxy/session.d.cts +8 -14
- package/sqlite-proxy/session.d.ts +8 -14
- package/sqlite-proxy/session.js +4 -47
- package/sqlite-proxy/session.js.map +1 -1
- package/table.cjs.map +1 -1
- package/table.d.cts +1 -1
- package/table.d.ts +1 -1
- package/table.js.map +1 -1
- package/tidb-serverless/driver.cjs +5 -22
- package/tidb-serverless/driver.cjs.map +1 -1
- package/tidb-serverless/driver.d.cts +6 -7
- package/tidb-serverless/driver.d.ts +6 -7
- package/tidb-serverless/driver.js +8 -12
- package/tidb-serverless/driver.js.map +1 -1
- package/tidb-serverless/migrator.cjs.map +1 -1
- package/tidb-serverless/migrator.d.cts +1 -2
- package/tidb-serverless/migrator.d.ts +1 -2
- package/tidb-serverless/migrator.js.map +1 -1
- package/tidb-serverless/session.cjs +5 -62
- package/tidb-serverless/session.cjs.map +1 -1
- package/tidb-serverless/session.d.cts +9 -14
- package/tidb-serverless/session.d.ts +9 -14
- package/tidb-serverless/session.js +5 -62
- package/tidb-serverless/session.js.map +1 -1
- package/utils.cjs +2 -2
- package/utils.cjs.map +1 -1
- package/utils.d.cts +1 -3
- package/utils.d.ts +1 -3
- package/utils.js +2 -2
- package/utils.js.map +1 -1
- package/vercel-postgres/driver.cjs +7 -23
- package/vercel-postgres/driver.cjs.map +1 -1
- package/vercel-postgres/driver.d.cts +8 -9
- package/vercel-postgres/driver.d.ts +8 -9
- package/vercel-postgres/driver.js +10 -13
- package/vercel-postgres/driver.js.map +1 -1
- package/vercel-postgres/migrator.cjs.map +1 -1
- package/vercel-postgres/migrator.d.cts +1 -2
- package/vercel-postgres/migrator.d.ts +1 -2
- package/vercel-postgres/migrator.js.map +1 -1
- package/vercel-postgres/session.cjs +4 -34
- package/vercel-postgres/session.cjs.map +1 -1
- package/vercel-postgres/session.d.cts +8 -13
- package/vercel-postgres/session.d.ts +8 -13
- package/vercel-postgres/session.js +4 -34
- package/vercel-postgres/session.js.map +1 -1
- package/version.cjs +1 -1
- package/version.d.cts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/xata-http/driver.cjs +5 -17
- package/xata-http/driver.cjs.map +1 -1
- package/xata-http/driver.d.cts +4 -5
- package/xata-http/driver.d.ts +4 -5
- package/xata-http/driver.js +5 -7
- package/xata-http/driver.js.map +1 -1
- package/xata-http/migrator.cjs.map +1 -1
- package/xata-http/migrator.d.cts +1 -2
- package/xata-http/migrator.d.ts +1 -2
- package/xata-http/migrator.js.map +1 -1
- package/xata-http/session.cjs +2 -30
- package/xata-http/session.cjs.map +1 -1
- package/xata-http/session.d.cts +8 -13
- package/xata-http/session.d.ts +8 -13
- package/xata-http/session.js +2 -30
- package/xata-http/session.js.map +1 -1
- package/_relations.cjs +0 -328
- package/_relations.cjs.map +0 -1
- package/_relations.d.cts +0 -215
- package/_relations.d.ts +0 -215
- package/_relations.js +0 -316
- package/_relations.js.map +0 -1
- package/mysql-core/query-builders/_query.cjs +0 -149
- package/mysql-core/query-builders/_query.cjs.map +0 -1
- package/mysql-core/query-builders/_query.d.cts +0 -44
- package/mysql-core/query-builders/_query.d.ts +0 -44
- package/mysql-core/query-builders/_query.js +0 -114
- package/mysql-core/query-builders/_query.js.map +0 -1
- package/pg-core/query-builders/_query.cjs +0 -155
- package/pg-core/query-builders/_query.cjs.map +0 -1
- package/pg-core/query-builders/_query.d.cts +0 -47
- package/pg-core/query-builders/_query.d.ts +0 -47
- package/pg-core/query-builders/_query.js +0 -120
- package/pg-core/query-builders/_query.js.map +0 -1
- package/sqlite-core/query-builders/_query.cjs +0 -187
- package/sqlite-core/query-builders/_query.cjs.map +0 -1
- package/sqlite-core/query-builders/_query.d.cts +0 -55
- package/sqlite-core/query-builders/_query.d.ts +0 -55
- package/sqlite-core/query-builders/_query.js +0 -151
- package/sqlite-core/query-builders/_query.js.map +0 -1
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { type Client, Pool, type PoolClient, type QueryResult, type QueryResultRow } from '@neondatabase/serverless';
|
|
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 } from "../pg-core/dialect.cjs";
|
|
@@ -7,48 +6,44 @@ import { PgTransaction } from "../pg-core/index.cjs";
|
|
|
7
6
|
import type { SelectedFieldsOrdered } from "../pg-core/query-builders/select.types.cjs";
|
|
8
7
|
import type { PgQueryResultHKT, PgTransactionConfig, PreparedQueryConfig } from "../pg-core/session.cjs";
|
|
9
8
|
import { PgPreparedQuery, PgSession } from "../pg-core/session.cjs";
|
|
10
|
-
import type {
|
|
9
|
+
import type { RelationalSchemaConfig, TablesRelationalConfig } from "../relations.cjs";
|
|
11
10
|
import { type Query, type SQL } from "../sql/sql.cjs";
|
|
12
11
|
import { type Assume } from "../utils.cjs";
|
|
13
12
|
export type NeonClient = Pool | PoolClient | Client;
|
|
14
|
-
export declare class NeonPreparedQuery<T extends PreparedQueryConfig
|
|
13
|
+
export declare class NeonPreparedQuery<T extends PreparedQueryConfig> extends PgPreparedQuery<T> {
|
|
15
14
|
private client;
|
|
16
15
|
private params;
|
|
17
16
|
private logger;
|
|
18
17
|
private fields;
|
|
19
18
|
private _isResponseInArrayMode;
|
|
20
19
|
private customResultMapper?;
|
|
21
|
-
private isRqbV2Query?;
|
|
22
20
|
static readonly [entityKind]: string;
|
|
23
21
|
private rawQueryConfig;
|
|
24
22
|
private queryConfig;
|
|
25
|
-
constructor(client: NeonClient, queryString: string, params: unknown[], logger: Logger, fields: SelectedFieldsOrdered | undefined, name: string | undefined, _isResponseInArrayMode: boolean, customResultMapper?: ((rows:
|
|
23
|
+
constructor(client: NeonClient, queryString: string, params: unknown[], logger: Logger, fields: SelectedFieldsOrdered | undefined, name: string | undefined, _isResponseInArrayMode: boolean, customResultMapper?: ((rows: unknown[][]) => T["execute"]) | undefined);
|
|
26
24
|
execute(placeholderValues?: Record<string, unknown> | undefined): Promise<T['execute']>;
|
|
27
|
-
private executeRqbV2;
|
|
28
25
|
all(placeholderValues?: Record<string, unknown> | undefined): Promise<T['all']>;
|
|
29
26
|
values(placeholderValues?: Record<string, unknown> | undefined): Promise<T['values']>;
|
|
30
27
|
}
|
|
31
28
|
export interface NeonSessionOptions {
|
|
32
29
|
logger?: Logger;
|
|
33
30
|
}
|
|
34
|
-
export declare class NeonSession<TFullSchema extends Record<string, unknown>,
|
|
31
|
+
export declare class NeonSession<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends PgSession<NeonQueryResultHKT, TFullSchema, TSchema> {
|
|
35
32
|
private client;
|
|
36
|
-
private relations;
|
|
37
33
|
private schema;
|
|
38
34
|
private options;
|
|
39
35
|
static readonly [entityKind]: string;
|
|
40
36
|
private logger;
|
|
41
|
-
constructor(client: NeonClient, dialect: PgDialect,
|
|
37
|
+
constructor(client: NeonClient, dialect: PgDialect, schema: RelationalSchemaConfig<TSchema> | undefined, options?: NeonSessionOptions);
|
|
42
38
|
prepareQuery<T extends PreparedQueryConfig = PreparedQueryConfig>(query: Query, fields: SelectedFieldsOrdered | undefined, name: string | undefined, isResponseInArrayMode: boolean, customResultMapper?: (rows: unknown[][]) => T['execute']): PgPreparedQuery<T>;
|
|
43
|
-
prepareRelationalQuery<T extends PreparedQueryConfig = PreparedQueryConfig>(query: Query, fields: SelectedFieldsOrdered | undefined, name: string | undefined, customResultMapper?: (rows: Record<string, unknown>[]) => T['execute']): PgPreparedQuery<T>;
|
|
44
39
|
query(query: string, params: unknown[]): Promise<QueryResult>;
|
|
45
40
|
queryObjects<T extends QueryResultRow>(query: string, params: unknown[]): Promise<QueryResult<T>>;
|
|
46
41
|
count(sql: SQL): Promise<number>;
|
|
47
|
-
transaction<T>(transaction: (tx: NeonTransaction<TFullSchema,
|
|
42
|
+
transaction<T>(transaction: (tx: NeonTransaction<TFullSchema, TSchema>) => Promise<T>, config?: PgTransactionConfig): Promise<T>;
|
|
48
43
|
}
|
|
49
|
-
export declare class NeonTransaction<TFullSchema extends Record<string, unknown>,
|
|
44
|
+
export declare class NeonTransaction<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends PgTransaction<NeonQueryResultHKT, TFullSchema, TSchema> {
|
|
50
45
|
static readonly [entityKind]: string;
|
|
51
|
-
transaction<T>(transaction: (tx: NeonTransaction<TFullSchema,
|
|
46
|
+
transaction<T>(transaction: (tx: NeonTransaction<TFullSchema, TSchema>) => Promise<T>): Promise<T>;
|
|
52
47
|
}
|
|
53
48
|
export interface NeonQueryResultHKT extends PgQueryResultHKT {
|
|
54
49
|
type: QueryResult<Assume<this['row'], QueryResultRow>>;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { type Client, Pool, type PoolClient, type QueryResult, type QueryResultRow } from '@neondatabase/serverless';
|
|
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 } from "../pg-core/dialect.js";
|
|
@@ -7,48 +6,44 @@ import { PgTransaction } from "../pg-core/index.js";
|
|
|
7
6
|
import type { SelectedFieldsOrdered } from "../pg-core/query-builders/select.types.js";
|
|
8
7
|
import type { PgQueryResultHKT, PgTransactionConfig, PreparedQueryConfig } from "../pg-core/session.js";
|
|
9
8
|
import { PgPreparedQuery, PgSession } from "../pg-core/session.js";
|
|
10
|
-
import type {
|
|
9
|
+
import type { RelationalSchemaConfig, TablesRelationalConfig } from "../relations.js";
|
|
11
10
|
import { type Query, type SQL } from "../sql/sql.js";
|
|
12
11
|
import { type Assume } from "../utils.js";
|
|
13
12
|
export type NeonClient = Pool | PoolClient | Client;
|
|
14
|
-
export declare class NeonPreparedQuery<T extends PreparedQueryConfig
|
|
13
|
+
export declare class NeonPreparedQuery<T extends PreparedQueryConfig> extends PgPreparedQuery<T> {
|
|
15
14
|
private client;
|
|
16
15
|
private params;
|
|
17
16
|
private logger;
|
|
18
17
|
private fields;
|
|
19
18
|
private _isResponseInArrayMode;
|
|
20
19
|
private customResultMapper?;
|
|
21
|
-
private isRqbV2Query?;
|
|
22
20
|
static readonly [entityKind]: string;
|
|
23
21
|
private rawQueryConfig;
|
|
24
22
|
private queryConfig;
|
|
25
|
-
constructor(client: NeonClient, queryString: string, params: unknown[], logger: Logger, fields: SelectedFieldsOrdered | undefined, name: string | undefined, _isResponseInArrayMode: boolean, customResultMapper?: ((rows:
|
|
23
|
+
constructor(client: NeonClient, queryString: string, params: unknown[], logger: Logger, fields: SelectedFieldsOrdered | undefined, name: string | undefined, _isResponseInArrayMode: boolean, customResultMapper?: ((rows: unknown[][]) => T["execute"]) | undefined);
|
|
26
24
|
execute(placeholderValues?: Record<string, unknown> | undefined): Promise<T['execute']>;
|
|
27
|
-
private executeRqbV2;
|
|
28
25
|
all(placeholderValues?: Record<string, unknown> | undefined): Promise<T['all']>;
|
|
29
26
|
values(placeholderValues?: Record<string, unknown> | undefined): Promise<T['values']>;
|
|
30
27
|
}
|
|
31
28
|
export interface NeonSessionOptions {
|
|
32
29
|
logger?: Logger;
|
|
33
30
|
}
|
|
34
|
-
export declare class NeonSession<TFullSchema extends Record<string, unknown>,
|
|
31
|
+
export declare class NeonSession<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends PgSession<NeonQueryResultHKT, TFullSchema, TSchema> {
|
|
35
32
|
private client;
|
|
36
|
-
private relations;
|
|
37
33
|
private schema;
|
|
38
34
|
private options;
|
|
39
35
|
static readonly [entityKind]: string;
|
|
40
36
|
private logger;
|
|
41
|
-
constructor(client: NeonClient, dialect: PgDialect,
|
|
37
|
+
constructor(client: NeonClient, dialect: PgDialect, schema: RelationalSchemaConfig<TSchema> | undefined, options?: NeonSessionOptions);
|
|
42
38
|
prepareQuery<T extends PreparedQueryConfig = PreparedQueryConfig>(query: Query, fields: SelectedFieldsOrdered | undefined, name: string | undefined, isResponseInArrayMode: boolean, customResultMapper?: (rows: unknown[][]) => T['execute']): PgPreparedQuery<T>;
|
|
43
|
-
prepareRelationalQuery<T extends PreparedQueryConfig = PreparedQueryConfig>(query: Query, fields: SelectedFieldsOrdered | undefined, name: string | undefined, customResultMapper?: (rows: Record<string, unknown>[]) => T['execute']): PgPreparedQuery<T>;
|
|
44
39
|
query(query: string, params: unknown[]): Promise<QueryResult>;
|
|
45
40
|
queryObjects<T extends QueryResultRow>(query: string, params: unknown[]): Promise<QueryResult<T>>;
|
|
46
41
|
count(sql: SQL): Promise<number>;
|
|
47
|
-
transaction<T>(transaction: (tx: NeonTransaction<TFullSchema,
|
|
42
|
+
transaction<T>(transaction: (tx: NeonTransaction<TFullSchema, TSchema>) => Promise<T>, config?: PgTransactionConfig): Promise<T>;
|
|
48
43
|
}
|
|
49
|
-
export declare class NeonTransaction<TFullSchema extends Record<string, unknown>,
|
|
44
|
+
export declare class NeonTransaction<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends PgTransaction<NeonQueryResultHKT, TFullSchema, TSchema> {
|
|
50
45
|
static readonly [entityKind]: string;
|
|
51
|
-
transaction<T>(transaction: (tx: NeonTransaction<TFullSchema,
|
|
46
|
+
transaction<T>(transaction: (tx: NeonTransaction<TFullSchema, TSchema>) => Promise<T>): Promise<T>;
|
|
52
47
|
}
|
|
53
48
|
export interface NeonQueryResultHKT extends PgQueryResultHKT {
|
|
54
49
|
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 NeonPreparedQuery 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 NeonPreparedQuery extends PgPreparedQuery {
|
|
|
17
17
|
this.fields = fields;
|
|
18
18
|
this._isResponseInArrayMode = _isResponseInArrayMode;
|
|
19
19
|
this.customResultMapper = customResultMapper;
|
|
20
|
-
this.isRqbV2Query = isRqbV2Query;
|
|
21
20
|
this.rawQueryConfig = {
|
|
22
21
|
name,
|
|
23
22
|
text: queryString,
|
|
@@ -68,8 +67,6 @@ class NeonPreparedQuery extends PgPreparedQuery {
|
|
|
68
67
|
rawQueryConfig;
|
|
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.rawQueryConfig.text, params);
|
|
75
72
|
const { fields, client, rawQueryConfig: rawQuery, queryConfig: query, joinsNotNullableMap, customResultMapper } = this;
|
|
@@ -79,13 +76,6 @@ class NeonPreparedQuery extends PgPreparedQuery {
|
|
|
79
76
|
const result = await client.query(query, params);
|
|
80
77
|
return customResultMapper ? customResultMapper(result.rows) : result.rows.map((row) => mapResultRow(fields, row, joinsNotNullableMap));
|
|
81
78
|
}
|
|
82
|
-
async executeRqbV2(placeholderValues = {}) {
|
|
83
|
-
const params = fillPlaceholders(this.params, placeholderValues);
|
|
84
|
-
this.logger.logQuery(this.rawQueryConfig.text, params);
|
|
85
|
-
const { client, rawQueryConfig: rawQuery, customResultMapper } = this;
|
|
86
|
-
const result = await client.query(rawQuery, params);
|
|
87
|
-
return customResultMapper(result.rows);
|
|
88
|
-
}
|
|
89
79
|
all(placeholderValues = {}) {
|
|
90
80
|
const params = fillPlaceholders(this.params, placeholderValues);
|
|
91
81
|
this.logger.logQuery(this.rawQueryConfig.text, params);
|
|
@@ -102,10 +92,9 @@ class NeonPreparedQuery extends PgPreparedQuery {
|
|
|
102
92
|
}
|
|
103
93
|
}
|
|
104
94
|
class NeonSession extends PgSession {
|
|
105
|
-
constructor(client, dialect,
|
|
95
|
+
constructor(client, dialect, schema, options = {}) {
|
|
106
96
|
super(dialect);
|
|
107
97
|
this.client = client;
|
|
108
|
-
this.relations = relations;
|
|
109
98
|
this.schema = schema;
|
|
110
99
|
this.options = options;
|
|
111
100
|
this.logger = options.logger ?? new NoopLogger();
|
|
@@ -124,19 +113,6 @@ class NeonSession extends PgSession {
|
|
|
124
113
|
customResultMapper
|
|
125
114
|
);
|
|
126
115
|
}
|
|
127
|
-
prepareRelationalQuery(query, fields, name, customResultMapper) {
|
|
128
|
-
return new NeonPreparedQuery(
|
|
129
|
-
this.client,
|
|
130
|
-
query.sql,
|
|
131
|
-
query.params,
|
|
132
|
-
this.logger,
|
|
133
|
-
fields,
|
|
134
|
-
name,
|
|
135
|
-
false,
|
|
136
|
-
customResultMapper,
|
|
137
|
-
true
|
|
138
|
-
);
|
|
139
|
-
}
|
|
140
116
|
async query(query, params) {
|
|
141
117
|
this.logger.logQuery(query, params);
|
|
142
118
|
const result = await this.client.query({
|
|
@@ -156,13 +132,8 @@ class NeonSession extends PgSession {
|
|
|
156
132
|
);
|
|
157
133
|
}
|
|
158
134
|
async transaction(transaction, config = {}) {
|
|
159
|
-
const session = this.client instanceof Pool ? new NeonSession(await this.client.connect(), this.dialect, this.
|
|
160
|
-
const tx = new NeonTransaction(
|
|
161
|
-
this.dialect,
|
|
162
|
-
session,
|
|
163
|
-
this.relations,
|
|
164
|
-
this.schema
|
|
165
|
-
);
|
|
135
|
+
const session = this.client instanceof Pool ? new NeonSession(await this.client.connect(), this.dialect, this.schema, this.options) : this;
|
|
136
|
+
const tx = new NeonTransaction(this.dialect, session, this.schema);
|
|
166
137
|
await tx.execute(sql`begin ${tx.getTransactionConfigSQL(config)}`);
|
|
167
138
|
try {
|
|
168
139
|
const result = await transaction(tx);
|
|
@@ -182,13 +153,7 @@ class NeonTransaction extends PgTransaction {
|
|
|
182
153
|
static [entityKind] = "NeonTransaction";
|
|
183
154
|
async transaction(transaction) {
|
|
184
155
|
const savepointName = `sp${this.nestedIndex + 1}`;
|
|
185
|
-
const tx = new NeonTransaction(
|
|
186
|
-
this.dialect,
|
|
187
|
-
this.session,
|
|
188
|
-
this.relations,
|
|
189
|
-
this.schema,
|
|
190
|
-
this.nestedIndex + 1
|
|
191
|
-
);
|
|
156
|
+
const tx = new NeonTransaction(this.dialect, this.session, this.schema, this.nestedIndex + 1);
|
|
192
157
|
await tx.execute(sql.raw(`savepoint ${savepointName}`));
|
|
193
158
|
try {
|
|
194
159
|
const result = await transaction(tx);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/neon-serverless/session.ts"],"sourcesContent":["import {\n\ttype Client,\n\tPool,\n\ttype PoolClient,\n\ttype QueryArrayConfig,\n\ttype QueryConfig,\n\ttype QueryResult,\n\ttype QueryResultRow,\n\ttypes,\n} from '@neondatabase/serverless';\nimport type * as V1 from '~/_relations.ts';\nimport { entityKind } from '~/entity.ts';\nimport type { Logger } from '~/logger.ts';\nimport { NoopLogger } from '~/logger.ts';\nimport type { PgDialect } from '~/pg-core/dialect.ts';\nimport { 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, type SQL, sql } from '~/sql/sql.ts';\nimport { type Assume, mapResultRow } from '~/utils.ts';\n\nexport type NeonClient = Pool | PoolClient | Client;\n\nexport class NeonPreparedQuery<T extends PreparedQueryConfig, TIsRqbV2 extends boolean = false>\n\textends PgPreparedQuery<T>\n{\n\tstatic override readonly [entityKind]: string = 'NeonPreparedQuery';\n\n\tprivate rawQueryConfig: QueryConfig;\n\tprivate queryConfig: QueryArrayConfig;\n\n\tconstructor(\n\t\tprivate client: NeonClient,\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.rawQueryConfig = {\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.rawQueryConfig.text, params);\n\n\t\tconst { fields, client, rawQueryConfig: rawQuery, queryConfig: query, joinsNotNullableMap, customResultMapper } =\n\t\t\tthis;\n\t\tif (!fields && !customResultMapper) {\n\t\t\treturn client.query(rawQuery, params);\n\t\t}\n\n\t\tconst result = await client.query(query, params);\n\n\t\treturn customResultMapper\n\t\t\t? (customResultMapper as (rows: unknown[][]) => T['execute'])(result.rows)\n\t\t\t: result.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.rawQueryConfig.text, params);\n\n\t\tconst { client, rawQueryConfig: rawQuery, customResultMapper } = this;\n\n\t\tconst result = await client.query(rawQuery, params);\n\n\t\treturn customResultMapper!(result.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.rawQueryConfig.text, params);\n\t\treturn this.client.query(this.rawQueryConfig, 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.rawQueryConfig.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 NeonSessionOptions {\n\tlogger?: Logger;\n}\n\nexport class NeonSession<\n\tTFullSchema extends Record<string, unknown>,\n\tTRelations extends AnyRelations,\n\tTTablesConfig extends TablesRelationalConfig,\n\tTSchema extends V1.TablesRelationalConfig,\n> extends PgSession<NeonQueryResultHKT, TFullSchema, TRelations, TTablesConfig, TSchema> {\n\tstatic override readonly [entityKind]: string = 'NeonSession';\n\n\tprivate logger: Logger;\n\n\tconstructor(\n\t\tprivate client: NeonClient,\n\t\tdialect: PgDialect,\n\t\tprivate relations: AnyRelations | undefined,\n\t\tprivate schema: V1.RelationalSchemaConfig<TSchema> | undefined,\n\t\tprivate options: NeonSessionOptions = {},\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 NeonPreparedQuery(\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 NeonPreparedQuery(\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 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 async transaction<T>(\n\t\ttransaction: (tx: NeonTransaction<TFullSchema, TRelations, TTablesConfig, TSchema>) => Promise<T>,\n\t\tconfig: PgTransactionConfig = {},\n\t): Promise<T> {\n\t\tconst session = this.client instanceof Pool // eslint-disable-line no-instanceof/no-instanceof\n\t\t\t? new NeonSession(await this.client.connect(), this.dialect, this.relations, this.schema, this.options)\n\t\t\t: this;\n\t\tconst tx = new NeonTransaction<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 ${tx.getTransactionConfigSQL(config)}`);\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 Pool) { // eslint-disable-line no-instanceof/no-instanceof\n\t\t\t\t(session.client as PoolClient).release();\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport class NeonTransaction<\n\tTFullSchema extends Record<string, unknown>,\n\tTRelations extends AnyRelations,\n\tTTablesConfig extends TablesRelationalConfig,\n\tTSchema extends V1.TablesRelationalConfig,\n> extends PgTransaction<NeonQueryResultHKT, TFullSchema, TRelations, TTablesConfig, TSchema> {\n\tstatic override readonly [entityKind]: string = 'NeonTransaction';\n\n\toverride async transaction<T>(\n\t\ttransaction: (tx: NeonTransaction<TFullSchema, TRelations, TTablesConfig, TSchema>) => Promise<T>,\n\t): Promise<T> {\n\t\tconst savepointName = `sp${this.nestedIndex + 1}`;\n\t\tconst tx = new NeonTransaction<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 (e) {\n\t\t\tawait tx.execute(sql.raw(`rollback to savepoint ${savepointName}`));\n\t\t\tthrow e;\n\t\t}\n\t}\n}\n\nexport interface NeonQueryResultHKT extends PgQueryResultHKT {\n\ttype: QueryResult<Assume<this['row'], QueryResultRow>>;\n}\n"],"mappings":"AAAA;AAAA,EAEC;AAAA,EAMA;AAAA,OACM;AAEP,SAAS,kBAAkB;AAE3B,SAAS,kBAAkB;AAE3B,SAAS,qBAAqB;AAG9B,SAAS,iBAAiB,iBAAiB;AAE3C,SAAS,kBAAwC,WAAW;AAC5D,SAAsB,oBAAoB;AAInC,MAAM,0BACJ,gBACT;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,iBAAiB;AAAA,MACrB;AAAA,MACA,MAAM;AAAA,MACN,OAAO;AAAA;AAAA,QAEN,eAAe,CAAC,QAAQ,WAAW;AAClC,cAAI,WAAW,MAAM,SAAS,aAAa;AAC1C,mBAAO,CAAC,QAAa;AAAA,UACtB;AACA,cAAI,WAAW,MAAM,SAA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AS,OAAO;AACf,YAAM,GAAG,QAAQ,aAAa;AAC9B,YAAM;AAAA,IACP,UAAE;AACD,UAAI,KAAK,kBAAkB,MAAM;AAChC,QAAC,QAAQ,OAAsB,QAAQ;AAAA,MACxC;AAAA,IACD;AAAA,EACD;AACD;AAEO,MAAM,wBAKH,cAAmF;AAAA,EAC5F,QAA0B,UAAU,IAAY;AAAA,EAEhD,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,IAAI,IAAI,aAAa,aAAa,EAAE,CAAC;AACtD,QAAI;AACH,YAAM,SAAS,MAAM,YAAY,EAAE;AACnC,YAAM,GAAG,QAAQ,IAAI,IAAI,qBAAqB,aAAa,EAAE,CAAC;AAC9D,aAAO;AAAA,IACR,SAAS,GAAG;AACX,YAAM,GAAG,QAAQ,IAAI,IAAI,yBAAyB,aAAa,EAAE,CAAC;AAClE,YAAM;AAAA,IACP;AAAA,EACD;AACD;","names":["sql"]}
|
|
1
|
+
{"version":3,"sources":["../../src/neon-serverless/session.ts"],"sourcesContent":["import {\n\ttype Client,\n\tPool,\n\ttype PoolClient,\n\ttype QueryArrayConfig,\n\ttype QueryConfig,\n\ttype QueryResult,\n\ttype QueryResultRow,\n\ttypes,\n} from '@neondatabase/serverless';\nimport { entityKind } from '~/entity.ts';\nimport type { Logger } from '~/logger.ts';\nimport { NoopLogger } from '~/logger.ts';\nimport type { PgDialect } from '~/pg-core/dialect.ts';\nimport { 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 NeonClient = Pool | PoolClient | Client;\n\nexport class NeonPreparedQuery<T extends PreparedQueryConfig> extends PgPreparedQuery<T> {\n\tstatic override readonly [entityKind]: string = 'NeonPreparedQuery';\n\n\tprivate rawQueryConfig: QueryConfig;\n\tprivate queryConfig: QueryArrayConfig;\n\n\tconstructor(\n\t\tprivate client: NeonClient,\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.rawQueryConfig = {\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.rawQueryConfig.text, params);\n\n\t\tconst { fields, client, rawQueryConfig: rawQuery, queryConfig: query, joinsNotNullableMap, customResultMapper } =\n\t\t\tthis;\n\t\tif (!fields && !customResultMapper) {\n\t\t\treturn client.query(rawQuery, params);\n\t\t}\n\n\t\tconst result = await client.query(query, params);\n\n\t\treturn customResultMapper\n\t\t\t? customResultMapper(result.rows)\n\t\t\t: result.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.rawQueryConfig.text, params);\n\t\treturn this.client.query(this.rawQueryConfig, 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.rawQueryConfig.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 NeonSessionOptions {\n\tlogger?: Logger;\n}\n\nexport class NeonSession<\n\tTFullSchema extends Record<string, unknown>,\n\tTSchema extends TablesRelationalConfig,\n> extends PgSession<NeonQueryResultHKT, TFullSchema, TSchema> {\n\tstatic override readonly [entityKind]: string = 'NeonSession';\n\n\tprivate logger: Logger;\n\n\tconstructor(\n\t\tprivate client: NeonClient,\n\t\tdialect: PgDialect,\n\t\tprivate schema: RelationalSchemaConfig<TSchema> | undefined,\n\t\tprivate options: NeonSessionOptions = {},\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 NeonPreparedQuery(\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 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 async transaction<T>(\n\t\ttransaction: (tx: NeonTransaction<TFullSchema, TSchema>) => Promise<T>,\n\t\tconfig: PgTransactionConfig = {},\n\t): Promise<T> {\n\t\tconst session = this.client instanceof Pool // eslint-disable-line no-instanceof/no-instanceof\n\t\t\t? new NeonSession(await this.client.connect(), this.dialect, this.schema, this.options)\n\t\t\t: this;\n\t\tconst tx = new NeonTransaction<TFullSchema, TSchema>(this.dialect, session, this.schema);\n\t\tawait tx.execute(sql`begin ${tx.getTransactionConfigSQL(config)}`);\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 Pool) { // eslint-disable-line no-instanceof/no-instanceof\n\t\t\t\t(session.client as PoolClient).release();\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport class NeonTransaction<\n\tTFullSchema extends Record<string, unknown>,\n\tTSchema extends TablesRelationalConfig,\n> extends PgTransaction<NeonQueryResultHKT, TFullSchema, TSchema> {\n\tstatic override readonly [entityKind]: string = 'NeonTransaction';\n\n\toverride async transaction<T>(transaction: (tx: NeonTransaction<TFullSchema, TSchema>) => Promise<T>): Promise<T> {\n\t\tconst savepointName = `sp${this.nestedIndex + 1}`;\n\t\tconst tx = new NeonTransaction<TFullSchema, TSchema>(this.dialect, this.session, this.schema, this.nestedIndex + 1);\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 (e) {\n\t\t\tawait tx.execute(sql.raw(`rollback to savepoint ${savepointName}`));\n\t\t\tthrow e;\n\t\t}\n\t}\n}\n\nexport interface NeonQueryResultHKT extends PgQueryResultHKT {\n\ttype: QueryResult<Assume<this['row'], QueryResultRow>>;\n}\n"],"mappings":"AAAA;AA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B,YAAM;AAAA,IACP,UAAE;AACD,UAAI,KAAK,kBAAkB,MAAM;AAChC,QAAC,QAAQ,OAAsB,QAAQ;AAAA,MACxC;AAAA,IACD;AAAA,EACD;AACD;AAEO,MAAM,wBAGH,cAAwD;AAAA,EACjE,QAA0B,UAAU,IAAY;AAAA,EAEhD,MAAe,YAAe,aAAoF;AACjH,UAAM,gBAAgB,KAAK,KAAK,cAAc,CAAC;AAC/C,UAAM,KAAK,IAAI,gBAAsC,KAAK,SAAS,KAAK,SAAS,KAAK,QAAQ,KAAK,cAAc,CAAC;AAClH,UAAM,GAAG,QAAQ,IAAI,IAAI,aAAa,aAAa,EAAE,CAAC;AACtD,QAAI;AACH,YAAM,SAAS,MAAM,YAAY,EAAE;AACnC,YAAM,GAAG,QAAQ,IAAI,IAAI,qBAAqB,aAAa,EAAE,CAAC;AAC9D,aAAO;AAAA,IACR,SAAS,GAAG;AACX,YAAM,GAAG,QAAQ,IAAI,IAAI,yBAAyB,aAAa,EAAE,CAAC;AAClE,YAAM;AAAA,IACP;AAAA,EACD;AACD;","names":["sql"]}
|
package/node-postgres/driver.cjs
CHANGED
|
@@ -34,11 +34,11 @@ __export(driver_exports, {
|
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(driver_exports);
|
|
36
36
|
var import_pg = __toESM(require("pg"), 1);
|
|
37
|
-
var V1 = __toESM(require("../_relations.cjs"), 1);
|
|
38
37
|
var import_entity = require("../entity.cjs");
|
|
39
38
|
var import_logger = require("../logger.cjs");
|
|
40
39
|
var import_db = require("../pg-core/db.cjs");
|
|
41
40
|
var import_dialect = require("../pg-core/dialect.cjs");
|
|
41
|
+
var import_relations = require("../relations.cjs");
|
|
42
42
|
var import_utils = require("../utils.cjs");
|
|
43
43
|
var import_session = require("./session.cjs");
|
|
44
44
|
class NodePgDriver {
|
|
@@ -48,8 +48,8 @@ class NodePgDriver {
|
|
|
48
48
|
this.options = options;
|
|
49
49
|
}
|
|
50
50
|
static [import_entity.entityKind] = "NodePgDriver";
|
|
51
|
-
createSession(
|
|
52
|
-
return new import_session.NodePgSession(this.client, this.dialect,
|
|
51
|
+
createSession(schema) {
|
|
52
|
+
return new import_session.NodePgSession(this.client, this.dialect, schema, { logger: this.options.logger });
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
class NodePgDatabase extends import_db.PgDatabase {
|
|
@@ -65,9 +65,9 @@ function construct(client, config = {}) {
|
|
|
65
65
|
}
|
|
66
66
|
let schema;
|
|
67
67
|
if (config.schema) {
|
|
68
|
-
const tablesConfig =
|
|
68
|
+
const tablesConfig = (0, import_relations.extractTablesRelationalConfig)(
|
|
69
69
|
config.schema,
|
|
70
|
-
|
|
70
|
+
import_relations.createTableRelationsHelpers
|
|
71
71
|
);
|
|
72
72
|
schema = {
|
|
73
73
|
fullSchema: config.schema,
|
|
@@ -75,15 +75,9 @@ function construct(client, config = {}) {
|
|
|
75
75
|
tableNamesMap: tablesConfig.tableNamesMap
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
|
-
const relations = config.relations;
|
|
79
78
|
const driver = new NodePgDriver(client, dialect, { logger });
|
|
80
|
-
const session = driver.createSession(
|
|
81
|
-
const db = new NodePgDatabase(
|
|
82
|
-
dialect,
|
|
83
|
-
session,
|
|
84
|
-
relations,
|
|
85
|
-
schema
|
|
86
|
-
);
|
|
79
|
+
const session = driver.createSession(schema);
|
|
80
|
+
const db = new NodePgDatabase(dialect, session, schema);
|
|
87
81
|
db.$client = client;
|
|
88
82
|
return db;
|
|
89
83
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/node-postgres/driver.ts"],"sourcesContent":["import pg, { type Pool, type PoolConfig } from 'pg';\nimport
|
|
1
|
+
{"version":3,"sources":["../../src/node-postgres/driver.ts"],"sourcesContent":["import pg, { type Pool, type PoolConfig } from 'pg';\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/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 { NodePgClient, NodePgQueryResultHKT } from './session.ts';\nimport { NodePgSession } from './session.ts';\n\nexport interface PgDriverOptions {\n\tlogger?: Logger;\n}\n\nexport class NodePgDriver {\n\tstatic readonly [entityKind]: string = 'NodePgDriver';\n\n\tconstructor(\n\t\tprivate client: NodePgClient,\n\t\tprivate dialect: PgDialect,\n\t\tprivate options: PgDriverOptions = {},\n\t) {\n\t}\n\n\tcreateSession(\n\t\tschema: RelationalSchemaConfig<TablesRelationalConfig> | undefined,\n\t): NodePgSession<Record<string, unknown>, TablesRelationalConfig> {\n\t\treturn new NodePgSession(this.client, this.dialect, schema, { logger: this.options.logger });\n\t}\n}\n\nexport class NodePgDatabase<\n\tTSchema extends Record<string, unknown> = Record<string, never>,\n> extends PgDatabase<NodePgQueryResultHKT, TSchema> {\n\tstatic override readonly [entityKind]: string = 'NodePgDatabase';\n}\n\nfunction construct<\n\tTSchema extends Record<string, unknown> = Record<string, never>,\n\tTClient extends NodePgClient = NodePgClient,\n>(\n\tclient: TClient,\n\tconfig: DrizzleConfig<TSchema> = {},\n): NodePgDatabase<TSchema> & {\n\t$client: TClient;\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 NodePgDriver(client, dialect, { logger });\n\tconst session = driver.createSession(schema);\n\tconst db = new NodePgDatabase(dialect, session, schema as any) as NodePgDatabase<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 NodePgClient = Pool,\n>(\n\t...params:\n\t\t| [\n\t\t\tTClient | string,\n\t\t]\n\t\t| [\n\t\t\tTClient | string,\n\t\t\tDrizzleConfig<TSchema>,\n\t\t]\n\t\t| [\n\t\t\t(\n\t\t\t\t& DrizzleConfig<TSchema>\n\t\t\t\t& ({\n\t\t\t\t\tconnection: string | PoolConfig;\n\t\t\t\t} | {\n\t\t\t\t\tclient: TClient;\n\t\t\t\t})\n\t\t\t),\n\t\t]\n): NodePgDatabase<TSchema> & {\n\t$client: TClient;\n} {\n\tif (typeof params[0] === 'string') {\n\t\tconst instance = new pg.Pool({\n\t\t\tconnectionString: params[0],\n\t\t});\n\n\t\treturn construct(instance, params[1] as DrizzleConfig<TSchema> | undefined) as any;\n\t}\n\n\tif (isConfig(params[0])) {\n\t\tconst { connection, client, ...drizzleConfig } = params[0] as (\n\t\t\t& ({ connection?: PoolConfig | string; client?: TClient })\n\t\t\t& DrizzleConfig<TSchema>\n\t\t);\n\n\t\tif (client) return construct(client, drizzleConfig);\n\n\t\tconst instance = typeof connection === 'string'\n\t\t\t? new pg.Pool({\n\t\t\t\tconnectionString: connection,\n\t\t\t})\n\t\t\t: new pg.Pool(connection!);\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): NodePgDatabase<TSchema> & {\n\t\t$client: '$client is not available on drizzle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Z,QAoBF;AACD,MAAI,OAAO,OAAO,CAAC,MAAM,UAAU;AAClC,UAAM,WAAW,IAAI,UAAAA,QAAG,KAAK;AAAA,MAC5B,kBAAkB,OAAO,CAAC;AAAA,IAC3B,CAAC;AAED,WAAO,UAAU,UAAU,OAAO,CAAC,CAAuC;AAAA,EAC3E;AAEA,UAAI,uBAAS,OAAO,CAAC,CAAC,GAAG;AACxB,UAAM,EAAE,YAAY,QAAQ,GAAG,cAAc,IAAI,OAAO,CAAC;AAKzD,QAAI;AAAQ,aAAO,UAAU,QAAQ,aAAa;AAElD,UAAM,WAAW,OAAO,eAAe,WACpC,IAAI,UAAAA,QAAG,KAAK;AAAA,MACb,kBAAkB;AAAA,IACnB,CAAC,IACC,IAAI,UAAAA,QAAG,KAAK,UAAW;AAE1B,WAAO,UAAU,UAAU,aAAa;AAAA,EACzC;AAEA,SAAO,UAAU,OAAO,CAAC,GAAc,OAAO,CAAC,CAAuC;AACvF;AAAA,CAEO,CAAUC,aAAV;AACC,WAAS,KACf,QAGC;AACD,WAAO,UAAU,CAAC,GAAU,MAAM;AAAA,EACnC;AANO,EAAAA,SAAS;AAAA,GADA;","names":["pg","drizzle"]}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { type Pool, type PoolConfig } from 'pg';
|
|
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/dialect.cjs";
|
|
7
|
-
import
|
|
6
|
+
import { type RelationalSchemaConfig, type TablesRelationalConfig } from "../relations.cjs";
|
|
8
7
|
import { type DrizzleConfig } from "../utils.cjs";
|
|
9
8
|
import type { NodePgClient, NodePgQueryResultHKT } from "./session.cjs";
|
|
10
9
|
import { NodePgSession } from "./session.cjs";
|
|
@@ -17,27 +16,27 @@ export declare class NodePgDriver {
|
|
|
17
16
|
private options;
|
|
18
17
|
static readonly [entityKind]: string;
|
|
19
18
|
constructor(client: NodePgClient, dialect: PgDialect, options?: PgDriverOptions);
|
|
20
|
-
createSession(
|
|
19
|
+
createSession(schema: RelationalSchemaConfig<TablesRelationalConfig> | undefined): NodePgSession<Record<string, unknown>, TablesRelationalConfig>;
|
|
21
20
|
}
|
|
22
|
-
export declare class NodePgDatabase<TSchema extends Record<string, unknown> = Record<string, never
|
|
21
|
+
export declare class NodePgDatabase<TSchema extends Record<string, unknown> = Record<string, never>> extends PgDatabase<NodePgQueryResultHKT, TSchema> {
|
|
23
22
|
static readonly [entityKind]: string;
|
|
24
23
|
}
|
|
25
|
-
export declare function drizzle<TSchema extends Record<string, unknown> = Record<string, never>,
|
|
24
|
+
export declare function drizzle<TSchema extends Record<string, unknown> = Record<string, never>, TClient extends NodePgClient = Pool>(...params: [
|
|
26
25
|
TClient | string
|
|
27
26
|
] | [
|
|
28
27
|
TClient | string,
|
|
29
|
-
DrizzleConfig<TSchema
|
|
28
|
+
DrizzleConfig<TSchema>
|
|
30
29
|
] | [
|
|
31
|
-
(DrizzleConfig<TSchema
|
|
30
|
+
(DrizzleConfig<TSchema> & ({
|
|
32
31
|
connection: string | PoolConfig;
|
|
33
32
|
} | {
|
|
34
33
|
client: TClient;
|
|
35
34
|
}))
|
|
36
|
-
]): NodePgDatabase<TSchema
|
|
35
|
+
]): NodePgDatabase<TSchema> & {
|
|
37
36
|
$client: TClient;
|
|
38
37
|
};
|
|
39
38
|
export declare namespace drizzle {
|
|
40
|
-
function mock<TSchema extends Record<string, unknown> = Record<string, never
|
|
39
|
+
function mock<TSchema extends Record<string, unknown> = Record<string, never>>(config?: DrizzleConfig<TSchema>): NodePgDatabase<TSchema> & {
|
|
41
40
|
$client: '$client is not available on drizzle.mock()';
|
|
42
41
|
};
|
|
43
42
|
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { type Pool, type PoolConfig } from 'pg';
|
|
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/dialect.js";
|
|
7
|
-
import
|
|
6
|
+
import { type RelationalSchemaConfig, type TablesRelationalConfig } from "../relations.js";
|
|
8
7
|
import { type DrizzleConfig } from "../utils.js";
|
|
9
8
|
import type { NodePgClient, NodePgQueryResultHKT } from "./session.js";
|
|
10
9
|
import { NodePgSession } from "./session.js";
|
|
@@ -17,27 +16,27 @@ export declare class NodePgDriver {
|
|
|
17
16
|
private options;
|
|
18
17
|
static readonly [entityKind]: string;
|
|
19
18
|
constructor(client: NodePgClient, dialect: PgDialect, options?: PgDriverOptions);
|
|
20
|
-
createSession(
|
|
19
|
+
createSession(schema: RelationalSchemaConfig<TablesRelationalConfig> | undefined): NodePgSession<Record<string, unknown>, TablesRelationalConfig>;
|
|
21
20
|
}
|
|
22
|
-
export declare class NodePgDatabase<TSchema extends Record<string, unknown> = Record<string, never
|
|
21
|
+
export declare class NodePgDatabase<TSchema extends Record<string, unknown> = Record<string, never>> extends PgDatabase<NodePgQueryResultHKT, TSchema> {
|
|
23
22
|
static readonly [entityKind]: string;
|
|
24
23
|
}
|
|
25
|
-
export declare function drizzle<TSchema extends Record<string, unknown> = Record<string, never>,
|
|
24
|
+
export declare function drizzle<TSchema extends Record<string, unknown> = Record<string, never>, TClient extends NodePgClient = Pool>(...params: [
|
|
26
25
|
TClient | string
|
|
27
26
|
] | [
|
|
28
27
|
TClient | string,
|
|
29
|
-
DrizzleConfig<TSchema
|
|
28
|
+
DrizzleConfig<TSchema>
|
|
30
29
|
] | [
|
|
31
|
-
(DrizzleConfig<TSchema
|
|
30
|
+
(DrizzleConfig<TSchema> & ({
|
|
32
31
|
connection: string | PoolConfig;
|
|
33
32
|
} | {
|
|
34
33
|
client: TClient;
|
|
35
34
|
}))
|
|
36
|
-
]): NodePgDatabase<TSchema
|
|
35
|
+
]): NodePgDatabase<TSchema> & {
|
|
37
36
|
$client: TClient;
|
|
38
37
|
};
|
|
39
38
|
export declare namespace drizzle {
|
|
40
|
-
function mock<TSchema extends Record<string, unknown> = Record<string, never
|
|
39
|
+
function mock<TSchema extends Record<string, unknown> = Record<string, never>>(config?: DrizzleConfig<TSchema>): NodePgDatabase<TSchema> & {
|
|
41
40
|
$client: '$client is not available on drizzle.mock()';
|
|
42
41
|
};
|
|
43
42
|
}
|
package/node-postgres/driver.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import pg from "pg";
|
|
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/dialect.js";
|
|
6
|
+
import {
|
|
7
|
+
createTableRelationsHelpers,
|
|
8
|
+
extractTablesRelationalConfig
|
|
9
|
+
} from "../relations.js";
|
|
7
10
|
import { isConfig } from "../utils.js";
|
|
8
11
|
import { NodePgSession } from "./session.js";
|
|
9
12
|
class NodePgDriver {
|
|
@@ -13,8 +16,8 @@ class NodePgDriver {
|
|
|
13
16
|
this.options = options;
|
|
14
17
|
}
|
|
15
18
|
static [entityKind] = "NodePgDriver";
|
|
16
|
-
createSession(
|
|
17
|
-
return new NodePgSession(this.client, this.dialect,
|
|
19
|
+
createSession(schema) {
|
|
20
|
+
return new NodePgSession(this.client, this.dialect, schema, { logger: this.options.logger });
|
|
18
21
|
}
|
|
19
22
|
}
|
|
20
23
|
class NodePgDatabase 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 NodePgDriver(client, dialect, { logger });
|
|
45
|
-
const session = driver.createSession(
|
|
46
|
-
const db = new NodePgDatabase(
|
|
47
|
-
dialect,
|
|
48
|
-
session,
|
|
49
|
-
relations,
|
|
50
|
-
schema
|
|
51
|
-
);
|
|
47
|
+
const session = driver.createSession(schema);
|
|
48
|
+
const db = new NodePgDatabase(dialect, session, schema);
|
|
52
49
|
db.$client = client;
|
|
53
50
|
return db;
|
|
54
51
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/node-postgres/driver.ts"],"sourcesContent":["import pg, { type Pool, type PoolConfig } from 'pg';\nimport
|
|
1
|
+
{"version":3,"sources":["../../src/node-postgres/driver.ts"],"sourcesContent":["import pg, { type Pool, type PoolConfig } from 'pg';\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/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 { NodePgClient, NodePgQueryResultHKT } from './session.ts';\nimport { NodePgSession } from './session.ts';\n\nexport interface PgDriverOptions {\n\tlogger?: Logger;\n}\n\nexport class NodePgDriver {\n\tstatic readonly [entityKind]: string = 'NodePgDriver';\n\n\tconstructor(\n\t\tprivate client: NodePgClient,\n\t\tprivate dialect: PgDialect,\n\t\tprivate options: PgDriverOptions = {},\n\t) {\n\t}\n\n\tcreateSession(\n\t\tschema: RelationalSchemaConfig<TablesRelationalConfig> | undefined,\n\t): NodePgSession<Record<string, unknown>, TablesRelationalConfig> {\n\t\treturn new NodePgSession(this.client, this.dialect, schema, { logger: this.options.logger });\n\t}\n}\n\nexport class NodePgDatabase<\n\tTSchema extends Record<string, unknown> = Record<string, never>,\n> extends PgDatabase<NodePgQueryResultHKT, TSchema> {\n\tstatic override readonly [entityKind]: string = 'NodePgDatabase';\n}\n\nfunction construct<\n\tTSchema extends Record<string, unknown> = Record<string, never>,\n\tTClient extends NodePgClient = NodePgClient,\n>(\n\tclient: TClient,\n\tconfig: DrizzleConfig<TSchema> = {},\n): NodePgDatabase<TSchema> & {\n\t$client: TClient;\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 NodePgDriver(client, dialect, { logger });\n\tconst session = driver.createSession(schema);\n\tconst db = new NodePgDatabase(dialect, session, schema as any) as NodePgDatabase<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 NodePgClient = Pool,\n>(\n\t...params:\n\t\t| [\n\t\t\tTClient | string,\n\t\t]\n\t\t| [\n\t\t\tTClient | string,\n\t\t\tDrizzleConfig<TSchema>,\n\t\t]\n\t\t| [\n\t\t\t(\n\t\t\t\t& DrizzleConfig<TSchema>\n\t\t\t\t& ({\n\t\t\t\t\tconnection: string | PoolConfig;\n\t\t\t\t} | {\n\t\t\t\t\tclient: TClient;\n\t\t\t\t})\n\t\t\t),\n\t\t]\n): NodePgDatabase<TSchema> & {\n\t$client: TClient;\n} {\n\tif (typeof params[0] === 'string') {\n\t\tconst instance = new pg.Pool({\n\t\t\tconnectionString: params[0],\n\t\t});\n\n\t\treturn construct(instance, params[1] as DrizzleConfig<TSchema> | undefined) as any;\n\t}\n\n\tif (isConfig(params[0])) {\n\t\tconst { connection, client, ...drizzleConfig } = params[0] as (\n\t\t\t& ({ connection?: PoolConfig | string; client?: TClient })\n\t\t\t& DrizzleConfig<TSchema>\n\t\t);\n\n\t\tif (client) return construct(client, drizzleConfig);\n\n\t\tconst instance = typeof connection === 'string'\n\t\t\t? new pg.Pool({\n\t\t\t\tconnectionString: connection,\n\t\t\t})\n\t\t\t: new pg.Pool(connection!);\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): NodePgDatabase<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,OAAO,QAAwC;AAC/C,SAAS,kBAAkB;AAE3B,SAAS,qBAAqB;AAC9B,SAAS,kBAAkB;AAC3B,SAAS,iBAAiB;AAC1B;AAAA,EACC;AAAA,EACA;AAAA,OAGM;AACP,SAA6B,gBAAgB;AAE7C,SAAS,qBAAqB;AAMvB,MAAM,aAAa;AAAA,EAGzB,YACS,QACA,SACA,UAA2B,CAAC,GACnC;AAHO;AACA;AACA;AAAA,EAET;AAAA,EAPA,QAAiB,UAAU,IAAY;AAAA,EASvC,cACC,QACiE;AACjE,WAAO,IAAI,cAAc,KAAK,QAAQ,KAAK,SAA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AK,UAAW;AAE1B,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/node-postgres/migrator.ts"],"sourcesContent":["import type { MigrationConfig } from '~/migrator.ts';\nimport { readMigrationFiles } from '~/migrator.ts';\nimport type {
|
|
1
|
+
{"version":3,"sources":["../../src/node-postgres/migrator.ts"],"sourcesContent":["import type { MigrationConfig } from '~/migrator.ts';\nimport { readMigrationFiles } from '~/migrator.ts';\nimport type { NodePgDatabase } from './driver.ts';\n\nexport async function migrate<TSchema extends Record<string, unknown>>(\n\tdb: NodePgDatabase<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 { NodePgDatabase } from "./driver.cjs";
|
|
4
|
-
export declare function migrate<TSchema extends Record<string, unknown
|
|
3
|
+
export declare function migrate<TSchema extends Record<string, unknown>>(db: NodePgDatabase<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 { NodePgDatabase } from "./driver.js";
|
|
4
|
-
export declare function migrate<TSchema extends Record<string, unknown
|
|
3
|
+
export declare function migrate<TSchema extends Record<string, unknown>>(db: NodePgDatabase<TSchema>, config: MigrationConfig): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/node-postgres/migrator.ts"],"sourcesContent":["import type { MigrationConfig } from '~/migrator.ts';\nimport { readMigrationFiles } from '~/migrator.ts';\nimport type {
|
|
1
|
+
{"version":3,"sources":["../../src/node-postgres/migrator.ts"],"sourcesContent":["import type { MigrationConfig } from '~/migrator.ts';\nimport { readMigrationFiles } from '~/migrator.ts';\nimport type { NodePgDatabase } from './driver.ts';\n\nexport async function migrate<TSchema extends Record<string, unknown>>(\n\tdb: NodePgDatabase<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":[]}
|