drizzle-orm 0.39.2-8628c8a → 0.39.2-c7c31ad
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_relations.cjs +328 -0
- package/_relations.cjs.map +1 -0
- package/_relations.d.cts +215 -0
- package/_relations.d.ts +215 -0
- package/_relations.js +316 -0
- package/_relations.js.map +1 -0
- package/alias.cjs.map +1 -1
- package/alias.d.cts +3 -3
- package/alias.d.ts +3 -3
- package/alias.js.map +1 -1
- package/aws-data-api/pg/driver.cjs +19 -5
- package/aws-data-api/pg/driver.cjs.map +1 -1
- package/aws-data-api/pg/driver.d.cts +9 -8
- package/aws-data-api/pg/driver.d.ts +9 -8
- package/aws-data-api/pg/driver.js +9 -8
- package/aws-data-api/pg/driver.js.map +1 -1
- package/aws-data-api/pg/migrator.cjs.map +1 -1
- package/aws-data-api/pg/migrator.d.cts +2 -1
- package/aws-data-api/pg/migrator.d.ts +2 -1
- package/aws-data-api/pg/migrator.js.map +1 -1
- package/aws-data-api/pg/session.cjs +67 -4
- package/aws-data-api/pg/session.cjs.map +1 -1
- package/aws-data-api/pg/session.d.cts +13 -8
- package/aws-data-api/pg/session.d.ts +13 -8
- package/aws-data-api/pg/session.js +67 -4
- package/aws-data-api/pg/session.js.map +1 -1
- package/better-sqlite3/driver.cjs +12 -5
- package/better-sqlite3/driver.cjs.map +1 -1
- package/better-sqlite3/driver.d.cts +7 -6
- package/better-sqlite3/driver.d.ts +7 -6
- package/better-sqlite3/driver.js +12 -8
- package/better-sqlite3/driver.js.map +1 -1
- package/better-sqlite3/migrator.cjs.map +1 -1
- package/better-sqlite3/migrator.d.cts +2 -1
- package/better-sqlite3/migrator.d.ts +2 -1
- package/better-sqlite3/migrator.js.map +1 -1
- package/better-sqlite3/session.cjs +49 -4
- package/better-sqlite3/session.cjs.map +1 -1
- package/better-sqlite3/session.d.cts +14 -8
- package/better-sqlite3/session.d.ts +14 -8
- package/better-sqlite3/session.js +49 -4
- package/better-sqlite3/session.js.map +1 -1
- package/bun-sql/driver.cjs +16 -5
- package/bun-sql/driver.cjs.map +1 -1
- package/bun-sql/driver.d.cts +7 -6
- package/bun-sql/driver.d.ts +7 -6
- package/bun-sql/driver.js +6 -8
- package/bun-sql/driver.js.map +1 -1
- package/bun-sql/migrator.cjs.map +1 -1
- package/bun-sql/migrator.d.cts +2 -1
- package/bun-sql/migrator.d.ts +2 -1
- package/bun-sql/migrator.js.map +1 -1
- package/bun-sql/session.cjs +50 -6
- package/bun-sql/session.cjs.map +1 -1
- package/bun-sql/session.d.cts +14 -9
- package/bun-sql/session.d.ts +14 -9
- package/bun-sql/session.js +50 -6
- package/bun-sql/session.js.map +1 -1
- package/bun-sqlite/driver.cjs +22 -5
- package/bun-sqlite/driver.cjs.map +1 -1
- package/bun-sqlite/driver.d.cts +7 -6
- package/bun-sqlite/driver.d.ts +7 -6
- package/bun-sqlite/driver.js +12 -8
- package/bun-sqlite/driver.js.map +1 -1
- package/bun-sqlite/migrator.cjs.map +1 -1
- package/bun-sqlite/migrator.d.cts +2 -1
- package/bun-sqlite/migrator.d.ts +2 -1
- package/bun-sqlite/migrator.js.map +1 -1
- package/bun-sqlite/session.cjs +49 -4
- package/bun-sqlite/session.cjs.map +1 -1
- package/bun-sqlite/session.d.cts +14 -8
- package/bun-sqlite/session.d.ts +14 -8
- package/bun-sqlite/session.js +49 -4
- package/bun-sqlite/session.js.map +1 -1
- package/column-builder.cjs.map +1 -1
- package/column-builder.d.cts +5 -6
- package/column-builder.d.ts +5 -6
- package/column-builder.js.map +1 -1
- package/d1/driver.cjs +22 -5
- package/d1/driver.cjs.map +1 -1
- package/d1/driver.d.cts +3 -2
- package/d1/driver.d.ts +3 -2
- package/d1/driver.js +12 -8
- package/d1/driver.js.map +1 -1
- package/d1/migrator.cjs.map +1 -1
- package/d1/migrator.d.cts +2 -1
- package/d1/migrator.d.ts +2 -1
- package/d1/migrator.js.map +1 -1
- package/d1/session.cjs +50 -8
- package/d1/session.cjs.map +1 -1
- package/d1/session.d.cts +15 -8
- package/d1/session.d.ts +15 -8
- package/d1/session.js +50 -8
- package/d1/session.js.map +1 -1
- package/durable-sqlite/driver.cjs +16 -5
- package/durable-sqlite/driver.cjs.map +1 -1
- package/durable-sqlite/driver.d.cts +3 -2
- package/durable-sqlite/driver.d.ts +3 -2
- package/durable-sqlite/driver.js +6 -8
- package/durable-sqlite/driver.js.map +1 -1
- package/durable-sqlite/migrator.cjs.map +1 -1
- package/durable-sqlite/migrator.d.cts +2 -1
- package/durable-sqlite/migrator.d.ts +2 -1
- package/durable-sqlite/migrator.js.map +1 -1
- package/durable-sqlite/session.cjs +46 -4
- package/durable-sqlite/session.cjs.map +1 -1
- package/durable-sqlite/session.d.cts +14 -8
- package/durable-sqlite/session.d.ts +14 -8
- package/durable-sqlite/session.js +46 -4
- package/durable-sqlite/session.js.map +1 -1
- package/expo-sqlite/driver.cjs +22 -5
- package/expo-sqlite/driver.cjs.map +1 -1
- package/expo-sqlite/driver.d.cts +3 -2
- package/expo-sqlite/driver.d.ts +3 -2
- package/expo-sqlite/driver.js +12 -8
- package/expo-sqlite/driver.js.map +1 -1
- package/expo-sqlite/migrator.cjs.map +1 -1
- package/expo-sqlite/migrator.d.cts +3 -2
- package/expo-sqlite/migrator.d.ts +3 -2
- package/expo-sqlite/migrator.js.map +1 -1
- package/expo-sqlite/query.cjs +13 -2
- package/expo-sqlite/query.cjs.map +1 -1
- package/expo-sqlite/query.d.cts +2 -1
- package/expo-sqlite/query.d.ts +2 -1
- package/expo-sqlite/query.js +3 -2
- package/expo-sqlite/query.js.map +1 -1
- package/expo-sqlite/session.cjs +47 -4
- package/expo-sqlite/session.cjs.map +1 -1
- package/expo-sqlite/session.d.cts +14 -8
- package/expo-sqlite/session.d.ts +14 -8
- package/expo-sqlite/session.js +47 -4
- package/expo-sqlite/session.js.map +1 -1
- package/libsql/driver-core.cjs +22 -5
- package/libsql/driver-core.cjs.map +1 -1
- package/libsql/driver-core.d.cts +2 -1
- package/libsql/driver-core.d.ts +2 -1
- package/libsql/driver-core.js +12 -8
- package/libsql/driver-core.js.map +1 -1
- package/libsql/driver.cjs.map +1 -1
- package/libsql/driver.d.cts +6 -5
- package/libsql/driver.d.ts +6 -5
- package/libsql/driver.js.map +1 -1
- package/libsql/http/index.cjs.map +1 -1
- package/libsql/http/index.d.cts +6 -5
- package/libsql/http/index.d.ts +6 -5
- package/libsql/http/index.js.map +1 -1
- package/libsql/migrator.cjs.map +1 -1
- package/libsql/migrator.d.cts +2 -1
- package/libsql/migrator.d.ts +2 -1
- package/libsql/migrator.js.map +1 -1
- package/libsql/node/index.cjs.map +1 -1
- package/libsql/node/index.d.cts +6 -5
- package/libsql/node/index.d.ts +6 -5
- package/libsql/node/index.js.map +1 -1
- package/libsql/session.cjs +56 -4
- package/libsql/session.cjs.map +1 -1
- package/libsql/session.d.cts +15 -9
- package/libsql/session.d.ts +15 -9
- package/libsql/session.js +56 -4
- package/libsql/session.js.map +1 -1
- package/libsql/sqlite3/index.cjs.map +1 -1
- package/libsql/sqlite3/index.d.cts +6 -5
- package/libsql/sqlite3/index.d.ts +6 -5
- package/libsql/sqlite3/index.js.map +1 -1
- package/libsql/wasm/index.cjs.map +1 -1
- package/libsql/wasm/index.d.cts +6 -5
- package/libsql/wasm/index.d.ts +6 -5
- package/libsql/wasm/index.js.map +1 -1
- package/libsql/web/index.cjs.map +1 -1
- package/libsql/web/index.d.cts +6 -5
- package/libsql/web/index.d.ts +6 -5
- package/libsql/web/index.js.map +1 -1
- package/libsql/ws/index.cjs.map +1 -1
- package/libsql/ws/index.d.cts +6 -5
- package/libsql/ws/index.d.ts +6 -5
- package/libsql/ws/index.js.map +1 -1
- package/mysql-core/db.cjs +30 -6
- package/mysql-core/db.cjs.map +1 -1
- package/mysql-core/db.d.cts +15 -8
- package/mysql-core/db.d.ts +15 -8
- package/mysql-core/db.js +29 -5
- package/mysql-core/db.js.map +1 -1
- package/mysql-core/dialect.cjs +187 -15
- package/mysql-core/dialect.cjs.map +1 -1
- package/mysql-core/dialect.d.cts +36 -13
- package/mysql-core/dialect.d.ts +36 -13
- package/mysql-core/dialect.js +185 -22
- package/mysql-core/dialect.js.map +1 -1
- package/mysql-core/query-builders/_query.cjs +149 -0
- package/mysql-core/query-builders/_query.cjs.map +1 -0
- package/mysql-core/query-builders/_query.d.cts +44 -0
- package/mysql-core/query-builders/_query.d.ts +44 -0
- package/mysql-core/query-builders/_query.js +114 -0
- package/mysql-core/query-builders/_query.js.map +1 -0
- package/mysql-core/query-builders/count.cjs.map +1 -1
- package/mysql-core/query-builders/count.d.cts +1 -1
- package/mysql-core/query-builders/count.d.ts +1 -1
- package/mysql-core/query-builders/count.js.map +1 -1
- package/mysql-core/query-builders/query.cjs +18 -31
- package/mysql-core/query-builders/query.cjs.map +1 -1
- package/mysql-core/query-builders/query.d.cts +8 -10
- package/mysql-core/query-builders/query.d.ts +8 -10
- package/mysql-core/query-builders/query.js +18 -31
- package/mysql-core/query-builders/query.js.map +1 -1
- package/mysql-core/session.cjs +3 -2
- package/mysql-core/session.cjs.map +1 -1
- package/mysql-core/session.d.cts +10 -7
- package/mysql-core/session.d.ts +10 -7
- package/mysql-core/session.js +3 -2
- package/mysql-core/session.js.map +1 -1
- package/mysql-proxy/driver.cjs +22 -5
- package/mysql-proxy/driver.cjs.map +1 -1
- package/mysql-proxy/driver.d.cts +3 -2
- package/mysql-proxy/driver.d.ts +3 -2
- package/mysql-proxy/driver.js +12 -8
- package/mysql-proxy/driver.js.map +1 -1
- package/mysql-proxy/migrator.cjs.map +1 -1
- package/mysql-proxy/migrator.d.cts +2 -1
- package/mysql-proxy/migrator.d.ts +2 -1
- package/mysql-proxy/migrator.js.map +1 -1
- package/mysql-proxy/session.cjs +27 -2
- package/mysql-proxy/session.cjs.map +1 -1
- package/mysql-proxy/session.d.cts +13 -8
- package/mysql-proxy/session.d.ts +13 -8
- package/mysql-proxy/session.js +27 -2
- package/mysql-proxy/session.js.map +1 -1
- package/mysql2/driver.cjs +24 -7
- package/mysql2/driver.cjs.map +1 -1
- package/mysql2/driver.d.cts +10 -9
- package/mysql2/driver.d.ts +10 -9
- package/mysql2/driver.js +14 -10
- package/mysql2/driver.js.map +1 -1
- package/mysql2/migrator.cjs.map +1 -1
- package/mysql2/migrator.d.cts +2 -1
- package/mysql2/migrator.d.ts +2 -1
- package/mysql2/migrator.js.map +1 -1
- package/mysql2/session.cjs +30 -2
- package/mysql2/session.cjs.map +1 -1
- package/mysql2/session.d.cts +13 -8
- package/mysql2/session.d.ts +13 -8
- package/mysql2/session.js +30 -2
- package/mysql2/session.js.map +1 -1
- package/neon-http/driver.cjs +21 -7
- package/neon-http/driver.cjs.map +1 -1
- package/neon-http/driver.d.cts +10 -9
- package/neon-http/driver.d.ts +10 -9
- package/neon-http/driver.js +11 -7
- package/neon-http/driver.js.map +1 -1
- package/neon-http/migrator.cjs.map +1 -1
- package/neon-http/migrator.d.cts +2 -1
- package/neon-http/migrator.d.ts +2 -1
- package/neon-http/migrator.js.map +1 -1
- package/neon-http/session.cjs +32 -2
- package/neon-http/session.cjs.map +1 -1
- package/neon-http/session.d.cts +13 -8
- package/neon-http/session.d.ts +13 -8
- package/neon-http/session.js +32 -2
- package/neon-http/session.js.map +1 -1
- package/neon-serverless/driver.cjs +18 -7
- package/neon-serverless/driver.cjs.map +1 -1
- package/neon-serverless/driver.d.cts +9 -8
- package/neon-serverless/driver.d.ts +9 -8
- package/neon-serverless/driver.js +8 -10
- package/neon-serverless/driver.js.map +1 -1
- package/neon-serverless/migrator.cjs.map +1 -1
- package/neon-serverless/migrator.d.cts +2 -1
- package/neon-serverless/migrator.d.ts +2 -1
- package/neon-serverless/migrator.js.map +1 -1
- package/neon-serverless/session.cjs +40 -5
- package/neon-serverless/session.cjs.map +1 -1
- package/neon-serverless/session.d.cts +13 -8
- package/neon-serverless/session.d.ts +13 -8
- package/neon-serverless/session.js +40 -5
- package/neon-serverless/session.js.map +1 -1
- package/node-postgres/driver.cjs +13 -7
- package/node-postgres/driver.cjs.map +1 -1
- package/node-postgres/driver.d.cts +9 -8
- package/node-postgres/driver.d.ts +9 -8
- package/node-postgres/driver.js +13 -10
- package/node-postgres/driver.js.map +1 -1
- package/node-postgres/migrator.cjs.map +1 -1
- package/node-postgres/migrator.d.cts +2 -1
- package/node-postgres/migrator.d.ts +2 -1
- package/node-postgres/migrator.js.map +1 -1
- package/node-postgres/session.cjs +45 -4
- package/node-postgres/session.cjs.map +1 -1
- package/node-postgres/session.d.cts +13 -8
- package/node-postgres/session.d.ts +13 -8
- package/node-postgres/session.js +45 -4
- package/node-postgres/session.js.map +1 -1
- package/op-sqlite/driver.cjs +22 -5
- package/op-sqlite/driver.cjs.map +1 -1
- package/op-sqlite/driver.d.cts +3 -2
- package/op-sqlite/driver.d.ts +3 -2
- package/op-sqlite/driver.js +12 -8
- package/op-sqlite/driver.js.map +1 -1
- package/op-sqlite/migrator.cjs.map +1 -1
- package/op-sqlite/migrator.d.cts +3 -2
- package/op-sqlite/migrator.d.ts +3 -2
- package/op-sqlite/migrator.js.map +1 -1
- package/op-sqlite/session.cjs +47 -4
- package/op-sqlite/session.cjs.map +1 -1
- package/op-sqlite/session.d.cts +14 -8
- package/op-sqlite/session.d.ts +14 -8
- package/op-sqlite/session.js +47 -4
- package/op-sqlite/session.js.map +1 -1
- package/package.json +367 -1052
- package/pg-core/db.cjs +32 -5
- package/pg-core/db.cjs.map +1 -1
- package/pg-core/db.d.cts +16 -9
- package/pg-core/db.d.ts +16 -9
- package/pg-core/db.js +31 -4
- package/pg-core/db.js.map +1 -1
- package/pg-core/dialect.cjs +162 -488
- package/pg-core/dialect.cjs.map +1 -1
- package/pg-core/dialect.d.cts +27 -8
- package/pg-core/dialect.d.ts +27 -8
- package/pg-core/dialect.js +160 -495
- package/pg-core/dialect.js.map +1 -1
- package/{gel-core/query-builders/query.cjs → pg-core/query-builders/_query.cjs} +31 -15
- package/pg-core/query-builders/_query.cjs.map +1 -0
- package/pg-core/query-builders/_query.d.cts +47 -0
- package/pg-core/query-builders/_query.d.ts +47 -0
- package/{gel-core/query-builders/query.js → pg-core/query-builders/_query.js} +19 -15
- package/pg-core/query-builders/_query.js.map +1 -0
- package/pg-core/query-builders/count.cjs.map +1 -1
- package/pg-core/query-builders/count.d.cts +1 -1
- package/pg-core/query-builders/count.d.ts +1 -1
- package/pg-core/query-builders/count.js.map +1 -1
- package/pg-core/query-builders/query.cjs +15 -18
- package/pg-core/query-builders/query.cjs.map +1 -1
- package/pg-core/query-builders/query.d.cts +6 -6
- package/pg-core/query-builders/query.d.ts +6 -6
- package/pg-core/query-builders/query.js +15 -18
- package/pg-core/query-builders/query.js.map +1 -1
- package/pg-core/session.cjs +3 -2
- package/pg-core/session.cjs.map +1 -1
- package/pg-core/session.d.cts +9 -6
- package/pg-core/session.d.ts +9 -6
- package/pg-core/session.js +3 -2
- package/pg-core/session.js.map +1 -1
- package/pg-core/table.cjs +0 -2
- package/pg-core/table.cjs.map +1 -1
- package/pg-core/table.js +0 -2
- package/pg-core/table.js.map +1 -1
- package/pg-proxy/driver.cjs +21 -5
- package/pg-proxy/driver.cjs.map +1 -1
- package/pg-proxy/driver.d.cts +3 -2
- package/pg-proxy/driver.d.ts +3 -2
- package/pg-proxy/driver.js +11 -8
- package/pg-proxy/driver.js.map +1 -1
- package/pg-proxy/migrator.cjs.map +1 -1
- package/pg-proxy/migrator.d.cts +2 -1
- package/pg-proxy/migrator.d.ts +2 -1
- package/pg-proxy/migrator.js.map +1 -1
- package/pg-proxy/session.cjs +37 -2
- package/pg-proxy/session.cjs.map +1 -1
- package/pg-proxy/session.d.cts +13 -8
- package/pg-proxy/session.d.ts +13 -8
- package/pg-proxy/session.js +37 -2
- package/pg-proxy/session.js.map +1 -1
- package/pglite/driver.cjs +23 -7
- package/pglite/driver.cjs.map +1 -1
- package/pglite/driver.d.cts +9 -8
- package/pglite/driver.d.ts +9 -8
- package/pglite/driver.js +13 -10
- package/pglite/driver.js.map +1 -1
- package/pglite/migrator.cjs.map +1 -1
- package/pglite/migrator.d.cts +2 -1
- package/pglite/migrator.d.ts +2 -1
- package/pglite/migrator.js.map +1 -1
- package/pglite/session.cjs +34 -3
- package/pglite/session.cjs.map +1 -1
- package/pglite/session.d.cts +13 -8
- package/pglite/session.d.ts +13 -8
- package/pglite/session.js +34 -3
- package/pglite/session.js.map +1 -1
- package/planetscale-serverless/driver.cjs +22 -5
- package/planetscale-serverless/driver.cjs.map +1 -1
- package/planetscale-serverless/driver.d.cts +7 -6
- package/planetscale-serverless/driver.d.ts +7 -6
- package/planetscale-serverless/driver.js +12 -8
- package/planetscale-serverless/driver.js.map +1 -1
- package/planetscale-serverless/migrator.cjs.map +1 -1
- package/planetscale-serverless/migrator.d.cts +2 -1
- package/planetscale-serverless/migrator.d.ts +2 -1
- package/planetscale-serverless/migrator.js.map +1 -1
- package/planetscale-serverless/session.cjs +45 -5
- package/planetscale-serverless/session.cjs.map +1 -1
- package/planetscale-serverless/session.d.cts +14 -9
- package/planetscale-serverless/session.d.ts +14 -9
- package/planetscale-serverless/session.js +45 -5
- package/planetscale-serverless/session.js.map +1 -1
- package/postgres-js/driver.cjs +6 -5
- package/postgres-js/driver.cjs.map +1 -1
- package/postgres-js/driver.d.cts +7 -6
- package/postgres-js/driver.d.ts +7 -6
- package/postgres-js/driver.js +6 -8
- package/postgres-js/driver.js.map +1 -1
- package/postgres-js/migrator.cjs.map +1 -1
- package/postgres-js/migrator.d.cts +2 -1
- package/postgres-js/migrator.d.ts +2 -1
- package/postgres-js/migrator.js.map +1 -1
- package/postgres-js/session.cjs +51 -6
- package/postgres-js/session.cjs.map +1 -1
- package/postgres-js/session.d.cts +15 -9
- package/postgres-js/session.d.ts +15 -9
- package/postgres-js/session.js +51 -6
- package/postgres-js/session.js.map +1 -1
- package/prisma/mysql/driver.cjs +1 -1
- package/prisma/mysql/driver.cjs.map +1 -1
- package/prisma/mysql/driver.js +1 -1
- package/prisma/mysql/driver.js.map +1 -1
- package/prisma/mysql/session.cjs +3 -0
- package/prisma/mysql/session.cjs.map +1 -1
- package/prisma/mysql/session.d.cts +3 -1
- package/prisma/mysql/session.d.ts +3 -1
- package/prisma/mysql/session.js +3 -0
- package/prisma/mysql/session.js.map +1 -1
- package/prisma/pg/driver.cjs +1 -1
- package/prisma/pg/driver.cjs.map +1 -1
- package/prisma/pg/driver.js +1 -1
- package/prisma/pg/driver.js.map +1 -1
- package/prisma/pg/session.cjs +3 -0
- package/prisma/pg/session.cjs.map +1 -1
- package/prisma/pg/session.d.cts +3 -1
- package/prisma/pg/session.d.ts +3 -1
- package/prisma/pg/session.js +3 -0
- package/prisma/pg/session.js.map +1 -1
- package/prisma/sqlite/driver.cjs +1 -1
- package/prisma/sqlite/driver.cjs.map +1 -1
- package/prisma/sqlite/driver.js +1 -1
- package/prisma/sqlite/driver.js.map +1 -1
- package/prisma/sqlite/session.cjs +3 -0
- package/prisma/sqlite/session.cjs.map +1 -1
- package/prisma/sqlite/session.d.cts +4 -2
- package/prisma/sqlite/session.d.ts +4 -2
- package/prisma/sqlite/session.js +3 -0
- package/prisma/sqlite/session.js.map +1 -1
- package/relations.cjs +626 -245
- package/relations.cjs.map +1 -1
- package/relations.d.cts +305 -140
- package/relations.d.ts +305 -140
- package/relations.js +619 -240
- package/relations.js.map +1 -1
- package/singlestore/driver.cjs +1 -1
- package/singlestore/driver.cjs.map +1 -1
- package/singlestore/driver.d.cts +1 -1
- package/singlestore/driver.d.ts +1 -1
- package/singlestore/driver.js +3 -3
- package/singlestore/driver.js.map +1 -1
- package/singlestore/session.cjs.map +1 -1
- package/singlestore/session.d.cts +4 -4
- package/singlestore/session.d.ts +4 -4
- package/singlestore/session.js.map +1 -1
- package/singlestore-core/db.cjs.map +1 -1
- package/singlestore-core/db.d.cts +3 -3
- package/singlestore-core/db.d.ts +3 -3
- package/singlestore-core/db.js.map +1 -1
- package/singlestore-core/dialect.cjs +16 -6
- package/singlestore-core/dialect.cjs.map +1 -1
- package/singlestore-core/dialect.d.cts +6 -6
- package/singlestore-core/dialect.d.ts +6 -6
- package/singlestore-core/dialect.js +6 -12
- package/singlestore-core/dialect.js.map +1 -1
- package/singlestore-core/query-builders/query.cjs +12 -2
- package/singlestore-core/query-builders/query.cjs.map +1 -1
- package/singlestore-core/query-builders/query.d.cts +6 -6
- package/singlestore-core/query-builders/query.d.ts +6 -6
- package/singlestore-core/query-builders/query.js +2 -4
- package/singlestore-core/query-builders/query.js.map +1 -1
- package/singlestore-core/session.cjs.map +1 -1
- package/singlestore-core/session.d.cts +5 -5
- package/singlestore-core/session.d.ts +5 -5
- package/singlestore-core/session.js.map +1 -1
- package/singlestore-proxy/driver.cjs +1 -1
- package/singlestore-proxy/driver.cjs.map +1 -1
- package/singlestore-proxy/driver.js +3 -3
- package/singlestore-proxy/driver.js.map +1 -1
- package/singlestore-proxy/session.cjs.map +1 -1
- package/singlestore-proxy/session.d.cts +4 -4
- package/singlestore-proxy/session.d.ts +4 -4
- package/singlestore-proxy/session.js.map +1 -1
- package/sql/expressions/conditions.cjs.map +1 -1
- package/sql/expressions/conditions.d.cts +4 -4
- package/sql/expressions/conditions.d.ts +4 -4
- package/sql/expressions/conditions.js.map +1 -1
- package/sql/sql.cjs +21 -0
- package/sql/sql.cjs.map +1 -1
- package/sql/sql.d.cts +8 -8
- package/sql/sql.d.ts +8 -8
- package/sql/sql.js +22 -1
- package/sql/sql.js.map +1 -1
- package/sql-js/driver.cjs +16 -5
- package/sql-js/driver.cjs.map +1 -1
- package/sql-js/driver.d.cts +3 -2
- package/sql-js/driver.d.ts +3 -2
- package/sql-js/driver.js +6 -8
- package/sql-js/driver.js.map +1 -1
- package/sql-js/migrator.cjs.map +1 -1
- package/sql-js/migrator.d.cts +2 -1
- package/sql-js/migrator.d.ts +2 -1
- package/sql-js/migrator.js.map +1 -1
- package/sql-js/session.cjs +71 -36
- package/sql-js/session.cjs.map +1 -1
- package/sql-js/session.d.cts +16 -13
- package/sql-js/session.d.ts +16 -13
- package/sql-js/session.js +71 -36
- package/sql-js/session.js.map +1 -1
- package/sqlite-core/db.cjs +39 -12
- package/sqlite-core/db.cjs.map +1 -1
- package/sqlite-core/db.d.cts +16 -8
- package/sqlite-core/db.d.ts +16 -8
- package/sqlite-core/db.js +38 -11
- package/sqlite-core/db.js.map +1 -1
- package/sqlite-core/dialect.cjs +176 -7
- package/sqlite-core/dialect.cjs.map +1 -1
- package/sqlite-core/dialect.d.cts +31 -9
- package/sqlite-core/dialect.d.ts +31 -9
- package/sqlite-core/dialect.js +174 -14
- package/sqlite-core/dialect.js.map +1 -1
- package/sqlite-core/query-builders/_query.cjs +187 -0
- package/sqlite-core/query-builders/_query.cjs.map +1 -0
- package/sqlite-core/query-builders/_query.d.cts +55 -0
- package/sqlite-core/query-builders/_query.d.ts +55 -0
- package/sqlite-core/query-builders/_query.js +151 -0
- package/sqlite-core/query-builders/_query.js.map +1 -0
- package/sqlite-core/query-builders/count.cjs.map +1 -1
- package/sqlite-core/query-builders/count.d.cts +1 -1
- package/sqlite-core/query-builders/count.d.ts +1 -1
- package/sqlite-core/query-builders/count.js.map +1 -1
- package/sqlite-core/query-builders/delete.cjs.map +1 -1
- package/sqlite-core/query-builders/delete.d.cts +1 -1
- package/sqlite-core/query-builders/delete.d.ts +1 -1
- package/sqlite-core/query-builders/delete.js.map +1 -1
- package/sqlite-core/query-builders/insert.cjs.map +1 -1
- package/sqlite-core/query-builders/insert.d.cts +3 -3
- package/sqlite-core/query-builders/insert.d.ts +3 -3
- package/sqlite-core/query-builders/insert.js.map +1 -1
- package/sqlite-core/query-builders/query.cjs +56 -35
- package/sqlite-core/query-builders/query.cjs.map +1 -1
- package/sqlite-core/query-builders/query.d.cts +18 -17
- package/sqlite-core/query-builders/query.d.ts +18 -17
- package/sqlite-core/query-builders/query.js +56 -35
- package/sqlite-core/query-builders/query.js.map +1 -1
- package/sqlite-core/query-builders/select.cjs.map +1 -1
- package/sqlite-core/query-builders/select.d.cts +3 -3
- package/sqlite-core/query-builders/select.d.ts +3 -3
- package/sqlite-core/query-builders/select.js.map +1 -1
- package/sqlite-core/query-builders/update.cjs.map +1 -1
- package/sqlite-core/query-builders/update.d.cts +3 -3
- package/sqlite-core/query-builders/update.d.ts +3 -3
- package/sqlite-core/query-builders/update.js.map +1 -1
- package/sqlite-core/session.cjs +6 -2
- package/sqlite-core/session.cjs.map +1 -1
- package/sqlite-core/session.d.cts +15 -7
- package/sqlite-core/session.d.ts +15 -7
- package/sqlite-core/session.js +6 -2
- package/sqlite-core/session.js.map +1 -1
- package/sqlite-proxy/driver.cjs +23 -5
- package/sqlite-proxy/driver.cjs.map +1 -1
- package/sqlite-proxy/driver.d.cts +4 -3
- package/sqlite-proxy/driver.d.ts +4 -3
- package/sqlite-proxy/driver.js +13 -5
- package/sqlite-proxy/driver.js.map +1 -1
- package/sqlite-proxy/migrator.cjs.map +1 -1
- package/sqlite-proxy/migrator.d.cts +2 -1
- package/sqlite-proxy/migrator.d.ts +2 -1
- package/sqlite-proxy/migrator.js.map +1 -1
- package/sqlite-proxy/session.cjs +50 -6
- package/sqlite-proxy/session.cjs.map +1 -1
- package/sqlite-proxy/session.d.cts +14 -8
- package/sqlite-proxy/session.d.ts +14 -8
- package/sqlite-proxy/session.js +50 -6
- package/sqlite-proxy/session.js.map +1 -1
- package/table.cjs.map +1 -1
- package/table.d.cts +2 -2
- package/table.d.ts +2 -2
- package/table.js.map +1 -1
- package/tidb-serverless/driver.cjs +22 -5
- package/tidb-serverless/driver.cjs.map +1 -1
- package/tidb-serverless/driver.d.cts +7 -6
- package/tidb-serverless/driver.d.ts +7 -6
- package/tidb-serverless/driver.js +12 -8
- package/tidb-serverless/driver.js.map +1 -1
- package/tidb-serverless/migrator.cjs.map +1 -1
- package/tidb-serverless/migrator.d.cts +2 -1
- package/tidb-serverless/migrator.d.ts +2 -1
- package/tidb-serverless/migrator.js.map +1 -1
- package/tidb-serverless/session.cjs +62 -5
- package/tidb-serverless/session.cjs.map +1 -1
- package/tidb-serverless/session.d.cts +14 -9
- package/tidb-serverless/session.d.ts +14 -9
- package/tidb-serverless/session.js +62 -5
- package/tidb-serverless/session.js.map +1 -1
- package/utils.cjs +2 -2
- package/utils.cjs.map +1 -1
- package/utils.d.cts +3 -1
- package/utils.d.ts +3 -1
- package/utils.js +2 -2
- package/utils.js.map +1 -1
- package/vercel-postgres/driver.cjs +23 -7
- package/vercel-postgres/driver.cjs.map +1 -1
- package/vercel-postgres/driver.d.cts +9 -8
- package/vercel-postgres/driver.d.ts +9 -8
- package/vercel-postgres/driver.js +13 -10
- package/vercel-postgres/driver.js.map +1 -1
- package/vercel-postgres/migrator.cjs.map +1 -1
- package/vercel-postgres/migrator.d.cts +2 -1
- package/vercel-postgres/migrator.d.ts +2 -1
- package/vercel-postgres/migrator.js.map +1 -1
- package/vercel-postgres/session.cjs +34 -4
- package/vercel-postgres/session.cjs.map +1 -1
- package/vercel-postgres/session.d.cts +13 -8
- package/vercel-postgres/session.d.ts +13 -8
- package/vercel-postgres/session.js +34 -4
- package/vercel-postgres/session.js.map +1 -1
- package/version.cjs +1 -1
- package/version.d.cts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/xata-http/driver.cjs +17 -5
- package/xata-http/driver.cjs.map +1 -1
- package/xata-http/driver.d.cts +5 -4
- package/xata-http/driver.d.ts +5 -4
- package/xata-http/driver.js +7 -5
- package/xata-http/driver.js.map +1 -1
- package/xata-http/migrator.cjs.map +1 -1
- package/xata-http/migrator.d.cts +2 -1
- package/xata-http/migrator.d.ts +2 -1
- package/xata-http/migrator.js.map +1 -1
- package/xata-http/session.cjs +30 -2
- package/xata-http/session.cjs.map +1 -1
- package/xata-http/session.d.cts +13 -8
- package/xata-http/session.d.ts +13 -8
- package/xata-http/session.js +30 -2
- package/xata-http/session.js.map +1 -1
- package/gel/driver.cjs +0 -97
- package/gel/driver.cjs.map +0 -1
- package/gel/driver.d.cts +0 -38
- package/gel/driver.d.ts +0 -38
- package/gel/driver.js +0 -74
- package/gel/driver.js.map +0 -1
- package/gel/index.cjs +0 -25
- package/gel/index.cjs.map +0 -1
- package/gel/index.d.cts +0 -2
- package/gel/index.d.ts +0 -2
- package/gel/index.js +0 -3
- package/gel/index.js.map +0 -1
- package/gel/migrator.cjs +0 -5
- package/gel/migrator.cjs.map +0 -1
- package/gel/migrator.d.cts +0 -1
- package/gel/migrator.d.ts +0 -1
- package/gel/migrator.js +0 -4
- package/gel/migrator.js.map +0 -1
- package/gel/session.cjs +0 -139
- package/gel/session.cjs.map +0 -1
- package/gel/session.d.cts +0 -47
- package/gel/session.d.ts +0 -47
- package/gel/session.js +0 -113
- package/gel/session.js.map +0 -1
- package/gel-core/alias.cjs +0 -32
- package/gel-core/alias.cjs.map +0 -1
- package/gel-core/alias.d.cts +0 -4
- package/gel-core/alias.d.ts +0 -4
- package/gel-core/alias.js +0 -8
- package/gel-core/alias.js.map +0 -1
- package/gel-core/checks.cjs +0 -58
- package/gel-core/checks.cjs.map +0 -1
- package/gel-core/checks.d.cts +0 -18
- package/gel-core/checks.d.ts +0 -18
- package/gel-core/checks.js +0 -32
- package/gel-core/checks.js.map +0 -1
- package/gel-core/columns/all.cjs +0 -72
- package/gel-core/columns/all.cjs.map +0 -1
- package/gel-core/columns/all.d.cts +0 -43
- package/gel-core/columns/all.d.ts +0 -43
- package/gel-core/columns/all.js +0 -48
- package/gel-core/columns/all.js.map +0 -1
- package/gel-core/columns/bigint.cjs +0 -54
- package/gel-core/columns/bigint.cjs.map +0 -1
- package/gel-core/columns/bigint.d.cts +0 -23
- package/gel-core/columns/bigint.d.ts +0 -23
- package/gel-core/columns/bigint.js +0 -28
- package/gel-core/columns/bigint.js.map +0 -1
- package/gel-core/columns/bigintT.cjs +0 -60
- package/gel-core/columns/bigintT.cjs.map +0 -1
- package/gel-core/columns/bigintT.d.cts +0 -24
- package/gel-core/columns/bigintT.d.ts +0 -24
- package/gel-core/columns/bigintT.js +0 -34
- package/gel-core/columns/bigintT.js.map +0 -1
- package/gel-core/columns/boolean.cjs +0 -53
- package/gel-core/columns/boolean.cjs.map +0 -1
- package/gel-core/columns/boolean.d.cts +0 -22
- package/gel-core/columns/boolean.d.ts +0 -22
- package/gel-core/columns/boolean.js +0 -27
- package/gel-core/columns/boolean.js.map +0 -1
- package/gel-core/columns/bytes.cjs +0 -56
- package/gel-core/columns/bytes.cjs.map +0 -1
- package/gel-core/columns/bytes.d.cts +0 -22
- package/gel-core/columns/bytes.d.ts +0 -22
- package/gel-core/columns/bytes.js +0 -30
- package/gel-core/columns/bytes.js.map +0 -1
- package/gel-core/columns/common.cjs +0 -213
- package/gel-core/columns/common.cjs.map +0 -1
- package/gel-core/columns/common.d.cts +0 -147
- package/gel-core/columns/common.d.ts +0 -147
- package/gel-core/columns/common.js +0 -184
- package/gel-core/columns/common.js.map +0 -1
- package/gel-core/columns/custom.cjs +0 -77
- package/gel-core/columns/custom.cjs.map +0 -1
- package/gel-core/columns/custom.d.cts +0 -155
- package/gel-core/columns/custom.d.ts +0 -155
- package/gel-core/columns/custom.js +0 -51
- package/gel-core/columns/custom.js.map +0 -1
- package/gel-core/columns/date-duration.cjs +0 -56
- package/gel-core/columns/date-duration.cjs.map +0 -1
- package/gel-core/columns/date-duration.d.cts +0 -23
- package/gel-core/columns/date-duration.d.ts +0 -23
- package/gel-core/columns/date-duration.js +0 -30
- package/gel-core/columns/date-duration.js.map +0 -1
- package/gel-core/columns/date.common.cjs +0 -37
- package/gel-core/columns/date.common.cjs.map +0 -1
- package/gel-core/columns/date.common.d.cts +0 -7
- package/gel-core/columns/date.common.d.ts +0 -7
- package/gel-core/columns/date.common.js +0 -13
- package/gel-core/columns/date.common.js.map +0 -1
- package/gel-core/columns/decimal.cjs +0 -56
- package/gel-core/columns/decimal.cjs.map +0 -1
- package/gel-core/columns/decimal.d.cts +0 -26
- package/gel-core/columns/decimal.d.ts +0 -26
- package/gel-core/columns/decimal.js +0 -30
- package/gel-core/columns/decimal.js.map +0 -1
- package/gel-core/columns/double-precision.cjs +0 -62
- package/gel-core/columns/double-precision.cjs.map +0 -1
- package/gel-core/columns/double-precision.d.cts +0 -23
- package/gel-core/columns/double-precision.d.ts +0 -23
- package/gel-core/columns/double-precision.js +0 -36
- package/gel-core/columns/double-precision.js.map +0 -1
- package/gel-core/columns/duration.cjs +0 -53
- package/gel-core/columns/duration.cjs.map +0 -1
- package/gel-core/columns/duration.d.cts +0 -23
- package/gel-core/columns/duration.d.ts +0 -23
- package/gel-core/columns/duration.js +0 -27
- package/gel-core/columns/duration.js.map +0 -1
- package/gel-core/columns/index.cjs +0 -65
- package/gel-core/columns/index.cjs.map +0 -1
- package/gel-core/columns/index.d.cts +0 -22
- package/gel-core/columns/index.d.ts +0 -22
- package/gel-core/columns/index.js +0 -23
- package/gel-core/columns/index.js.map +0 -1
- package/gel-core/columns/int.common.cjs +0 -67
- package/gel-core/columns/int.common.cjs.map +0 -1
- package/gel-core/columns/int.common.d.cts +0 -15
- package/gel-core/columns/int.common.d.ts +0 -15
- package/gel-core/columns/int.common.js +0 -43
- package/gel-core/columns/int.common.js.map +0 -1
- package/gel-core/columns/integer.cjs +0 -54
- package/gel-core/columns/integer.cjs.map +0 -1
- package/gel-core/columns/integer.d.cts +0 -23
- package/gel-core/columns/integer.d.ts +0 -23
- package/gel-core/columns/integer.js +0 -28
- package/gel-core/columns/integer.js.map +0 -1
- package/gel-core/columns/json.cjs +0 -56
- package/gel-core/columns/json.cjs.map +0 -1
- package/gel-core/columns/json.d.cts +0 -26
- package/gel-core/columns/json.d.ts +0 -26
- package/gel-core/columns/json.js +0 -30
- package/gel-core/columns/json.js.map +0 -1
- package/gel-core/columns/localdate.cjs +0 -57
- package/gel-core/columns/localdate.cjs.map +0 -1
- package/gel-core/columns/localdate.d.cts +0 -24
- package/gel-core/columns/localdate.d.ts +0 -24
- package/gel-core/columns/localdate.js +0 -31
- package/gel-core/columns/localdate.js.map +0 -1
- package/gel-core/columns/localtime.cjs +0 -57
- package/gel-core/columns/localtime.cjs.map +0 -1
- package/gel-core/columns/localtime.d.cts +0 -24
- package/gel-core/columns/localtime.d.ts +0 -24
- package/gel-core/columns/localtime.js +0 -31
- package/gel-core/columns/localtime.js.map +0 -1
- package/gel-core/columns/real.cjs +0 -57
- package/gel-core/columns/real.cjs.map +0 -1
- package/gel-core/columns/real.d.cts +0 -28
- package/gel-core/columns/real.d.ts +0 -28
- package/gel-core/columns/real.js +0 -31
- package/gel-core/columns/real.js.map +0 -1
- package/gel-core/columns/relative-duration.cjs +0 -56
- package/gel-core/columns/relative-duration.cjs.map +0 -1
- package/gel-core/columns/relative-duration.d.cts +0 -23
- package/gel-core/columns/relative-duration.d.ts +0 -23
- package/gel-core/columns/relative-duration.js +0 -30
- package/gel-core/columns/relative-duration.js.map +0 -1
- package/gel-core/columns/smallint.cjs +0 -54
- package/gel-core/columns/smallint.cjs.map +0 -1
- package/gel-core/columns/smallint.d.cts +0 -23
- package/gel-core/columns/smallint.d.ts +0 -23
- package/gel-core/columns/smallint.js +0 -28
- package/gel-core/columns/smallint.js.map +0 -1
- package/gel-core/columns/text.cjs +0 -54
- package/gel-core/columns/text.cjs.map +0 -1
- package/gel-core/columns/text.d.cts +0 -26
- package/gel-core/columns/text.d.ts +0 -26
- package/gel-core/columns/text.js +0 -28
- package/gel-core/columns/text.js.map +0 -1
- package/gel-core/columns/timestamp.cjs +0 -60
- package/gel-core/columns/timestamp.cjs.map +0 -1
- package/gel-core/columns/timestamp.d.cts +0 -28
- package/gel-core/columns/timestamp.d.ts +0 -28
- package/gel-core/columns/timestamp.js +0 -34
- package/gel-core/columns/timestamp.js.map +0 -1
- package/gel-core/columns/timestamptz.cjs +0 -60
- package/gel-core/columns/timestamptz.cjs.map +0 -1
- package/gel-core/columns/timestamptz.d.cts +0 -27
- package/gel-core/columns/timestamptz.d.ts +0 -27
- package/gel-core/columns/timestamptz.js +0 -34
- package/gel-core/columns/timestamptz.js.map +0 -1
- package/gel-core/columns/uuid.cjs +0 -53
- package/gel-core/columns/uuid.cjs.map +0 -1
- package/gel-core/columns/uuid.d.cts +0 -22
- package/gel-core/columns/uuid.d.ts +0 -22
- package/gel-core/columns/uuid.js +0 -27
- package/gel-core/columns/uuid.js.map +0 -1
- package/gel-core/db.cjs +0 -338
- package/gel-core/db.cjs.map +0 -1
- package/gel-core/db.d.cts +0 -281
- package/gel-core/db.d.ts +0 -281
- package/gel-core/db.js +0 -319
- package/gel-core/db.js.map +0 -1
- package/gel-core/dialect.cjs +0 -1142
- package/gel-core/dialect.cjs.map +0 -1
- package/gel-core/dialect.d.cts +0 -62
- package/gel-core/dialect.d.ts +0 -62
- package/gel-core/dialect.js +0 -1128
- package/gel-core/dialect.js.map +0 -1
- package/gel-core/expressions.cjs +0 -49
- package/gel-core/expressions.cjs.map +0 -1
- package/gel-core/expressions.d.cts +0 -8
- package/gel-core/expressions.d.ts +0 -8
- package/gel-core/expressions.js +0 -22
- package/gel-core/expressions.js.map +0 -1
- package/gel-core/foreign-keys.cjs +0 -100
- package/gel-core/foreign-keys.cjs.map +0 -1
- package/gel-core/foreign-keys.d.cts +0 -48
- package/gel-core/foreign-keys.d.ts +0 -48
- package/gel-core/foreign-keys.js +0 -74
- package/gel-core/foreign-keys.js.map +0 -1
- package/gel-core/index.cjs +0 -61
- package/gel-core/index.cjs.map +0 -1
- package/gel-core/index.d.cts +0 -20
- package/gel-core/index.d.ts +0 -20
- package/gel-core/index.js +0 -21
- package/gel-core/index.js.map +0 -1
- package/gel-core/indexes.cjs +0 -149
- package/gel-core/indexes.cjs.map +0 -1
- package/gel-core/indexes.d.cts +0 -79
- package/gel-core/indexes.d.ts +0 -79
- package/gel-core/indexes.js +0 -121
- package/gel-core/indexes.js.map +0 -1
- package/gel-core/policies.cjs +0 -58
- package/gel-core/policies.cjs.map +0 -1
- package/gel-core/policies.d.cts +0 -24
- package/gel-core/policies.d.ts +0 -24
- package/gel-core/policies.js +0 -33
- package/gel-core/policies.js.map +0 -1
- package/gel-core/primary-keys.cjs +0 -68
- package/gel-core/primary-keys.cjs.map +0 -1
- package/gel-core/primary-keys.d.cts +0 -30
- package/gel-core/primary-keys.d.ts +0 -30
- package/gel-core/primary-keys.js +0 -42
- package/gel-core/primary-keys.js.map +0 -1
- package/gel-core/query-builders/count.cjs +0 -73
- package/gel-core/query-builders/count.cjs.map +0 -1
- package/gel-core/query-builders/count.d.cts +0 -25
- package/gel-core/query-builders/count.d.ts +0 -25
- package/gel-core/query-builders/count.js +0 -49
- package/gel-core/query-builders/count.js.map +0 -1
- package/gel-core/query-builders/delete.cjs +0 -105
- package/gel-core/query-builders/delete.cjs.map +0 -1
- package/gel-core/query-builders/delete.d.cts +0 -99
- package/gel-core/query-builders/delete.d.ts +0 -99
- package/gel-core/query-builders/delete.js +0 -81
- package/gel-core/query-builders/delete.js.map +0 -1
- package/gel-core/query-builders/index.cjs +0 -35
- package/gel-core/query-builders/index.cjs.map +0 -1
- package/gel-core/query-builders/index.d.cts +0 -7
- package/gel-core/query-builders/index.d.ts +0 -7
- package/gel-core/query-builders/index.js +0 -8
- package/gel-core/query-builders/index.js.map +0 -1
- package/gel-core/query-builders/insert.cjs +0 -218
- package/gel-core/query-builders/insert.cjs.map +0 -1
- package/gel-core/query-builders/insert.d.cts +0 -116
- package/gel-core/query-builders/insert.d.ts +0 -116
- package/gel-core/query-builders/insert.js +0 -193
- package/gel-core/query-builders/insert.js.map +0 -1
- package/gel-core/query-builders/query-builder.cjs +0 -114
- package/gel-core/query-builders/query-builder.cjs.map +0 -1
- package/gel-core/query-builders/query-builder.d.cts +0 -40
- package/gel-core/query-builders/query-builder.d.ts +0 -40
- package/gel-core/query-builders/query-builder.js +0 -90
- package/gel-core/query-builders/query-builder.js.map +0 -1
- package/gel-core/query-builders/query.cjs.map +0 -1
- package/gel-core/query-builders/query.d.cts +0 -46
- package/gel-core/query-builders/query.d.ts +0 -46
- package/gel-core/query-builders/query.js.map +0 -1
- package/gel-core/query-builders/raw.cjs +0 -57
- package/gel-core/query-builders/raw.cjs.map +0 -1
- package/gel-core/query-builders/raw.d.cts +0 -22
- package/gel-core/query-builders/raw.d.ts +0 -22
- package/gel-core/query-builders/raw.js +0 -33
- package/gel-core/query-builders/raw.js.map +0 -1
- package/gel-core/query-builders/refresh-materialized-view.cjs +0 -77
- package/gel-core/query-builders/refresh-materialized-view.cjs.map +0 -1
- package/gel-core/query-builders/refresh-materialized-view.d.cts +0 -27
- package/gel-core/query-builders/refresh-materialized-view.d.ts +0 -27
- package/gel-core/query-builders/refresh-materialized-view.js +0 -53
- package/gel-core/query-builders/refresh-materialized-view.js.map +0 -1
- package/gel-core/query-builders/select.cjs +0 -775
- package/gel-core/query-builders/select.cjs.map +0 -1
- package/gel-core/query-builders/select.d.cts +0 -721
- package/gel-core/query-builders/select.d.ts +0 -721
- package/gel-core/query-builders/select.js +0 -748
- package/gel-core/query-builders/select.js.map +0 -1
- package/gel-core/query-builders/select.types.cjs +0 -17
- package/gel-core/query-builders/select.types.cjs.map +0 -1
- package/gel-core/query-builders/select.types.d.cts +0 -138
- package/gel-core/query-builders/select.types.d.ts +0 -138
- package/gel-core/query-builders/select.types.js +0 -1
- package/gel-core/query-builders/select.types.js.map +0 -1
- package/gel-core/query-builders/update.cjs +0 -226
- package/gel-core/query-builders/update.cjs.map +0 -1
- package/gel-core/query-builders/update.d.cts +0 -166
- package/gel-core/query-builders/update.d.ts +0 -166
- package/gel-core/query-builders/update.js +0 -205
- package/gel-core/query-builders/update.js.map +0 -1
- package/gel-core/roles.cjs +0 -57
- package/gel-core/roles.cjs.map +0 -1
- package/gel-core/roles.d.cts +0 -13
- package/gel-core/roles.d.ts +0 -13
- package/gel-core/roles.js +0 -32
- package/gel-core/roles.js.map +0 -1
- package/gel-core/schema.cjs +0 -74
- package/gel-core/schema.cjs.map +0 -1
- package/gel-core/schema.d.cts +0 -15
- package/gel-core/schema.d.ts +0 -15
- package/gel-core/schema.js +0 -48
- package/gel-core/schema.js.map +0 -1
- package/gel-core/sequence.cjs +0 -52
- package/gel-core/sequence.cjs.map +0 -1
- package/gel-core/sequence.d.cts +0 -18
- package/gel-core/sequence.d.ts +0 -18
- package/gel-core/sequence.js +0 -25
- package/gel-core/sequence.js.map +0 -1
- package/gel-core/session.cjs +0 -94
- package/gel-core/session.cjs.map +0 -1
- package/gel-core/session.d.cts +0 -56
- package/gel-core/session.d.ts +0 -56
- package/gel-core/session.js +0 -68
- package/gel-core/session.js.map +0 -1
- package/gel-core/subquery.cjs +0 -17
- package/gel-core/subquery.cjs.map +0 -1
- package/gel-core/subquery.d.cts +0 -5
- package/gel-core/subquery.d.ts +0 -5
- package/gel-core/subquery.js +0 -1
- package/gel-core/subquery.js.map +0 -1
- package/gel-core/table.cjs +0 -100
- package/gel-core/table.cjs.map +0 -1
- package/gel-core/table.d.cts +0 -95
- package/gel-core/table.d.ts +0 -95
- package/gel-core/table.js +0 -71
- package/gel-core/table.js.map +0 -1
- package/gel-core/unique-constraint.cjs +0 -89
- package/gel-core/unique-constraint.cjs.map +0 -1
- package/gel-core/unique-constraint.d.cts +0 -25
- package/gel-core/unique-constraint.d.ts +0 -25
- package/gel-core/unique-constraint.js +0 -61
- package/gel-core/unique-constraint.js.map +0 -1
- package/gel-core/utils.cjs +0 -100
- package/gel-core/utils.cjs.map +0 -1
- package/gel-core/utils.d.cts +0 -51
- package/gel-core/utils.d.ts +0 -51
- package/gel-core/utils.js +0 -74
- package/gel-core/utils.js.map +0 -1
- package/gel-core/view-base.cjs +0 -33
- package/gel-core/view-base.cjs.map +0 -1
- package/gel-core/view-base.d.cts +0 -8
- package/gel-core/view-base.d.ts +0 -8
- package/gel-core/view-base.js +0 -9
- package/gel-core/view-base.js.map +0 -1
- package/gel-core/view-common.cjs +0 -29
- package/gel-core/view-common.cjs.map +0 -1
- package/gel-core/view-common.d.cts +0 -1
- package/gel-core/view-common.d.ts +0 -1
- package/gel-core/view-common.js +0 -5
- package/gel-core/view-common.js.map +0 -1
- package/gel-core/view.cjs +0 -302
- package/gel-core/view.cjs.map +0 -1
- package/gel-core/view.d.cts +0 -150
- package/gel-core/view.d.ts +0 -150
- package/gel-core/view.js +0 -268
- package/gel-core/view.js.map +0 -1
package/pglite/session.cjs
CHANGED
|
@@ -31,7 +31,7 @@ var import_sql = require("../sql/sql.cjs");
|
|
|
31
31
|
var import_utils = require("../utils.cjs");
|
|
32
32
|
var import_pglite = require("@electric-sql/pglite");
|
|
33
33
|
class PglitePreparedQuery extends import_session.PgPreparedQuery {
|
|
34
|
-
constructor(client, queryString, params, logger, fields, name, _isResponseInArrayMode, customResultMapper) {
|
|
34
|
+
constructor(client, queryString, params, logger, fields, name, _isResponseInArrayMode, customResultMapper, isRqbV2Query) {
|
|
35
35
|
super({ sql: queryString, params });
|
|
36
36
|
this.client = client;
|
|
37
37
|
this.queryString = queryString;
|
|
@@ -40,6 +40,7 @@ class PglitePreparedQuery extends import_session.PgPreparedQuery {
|
|
|
40
40
|
this.fields = fields;
|
|
41
41
|
this._isResponseInArrayMode = _isResponseInArrayMode;
|
|
42
42
|
this.customResultMapper = customResultMapper;
|
|
43
|
+
this.isRqbV2Query = isRqbV2Query;
|
|
43
44
|
this.rawQueryConfig = {
|
|
44
45
|
rowMode: "object",
|
|
45
46
|
parsers: {
|
|
@@ -63,6 +64,8 @@ class PglitePreparedQuery extends import_session.PgPreparedQuery {
|
|
|
63
64
|
rawQueryConfig;
|
|
64
65
|
queryConfig;
|
|
65
66
|
async execute(placeholderValues = {}) {
|
|
67
|
+
if (this.isRqbV2Query)
|
|
68
|
+
return this.executeRqbV2(placeholderValues);
|
|
66
69
|
const params = (0, import_sql.fillPlaceholders)(this.params, placeholderValues);
|
|
67
70
|
this.logger.logQuery(this.queryString, params);
|
|
68
71
|
const { fields, rawQueryConfig, client, queryConfig, joinsNotNullableMap, customResultMapper, queryString } = this;
|
|
@@ -72,6 +75,13 @@ class PglitePreparedQuery extends import_session.PgPreparedQuery {
|
|
|
72
75
|
const result = await client.query(queryString, params, queryConfig);
|
|
73
76
|
return customResultMapper ? customResultMapper(result.rows) : result.rows.map((row) => (0, import_utils.mapResultRow)(fields, row, joinsNotNullableMap));
|
|
74
77
|
}
|
|
78
|
+
async executeRqbV2(placeholderValues = {}) {
|
|
79
|
+
const params = (0, import_sql.fillPlaceholders)(this.params, placeholderValues);
|
|
80
|
+
this.logger.logQuery(this.queryString, params);
|
|
81
|
+
const { rawQueryConfig, client, customResultMapper, queryString } = this;
|
|
82
|
+
const result = await client.query(queryString, params, rawQueryConfig);
|
|
83
|
+
return customResultMapper(result.rows);
|
|
84
|
+
}
|
|
75
85
|
all(placeholderValues = {}) {
|
|
76
86
|
const params = (0, import_sql.fillPlaceholders)(this.params, placeholderValues);
|
|
77
87
|
this.logger.logQuery(this.queryString, params);
|
|
@@ -83,9 +93,10 @@ class PglitePreparedQuery extends import_session.PgPreparedQuery {
|
|
|
83
93
|
}
|
|
84
94
|
}
|
|
85
95
|
class PgliteSession extends import_session.PgSession {
|
|
86
|
-
constructor(client, dialect, schema, options = {}) {
|
|
96
|
+
constructor(client, dialect, relations, schema, options = {}) {
|
|
87
97
|
super(dialect);
|
|
88
98
|
this.client = client;
|
|
99
|
+
this.relations = relations;
|
|
89
100
|
this.schema = schema;
|
|
90
101
|
this.options = options;
|
|
91
102
|
this.logger = options.logger ?? new import_logger.NoopLogger();
|
|
@@ -104,15 +115,34 @@ class PgliteSession extends import_session.PgSession {
|
|
|
104
115
|
customResultMapper
|
|
105
116
|
);
|
|
106
117
|
}
|
|
118
|
+
prepareRelationalQuery(query, fields, name, customResultMapper) {
|
|
119
|
+
return new PglitePreparedQuery(
|
|
120
|
+
this.client,
|
|
121
|
+
query.sql,
|
|
122
|
+
query.params,
|
|
123
|
+
this.logger,
|
|
124
|
+
fields,
|
|
125
|
+
name,
|
|
126
|
+
false,
|
|
127
|
+
customResultMapper,
|
|
128
|
+
true
|
|
129
|
+
);
|
|
130
|
+
}
|
|
107
131
|
async transaction(transaction, config) {
|
|
108
132
|
return this.client.transaction(async (client) => {
|
|
109
133
|
const session = new PgliteSession(
|
|
110
134
|
client,
|
|
111
135
|
this.dialect,
|
|
136
|
+
this.relations,
|
|
112
137
|
this.schema,
|
|
113
138
|
this.options
|
|
114
139
|
);
|
|
115
|
-
const tx = new PgliteTransaction(
|
|
140
|
+
const tx = new PgliteTransaction(
|
|
141
|
+
this.dialect,
|
|
142
|
+
session,
|
|
143
|
+
this.relations,
|
|
144
|
+
this.schema
|
|
145
|
+
);
|
|
116
146
|
if (config) {
|
|
117
147
|
await tx.setTransaction(config);
|
|
118
148
|
}
|
|
@@ -133,6 +163,7 @@ class PgliteTransaction extends import_pg_core.PgTransaction {
|
|
|
133
163
|
const tx = new PgliteTransaction(
|
|
134
164
|
this.dialect,
|
|
135
165
|
this.session,
|
|
166
|
+
this.relations,
|
|
136
167
|
this.schema,
|
|
137
168
|
this.nestedIndex + 1
|
|
138
169
|
);
|
package/pglite/session.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/pglite/session.ts"],"sourcesContent":["import type { PGlite, QueryOptions, Results, Row, Transaction } from '@electric-sql/pglite';\nimport { entityKind } from '~/entity.ts';\nimport { type Logger, 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\nimport { types } from '@electric-sql/pglite';\n\nexport type PgliteClient = PGlite;\n\nexport class PglitePreparedQuery<T extends PreparedQueryConfig> extends PgPreparedQuery<T> {\n\tstatic override readonly [entityKind]: string = 'PglitePreparedQuery';\n\n\tprivate rawQueryConfig: QueryOptions;\n\tprivate queryConfig: QueryOptions;\n\n\tconstructor(\n\t\tprivate client: PgliteClient | Transaction,\n\t\tprivate queryString: 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\trowMode: 'object',\n\t\t\tparsers: {\n\t\t\t\t[types.TIMESTAMP]: (value) => value,\n\t\t\t\t[types.TIMESTAMPTZ]: (value) => value,\n\t\t\t\t[types.INTERVAL]: (value) => value,\n\t\t\t\t[types.DATE]: (value) => value,\n\t\t\t},\n\t\t};\n\t\tthis.queryConfig = {\n\t\t\trowMode: 'array',\n\t\t\tparsers: {\n\t\t\t\t[types.TIMESTAMP]: (value) => value,\n\t\t\t\t[types.TIMESTAMPTZ]: (value) => value,\n\t\t\t\t[types.INTERVAL]: (value) => value,\n\t\t\t\t[types.DATE]: (value) => value,\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.queryString, params);\n\n\t\tconst { fields, rawQueryConfig, client, queryConfig, joinsNotNullableMap, customResultMapper, queryString } = this;\n\n\t\tif (!fields && !customResultMapper) {\n\t\t\treturn client.query<any[]>(queryString, params, rawQueryConfig);\n\t\t}\n\n\t\tconst result = await client.query<any[][]>(queryString, params, queryConfig);\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.queryString, params);\n\t\treturn this.client.query(this.queryString, params, this.rawQueryConfig).then((result) => result.rows);\n\t}\n\n\t/** @internal */\n\tisResponseInArrayMode(): boolean {\n\t\treturn this._isResponseInArrayMode;\n\t}\n}\n\nexport interface PgliteSessionOptions {\n\tlogger?: Logger;\n}\n\nexport class PgliteSession<\n\tTFullSchema extends Record<string, unknown>,\n\tTSchema extends TablesRelationalConfig,\n> extends PgSession<PgliteQueryResultHKT, TFullSchema, TSchema> {\n\tstatic override readonly [entityKind]: string = 'PgliteSession';\n\n\tprivate logger: Logger;\n\n\tconstructor(\n\t\tprivate client: PgliteClient | Transaction,\n\t\tdialect: PgDialect,\n\t\tprivate schema: RelationalSchemaConfig<TSchema> | undefined,\n\t\tprivate options: PgliteSessionOptions = {},\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 PglitePreparedQuery(\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\toverride async transaction<T>(\n\t\ttransaction: (tx: PgliteTransaction<TFullSchema, TSchema>) => Promise<T>,\n\t\tconfig?: PgTransactionConfig | undefined,\n\t): Promise<T> {\n\t\treturn (this.client as PgliteClient).transaction(async (client) => {\n\t\t\tconst session = new PgliteSession<TFullSchema, TSchema>(\n\t\t\t\tclient,\n\t\t\t\tthis.dialect,\n\t\t\t\tthis.schema,\n\t\t\t\tthis.options,\n\t\t\t);\n\t\t\tconst tx = new PgliteTransaction<TFullSchema, TSchema>(this.dialect, session, this.schema);\n\t\t\tif (config) {\n\t\t\t\tawait tx.setTransaction(config);\n\t\t\t}\n\t\t\treturn transaction(tx);\n\t\t}) as Promise<T>;\n\t}\n\n\toverride async count(sql: SQL): Promise<number> {\n\t\tconst res = await this.execute<{ rows: [{ count: string }] }>(sql);\n\t\treturn Number(\n\t\t\tres['rows'][0]['count'],\n\t\t);\n\t}\n}\n\nexport class PgliteTransaction<\n\tTFullSchema extends Record<string, unknown>,\n\tTSchema extends TablesRelationalConfig,\n> extends PgTransaction<PgliteQueryResultHKT, TFullSchema, TSchema> {\n\tstatic override readonly [entityKind]: string = 'PgliteTransaction';\n\n\toverride async transaction<T>(transaction: (tx: PgliteTransaction<TFullSchema, TSchema>) => Promise<T>): Promise<T> {\n\t\tconst savepointName = `sp${this.nestedIndex + 1}`;\n\t\tconst tx = new PgliteTransaction<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 PgliteQueryResultHKT extends PgQueryResultHKT {\n\ttype: Results<Assume<this['row'], Row>>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAA2B;AAC3B,oBAAwC;AAExC,qBAA8B;AAG9B,qBAA2C;AAE3C,iBAA4D;AAC5D,mBAA0C;AAE1C,oBAAsB;AAIf,MAAM,4BAA2D,+BAAmB;AAAA,EAM1F,YACS,QACA,aACA,QACA,QACA,QACR,MACQ,wBACA,oBACP;AACD,UAAM,EAAE,KAAK,aAAa,OAAO,CAAC;AAT1B;AACA;AACA;AACA;AACA;AAEA;AAC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AAK,cAAc,CAAC;AAC/C,UAAM,KAAK,IAAI;AAAA,MACd,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK,cAAc;AAAA,IACpB;AACA,UAAM,GAAG,QAAQ,eAAI,IAAI,aAAa,aAAa,EAAE,CAAC;AACtD,QAAI;AACH,YAAM,SAAS,MAAM,YAAY,EAAE;AACnC,YAAM,GAAG,QAAQ,eAAI,IAAI,qBAAqB,aAAa,EAAE,CAAC;AAC9D,aAAO;AAAA,IACR,SAAS,KAAK;AACb,YAAM,GAAG,QAAQ,eAAI,IAAI,yBAAyB,aAAa,EAAE,CAAC;AAClE,YAAM;AAAA,IACP;AAAA,EACD;AACD;","names":["sql"]}
|
|
1
|
+
{"version":3,"sources":["../../src/pglite/session.ts"],"sourcesContent":["import type { PGlite, QueryOptions, Results, Row, Transaction } from '@electric-sql/pglite';\nimport type * as V1 from '~/_relations.ts';\nimport { entityKind } from '~/entity.ts';\nimport { type Logger, 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 { fillPlaceholders, type Query, type SQL, sql } from '~/sql/sql.ts';\nimport { type Assume, mapResultRow } from '~/utils.ts';\n\nimport { types } from '@electric-sql/pglite';\nimport type { AnyRelations, TablesRelationalConfig } from '~/relations.ts';\n\nexport type PgliteClient = PGlite;\n\nexport class PglitePreparedQuery<T extends PreparedQueryConfig, TIsRqbV2 extends boolean = false>\n\textends PgPreparedQuery<T>\n{\n\tstatic override readonly [entityKind]: string = 'PglitePreparedQuery';\n\n\tprivate rawQueryConfig: QueryOptions;\n\tprivate queryConfig: QueryOptions;\n\n\tconstructor(\n\t\tprivate client: PgliteClient | Transaction,\n\t\tprivate queryString: 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\trowMode: 'object',\n\t\t\tparsers: {\n\t\t\t\t[types.TIMESTAMP]: (value) => value,\n\t\t\t\t[types.TIMESTAMPTZ]: (value) => value,\n\t\t\t\t[types.INTERVAL]: (value) => value,\n\t\t\t\t[types.DATE]: (value) => value,\n\t\t\t},\n\t\t};\n\t\tthis.queryConfig = {\n\t\t\trowMode: 'array',\n\t\t\tparsers: {\n\t\t\t\t[types.TIMESTAMP]: (value) => value,\n\t\t\t\t[types.TIMESTAMPTZ]: (value) => value,\n\t\t\t\t[types.INTERVAL]: (value) => value,\n\t\t\t\t[types.DATE]: (value) => value,\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.queryString, params);\n\n\t\tconst { fields, rawQueryConfig, client, queryConfig, joinsNotNullableMap, customResultMapper, queryString } = this;\n\n\t\tif (!fields && !customResultMapper) {\n\t\t\treturn client.query<any[]>(queryString, params, rawQueryConfig);\n\t\t}\n\n\t\tconst result = await client.query<any[]>(queryString, params, queryConfig);\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.queryString, params);\n\n\t\tconst { rawQueryConfig, client, customResultMapper, queryString } = this;\n\n\t\tconst result = await client.query<Record<string, unknown>>(queryString, params, rawQueryConfig);\n\n\t\treturn (customResultMapper as (rows: Record<string, unknown>[]) => T['execute'])(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.queryString, params);\n\t\treturn this.client.query(this.queryString, params, this.rawQueryConfig).then((result) => result.rows);\n\t}\n\n\t/** @internal */\n\tisResponseInArrayMode(): boolean {\n\t\treturn this._isResponseInArrayMode;\n\t}\n}\n\nexport interface PgliteSessionOptions {\n\tlogger?: Logger;\n}\n\nexport class PgliteSession<\n\tTFullSchema extends Record<string, unknown>,\n\tTRelations extends AnyRelations,\n\tTTablesConfig extends TablesRelationalConfig,\n\tTSchema extends V1.TablesRelationalConfig,\n> extends PgSession<PgliteQueryResultHKT, TFullSchema, TRelations, TTablesConfig, TSchema> {\n\tstatic override readonly [entityKind]: string = 'PgliteSession';\n\n\tprivate logger: Logger;\n\n\tconstructor(\n\t\tprivate client: PgliteClient | Transaction,\n\t\tdialect: PgDialect,\n\t\tprivate relations: AnyRelations | undefined,\n\t\tprivate schema: V1.RelationalSchemaConfig<TSchema> | undefined,\n\t\tprivate options: PgliteSessionOptions = {},\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 PglitePreparedQuery(\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 PglitePreparedQuery(\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\toverride async transaction<T>(\n\t\ttransaction: (tx: PgliteTransaction<TFullSchema, TRelations, TTablesConfig, TSchema>) => Promise<T>,\n\t\tconfig?: PgTransactionConfig | undefined,\n\t): Promise<T> {\n\t\treturn (this.client as PgliteClient).transaction(async (client) => {\n\t\t\tconst session = new PgliteSession<TFullSchema, TRelations, TTablesConfig, TSchema>(\n\t\t\t\tclient,\n\t\t\t\tthis.dialect,\n\t\t\t\tthis.relations,\n\t\t\t\tthis.schema,\n\t\t\t\tthis.options,\n\t\t\t);\n\t\t\tconst tx = new PgliteTransaction<TFullSchema, TRelations, TTablesConfig, TSchema>(\n\t\t\t\tthis.dialect,\n\t\t\t\tsession,\n\t\t\t\tthis.relations,\n\t\t\t\tthis.schema,\n\t\t\t);\n\t\t\tif (config) {\n\t\t\t\tawait tx.setTransaction(config);\n\t\t\t}\n\t\t\treturn transaction(tx);\n\t\t}) as Promise<T>;\n\t}\n\n\toverride async count(sql: SQL): Promise<number> {\n\t\tconst res = await this.execute<{ rows: [{ count: string }] }>(sql);\n\t\treturn Number(\n\t\t\tres['rows'][0]['count'],\n\t\t);\n\t}\n}\n\nexport class PgliteTransaction<\n\tTFullSchema extends Record<string, unknown>,\n\tTRelations extends AnyRelations,\n\tTTablesConfig extends TablesRelationalConfig,\n\tTSchema extends V1.TablesRelationalConfig,\n> extends PgTransaction<PgliteQueryResultHKT, TFullSchema, TRelations, TTablesConfig, TSchema> {\n\tstatic override readonly [entityKind]: string = 'PgliteTransaction';\n\n\toverride async transaction<T>(\n\t\ttransaction: (tx: PgliteTransaction<TFullSchema, TRelations, TTablesConfig, TSchema>) => Promise<T>,\n\t): Promise<T> {\n\t\tconst savepointName = `sp${this.nestedIndex + 1}`;\n\t\tconst tx = new PgliteTransaction<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 PgliteQueryResultHKT extends PgQueryResultHKT {\n\ttype: Results<Assume<this['row'], Row>>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,oBAA2B;AAC3B,oBAAwC;AAExC,qBAA8B;AAG9B,qBAA2C;AAC3C,iBAA4D;AAC5D,mBAA0C;AAE1C,oBAAsB;AAKf,MAAM,4BACJ,+BACT;AAAA,EAMC,YACS,QACA,aACA,QACA,QACA,QACR,MACQ,wBACA,oBAGA,cACP;AACD,UAAM,EAAE,KAAK,aAAa,OAAO,CAAC;AAZ1B;AACA;AACA;AACA;AACA;AAEA;AACA;AAGA;AAGR,SAAK,iBAAiB;AAAA,MACrB,SAAS;AAAA,MACT,SAAS;AAAA,QACR,C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;AAAA,QACL,KAAK;AAAA,QACL,KAAK;AAAA,MACN;AACA,YAAM,KAAK,IAAI;AAAA,QACd,KAAK;AAAA,QACL;AAAA,QACA,KAAK;AAAA,QACL,KAAK;AAAA,MACN;AACA,UAAI,QAAQ;AACX,cAAM,GAAG,eAAe,MAAM;AAAA,MAC/B;AACA,aAAO,YAAY,EAAE;AAAA,IACtB,CAAC;AAAA,EACF;AAAA,EAEA,MAAe,MAAMA,MAA2B;AAC/C,UAAM,MAAM,MAAM,KAAK,QAAuCA,IAAG;AACjE,WAAO;AAAA,MACN,IAAI,MAAM,EAAE,CAAC,EAAE,OAAO;AAAA,IACvB;AAAA,EACD;AACD;AAEO,MAAM,0BAKH,6BAAqF;AAAA,EAC9F,QAA0B,wBAAU,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,eAAI,IAAI,aAAa,aAAa,EAAE,CAAC;AACtD,QAAI;AACH,YAAM,SAAS,MAAM,YAAY,EAAE;AACnC,YAAM,GAAG,QAAQ,eAAI,IAAI,qBAAqB,aAAa,EAAE,CAAC;AAC9D,aAAO;AAAA,IACR,SAAS,KAAK;AACb,YAAM,GAAG,QAAQ,eAAI,IAAI,yBAAyB,aAAa,EAAE,CAAC;AAClE,YAAM;AAAA,IACP;AAAA,EACD;AACD;","names":["sql"]}
|
package/pglite/session.d.cts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { PGlite, Results, Row, Transaction } from '@electric-sql/pglite';
|
|
2
|
+
import type * as V1 from "../_relations.cjs";
|
|
2
3
|
import { entityKind } from "../entity.cjs";
|
|
3
4
|
import { type Logger } from "../logger.cjs";
|
|
4
5
|
import type { PgDialect } from "../pg-core/dialect.cjs";
|
|
@@ -6,11 +7,11 @@ import { PgTransaction } from "../pg-core/index.cjs";
|
|
|
6
7
|
import type { SelectedFieldsOrdered } from "../pg-core/query-builders/select.types.cjs";
|
|
7
8
|
import type { PgQueryResultHKT, PgTransactionConfig, PreparedQueryConfig } from "../pg-core/session.cjs";
|
|
8
9
|
import { PgPreparedQuery, PgSession } from "../pg-core/session.cjs";
|
|
9
|
-
import type { RelationalSchemaConfig, TablesRelationalConfig } from "../relations.cjs";
|
|
10
10
|
import { type Query, type SQL } from "../sql/sql.cjs";
|
|
11
11
|
import { type Assume } from "../utils.cjs";
|
|
12
|
+
import type { AnyRelations, TablesRelationalConfig } from "../relations.cjs";
|
|
12
13
|
export type PgliteClient = PGlite;
|
|
13
|
-
export declare class PglitePreparedQuery<T extends PreparedQueryConfig> extends PgPreparedQuery<T> {
|
|
14
|
+
export declare class PglitePreparedQuery<T extends PreparedQueryConfig, TIsRqbV2 extends boolean = false> extends PgPreparedQuery<T> {
|
|
14
15
|
private client;
|
|
15
16
|
private queryString;
|
|
16
17
|
private params;
|
|
@@ -18,30 +19,34 @@ export declare class PglitePreparedQuery<T extends PreparedQueryConfig> extends
|
|
|
18
19
|
private fields;
|
|
19
20
|
private _isResponseInArrayMode;
|
|
20
21
|
private customResultMapper?;
|
|
22
|
+
private isRqbV2Query?;
|
|
21
23
|
static readonly [entityKind]: string;
|
|
22
24
|
private rawQueryConfig;
|
|
23
25
|
private queryConfig;
|
|
24
|
-
constructor(client: PgliteClient | Transaction, queryString: string, params: unknown[], logger: Logger, fields: SelectedFieldsOrdered | undefined, name: string | undefined, _isResponseInArrayMode: boolean, customResultMapper?: ((rows: unknown[][]) => T["execute"]) | undefined);
|
|
26
|
+
constructor(client: PgliteClient | Transaction, queryString: string, params: unknown[], logger: Logger, fields: SelectedFieldsOrdered | undefined, name: string | undefined, _isResponseInArrayMode: boolean, customResultMapper?: ((rows: TIsRqbV2 extends true ? Record<string, unknown>[] : unknown[][]) => T["execute"]) | undefined, isRqbV2Query?: TIsRqbV2 | undefined);
|
|
25
27
|
execute(placeholderValues?: Record<string, unknown> | undefined): Promise<T['execute']>;
|
|
28
|
+
private executeRqbV2;
|
|
26
29
|
all(placeholderValues?: Record<string, unknown> | undefined): Promise<T['all']>;
|
|
27
30
|
}
|
|
28
31
|
export interface PgliteSessionOptions {
|
|
29
32
|
logger?: Logger;
|
|
30
33
|
}
|
|
31
|
-
export declare class PgliteSession<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends PgSession<PgliteQueryResultHKT, TFullSchema, TSchema> {
|
|
34
|
+
export declare class PgliteSession<TFullSchema extends Record<string, unknown>, TRelations extends AnyRelations, TTablesConfig extends TablesRelationalConfig, TSchema extends V1.TablesRelationalConfig> extends PgSession<PgliteQueryResultHKT, TFullSchema, TRelations, TTablesConfig, TSchema> {
|
|
32
35
|
private client;
|
|
36
|
+
private relations;
|
|
33
37
|
private schema;
|
|
34
38
|
private options;
|
|
35
39
|
static readonly [entityKind]: string;
|
|
36
40
|
private logger;
|
|
37
|
-
constructor(client: PgliteClient | Transaction, dialect: PgDialect, schema: RelationalSchemaConfig<TSchema> | undefined, options?: PgliteSessionOptions);
|
|
41
|
+
constructor(client: PgliteClient | Transaction, dialect: PgDialect, relations: AnyRelations | undefined, schema: V1.RelationalSchemaConfig<TSchema> | undefined, options?: PgliteSessionOptions);
|
|
38
42
|
prepareQuery<T extends PreparedQueryConfig = PreparedQueryConfig>(query: Query, fields: SelectedFieldsOrdered | undefined, name: string | undefined, isResponseInArrayMode: boolean, customResultMapper?: (rows: unknown[][]) => T['execute']): PgPreparedQuery<T>;
|
|
39
|
-
|
|
43
|
+
prepareRelationalQuery<T extends PreparedQueryConfig = PreparedQueryConfig>(query: Query, fields: SelectedFieldsOrdered | undefined, name: string | undefined, customResultMapper: (rows: Record<string, unknown>[]) => T['execute']): PgPreparedQuery<T>;
|
|
44
|
+
transaction<T>(transaction: (tx: PgliteTransaction<TFullSchema, TRelations, TTablesConfig, TSchema>) => Promise<T>, config?: PgTransactionConfig | undefined): Promise<T>;
|
|
40
45
|
count(sql: SQL): Promise<number>;
|
|
41
46
|
}
|
|
42
|
-
export declare class PgliteTransaction<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends PgTransaction<PgliteQueryResultHKT, TFullSchema, TSchema> {
|
|
47
|
+
export declare class PgliteTransaction<TFullSchema extends Record<string, unknown>, TRelations extends AnyRelations, TTablesConfig extends TablesRelationalConfig, TSchema extends V1.TablesRelationalConfig> extends PgTransaction<PgliteQueryResultHKT, TFullSchema, TRelations, TTablesConfig, TSchema> {
|
|
43
48
|
static readonly [entityKind]: string;
|
|
44
|
-
transaction<T>(transaction: (tx: PgliteTransaction<TFullSchema, TSchema>) => Promise<T>): Promise<T>;
|
|
49
|
+
transaction<T>(transaction: (tx: PgliteTransaction<TFullSchema, TRelations, TTablesConfig, TSchema>) => Promise<T>): Promise<T>;
|
|
45
50
|
}
|
|
46
51
|
export interface PgliteQueryResultHKT extends PgQueryResultHKT {
|
|
47
52
|
type: Results<Assume<this['row'], Row>>;
|
package/pglite/session.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { PGlite, Results, Row, Transaction } from '@electric-sql/pglite';
|
|
2
|
+
import type * as V1 from "../_relations.js";
|
|
2
3
|
import { entityKind } from "../entity.js";
|
|
3
4
|
import { type Logger } from "../logger.js";
|
|
4
5
|
import type { PgDialect } from "../pg-core/dialect.js";
|
|
@@ -6,11 +7,11 @@ import { PgTransaction } from "../pg-core/index.js";
|
|
|
6
7
|
import type { SelectedFieldsOrdered } from "../pg-core/query-builders/select.types.js";
|
|
7
8
|
import type { PgQueryResultHKT, PgTransactionConfig, PreparedQueryConfig } from "../pg-core/session.js";
|
|
8
9
|
import { PgPreparedQuery, PgSession } from "../pg-core/session.js";
|
|
9
|
-
import type { RelationalSchemaConfig, TablesRelationalConfig } from "../relations.js";
|
|
10
10
|
import { type Query, type SQL } from "../sql/sql.js";
|
|
11
11
|
import { type Assume } from "../utils.js";
|
|
12
|
+
import type { AnyRelations, TablesRelationalConfig } from "../relations.js";
|
|
12
13
|
export type PgliteClient = PGlite;
|
|
13
|
-
export declare class PglitePreparedQuery<T extends PreparedQueryConfig> extends PgPreparedQuery<T> {
|
|
14
|
+
export declare class PglitePreparedQuery<T extends PreparedQueryConfig, TIsRqbV2 extends boolean = false> extends PgPreparedQuery<T> {
|
|
14
15
|
private client;
|
|
15
16
|
private queryString;
|
|
16
17
|
private params;
|
|
@@ -18,30 +19,34 @@ export declare class PglitePreparedQuery<T extends PreparedQueryConfig> extends
|
|
|
18
19
|
private fields;
|
|
19
20
|
private _isResponseInArrayMode;
|
|
20
21
|
private customResultMapper?;
|
|
22
|
+
private isRqbV2Query?;
|
|
21
23
|
static readonly [entityKind]: string;
|
|
22
24
|
private rawQueryConfig;
|
|
23
25
|
private queryConfig;
|
|
24
|
-
constructor(client: PgliteClient | Transaction, queryString: string, params: unknown[], logger: Logger, fields: SelectedFieldsOrdered | undefined, name: string | undefined, _isResponseInArrayMode: boolean, customResultMapper?: ((rows: unknown[][]) => T["execute"]) | undefined);
|
|
26
|
+
constructor(client: PgliteClient | Transaction, queryString: string, params: unknown[], logger: Logger, fields: SelectedFieldsOrdered | undefined, name: string | undefined, _isResponseInArrayMode: boolean, customResultMapper?: ((rows: TIsRqbV2 extends true ? Record<string, unknown>[] : unknown[][]) => T["execute"]) | undefined, isRqbV2Query?: TIsRqbV2 | undefined);
|
|
25
27
|
execute(placeholderValues?: Record<string, unknown> | undefined): Promise<T['execute']>;
|
|
28
|
+
private executeRqbV2;
|
|
26
29
|
all(placeholderValues?: Record<string, unknown> | undefined): Promise<T['all']>;
|
|
27
30
|
}
|
|
28
31
|
export interface PgliteSessionOptions {
|
|
29
32
|
logger?: Logger;
|
|
30
33
|
}
|
|
31
|
-
export declare class PgliteSession<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends PgSession<PgliteQueryResultHKT, TFullSchema, TSchema> {
|
|
34
|
+
export declare class PgliteSession<TFullSchema extends Record<string, unknown>, TRelations extends AnyRelations, TTablesConfig extends TablesRelationalConfig, TSchema extends V1.TablesRelationalConfig> extends PgSession<PgliteQueryResultHKT, TFullSchema, TRelations, TTablesConfig, TSchema> {
|
|
32
35
|
private client;
|
|
36
|
+
private relations;
|
|
33
37
|
private schema;
|
|
34
38
|
private options;
|
|
35
39
|
static readonly [entityKind]: string;
|
|
36
40
|
private logger;
|
|
37
|
-
constructor(client: PgliteClient | Transaction, dialect: PgDialect, schema: RelationalSchemaConfig<TSchema> | undefined, options?: PgliteSessionOptions);
|
|
41
|
+
constructor(client: PgliteClient | Transaction, dialect: PgDialect, relations: AnyRelations | undefined, schema: V1.RelationalSchemaConfig<TSchema> | undefined, options?: PgliteSessionOptions);
|
|
38
42
|
prepareQuery<T extends PreparedQueryConfig = PreparedQueryConfig>(query: Query, fields: SelectedFieldsOrdered | undefined, name: string | undefined, isResponseInArrayMode: boolean, customResultMapper?: (rows: unknown[][]) => T['execute']): PgPreparedQuery<T>;
|
|
39
|
-
|
|
43
|
+
prepareRelationalQuery<T extends PreparedQueryConfig = PreparedQueryConfig>(query: Query, fields: SelectedFieldsOrdered | undefined, name: string | undefined, customResultMapper: (rows: Record<string, unknown>[]) => T['execute']): PgPreparedQuery<T>;
|
|
44
|
+
transaction<T>(transaction: (tx: PgliteTransaction<TFullSchema, TRelations, TTablesConfig, TSchema>) => Promise<T>, config?: PgTransactionConfig | undefined): Promise<T>;
|
|
40
45
|
count(sql: SQL): Promise<number>;
|
|
41
46
|
}
|
|
42
|
-
export declare class PgliteTransaction<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends PgTransaction<PgliteQueryResultHKT, TFullSchema, TSchema> {
|
|
47
|
+
export declare class PgliteTransaction<TFullSchema extends Record<string, unknown>, TRelations extends AnyRelations, TTablesConfig extends TablesRelationalConfig, TSchema extends V1.TablesRelationalConfig> extends PgTransaction<PgliteQueryResultHKT, TFullSchema, TRelations, TTablesConfig, TSchema> {
|
|
43
48
|
static readonly [entityKind]: string;
|
|
44
|
-
transaction<T>(transaction: (tx: PgliteTransaction<TFullSchema, TSchema>) => Promise<T>): Promise<T>;
|
|
49
|
+
transaction<T>(transaction: (tx: PgliteTransaction<TFullSchema, TRelations, TTablesConfig, TSchema>) => Promise<T>): Promise<T>;
|
|
45
50
|
}
|
|
46
51
|
export interface PgliteQueryResultHKT extends PgQueryResultHKT {
|
|
47
52
|
type: Results<Assume<this['row'], Row>>;
|
package/pglite/session.js
CHANGED
|
@@ -6,7 +6,7 @@ import { fillPlaceholders, sql } from "../sql/sql.js";
|
|
|
6
6
|
import { mapResultRow } from "../utils.js";
|
|
7
7
|
import { types } from "@electric-sql/pglite";
|
|
8
8
|
class PglitePreparedQuery extends PgPreparedQuery {
|
|
9
|
-
constructor(client, queryString, params, logger, fields, name, _isResponseInArrayMode, customResultMapper) {
|
|
9
|
+
constructor(client, queryString, params, logger, fields, name, _isResponseInArrayMode, customResultMapper, isRqbV2Query) {
|
|
10
10
|
super({ sql: queryString, params });
|
|
11
11
|
this.client = client;
|
|
12
12
|
this.queryString = queryString;
|
|
@@ -15,6 +15,7 @@ class PglitePreparedQuery extends PgPreparedQuery {
|
|
|
15
15
|
this.fields = fields;
|
|
16
16
|
this._isResponseInArrayMode = _isResponseInArrayMode;
|
|
17
17
|
this.customResultMapper = customResultMapper;
|
|
18
|
+
this.isRqbV2Query = isRqbV2Query;
|
|
18
19
|
this.rawQueryConfig = {
|
|
19
20
|
rowMode: "object",
|
|
20
21
|
parsers: {
|
|
@@ -38,6 +39,8 @@ class PglitePreparedQuery extends PgPreparedQuery {
|
|
|
38
39
|
rawQueryConfig;
|
|
39
40
|
queryConfig;
|
|
40
41
|
async execute(placeholderValues = {}) {
|
|
42
|
+
if (this.isRqbV2Query)
|
|
43
|
+
return this.executeRqbV2(placeholderValues);
|
|
41
44
|
const params = fillPlaceholders(this.params, placeholderValues);
|
|
42
45
|
this.logger.logQuery(this.queryString, params);
|
|
43
46
|
const { fields, rawQueryConfig, client, queryConfig, joinsNotNullableMap, customResultMapper, queryString } = this;
|
|
@@ -47,6 +50,13 @@ class PglitePreparedQuery extends PgPreparedQuery {
|
|
|
47
50
|
const result = await client.query(queryString, params, queryConfig);
|
|
48
51
|
return customResultMapper ? customResultMapper(result.rows) : result.rows.map((row) => mapResultRow(fields, row, joinsNotNullableMap));
|
|
49
52
|
}
|
|
53
|
+
async executeRqbV2(placeholderValues = {}) {
|
|
54
|
+
const params = fillPlaceholders(this.params, placeholderValues);
|
|
55
|
+
this.logger.logQuery(this.queryString, params);
|
|
56
|
+
const { rawQueryConfig, client, customResultMapper, queryString } = this;
|
|
57
|
+
const result = await client.query(queryString, params, rawQueryConfig);
|
|
58
|
+
return customResultMapper(result.rows);
|
|
59
|
+
}
|
|
50
60
|
all(placeholderValues = {}) {
|
|
51
61
|
const params = fillPlaceholders(this.params, placeholderValues);
|
|
52
62
|
this.logger.logQuery(this.queryString, params);
|
|
@@ -58,9 +68,10 @@ class PglitePreparedQuery extends PgPreparedQuery {
|
|
|
58
68
|
}
|
|
59
69
|
}
|
|
60
70
|
class PgliteSession extends PgSession {
|
|
61
|
-
constructor(client, dialect, schema, options = {}) {
|
|
71
|
+
constructor(client, dialect, relations, schema, options = {}) {
|
|
62
72
|
super(dialect);
|
|
63
73
|
this.client = client;
|
|
74
|
+
this.relations = relations;
|
|
64
75
|
this.schema = schema;
|
|
65
76
|
this.options = options;
|
|
66
77
|
this.logger = options.logger ?? new NoopLogger();
|
|
@@ -79,15 +90,34 @@ class PgliteSession extends PgSession {
|
|
|
79
90
|
customResultMapper
|
|
80
91
|
);
|
|
81
92
|
}
|
|
93
|
+
prepareRelationalQuery(query, fields, name, customResultMapper) {
|
|
94
|
+
return new PglitePreparedQuery(
|
|
95
|
+
this.client,
|
|
96
|
+
query.sql,
|
|
97
|
+
query.params,
|
|
98
|
+
this.logger,
|
|
99
|
+
fields,
|
|
100
|
+
name,
|
|
101
|
+
false,
|
|
102
|
+
customResultMapper,
|
|
103
|
+
true
|
|
104
|
+
);
|
|
105
|
+
}
|
|
82
106
|
async transaction(transaction, config) {
|
|
83
107
|
return this.client.transaction(async (client) => {
|
|
84
108
|
const session = new PgliteSession(
|
|
85
109
|
client,
|
|
86
110
|
this.dialect,
|
|
111
|
+
this.relations,
|
|
87
112
|
this.schema,
|
|
88
113
|
this.options
|
|
89
114
|
);
|
|
90
|
-
const tx = new PgliteTransaction(
|
|
115
|
+
const tx = new PgliteTransaction(
|
|
116
|
+
this.dialect,
|
|
117
|
+
session,
|
|
118
|
+
this.relations,
|
|
119
|
+
this.schema
|
|
120
|
+
);
|
|
91
121
|
if (config) {
|
|
92
122
|
await tx.setTransaction(config);
|
|
93
123
|
}
|
|
@@ -108,6 +138,7 @@ class PgliteTransaction extends PgTransaction {
|
|
|
108
138
|
const tx = new PgliteTransaction(
|
|
109
139
|
this.dialect,
|
|
110
140
|
this.session,
|
|
141
|
+
this.relations,
|
|
111
142
|
this.schema,
|
|
112
143
|
this.nestedIndex + 1
|
|
113
144
|
);
|
package/pglite/session.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/pglite/session.ts"],"sourcesContent":["import type { PGlite, QueryOptions, Results, Row, Transaction } from '@electric-sql/pglite';\nimport { entityKind } from '~/entity.ts';\nimport { type Logger, 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\nimport { types } from '@electric-sql/pglite';\n\nexport type PgliteClient = PGlite;\n\nexport class PglitePreparedQuery<T extends PreparedQueryConfig> extends PgPreparedQuery<T> {\n\tstatic override readonly [entityKind]: string = 'PglitePreparedQuery';\n\n\tprivate rawQueryConfig: QueryOptions;\n\tprivate queryConfig: QueryOptions;\n\n\tconstructor(\n\t\tprivate client: PgliteClient | Transaction,\n\t\tprivate queryString: 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\trowMode: 'object',\n\t\t\tparsers: {\n\t\t\t\t[types.TIMESTAMP]: (value) => value,\n\t\t\t\t[types.TIMESTAMPTZ]: (value) => value,\n\t\t\t\t[types.INTERVAL]: (value) => value,\n\t\t\t\t[types.DATE]: (value) => value,\n\t\t\t},\n\t\t};\n\t\tthis.queryConfig = {\n\t\t\trowMode: 'array',\n\t\t\tparsers: {\n\t\t\t\t[types.TIMESTAMP]: (value) => value,\n\t\t\t\t[types.TIMESTAMPTZ]: (value) => value,\n\t\t\t\t[types.INTERVAL]: (value) => value,\n\t\t\t\t[types.DATE]: (value) => value,\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.queryString, params);\n\n\t\tconst { fields, rawQueryConfig, client, queryConfig, joinsNotNullableMap, customResultMapper, queryString } = this;\n\n\t\tif (!fields && !customResultMapper) {\n\t\t\treturn client.query<any[]>(queryString, params, rawQueryConfig);\n\t\t}\n\n\t\tconst result = await client.query<any[][]>(queryString, params, queryConfig);\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.queryString, params);\n\t\treturn this.client.query(this.queryString, params, this.rawQueryConfig).then((result) => result.rows);\n\t}\n\n\t/** @internal */\n\tisResponseInArrayMode(): boolean {\n\t\treturn this._isResponseInArrayMode;\n\t}\n}\n\nexport interface PgliteSessionOptions {\n\tlogger?: Logger;\n}\n\nexport class PgliteSession<\n\tTFullSchema extends Record<string, unknown>,\n\tTSchema extends TablesRelationalConfig,\n> extends PgSession<PgliteQueryResultHKT, TFullSchema, TSchema> {\n\tstatic override readonly [entityKind]: string = 'PgliteSession';\n\n\tprivate logger: Logger;\n\n\tconstructor(\n\t\tprivate client: PgliteClient | Transaction,\n\t\tdialect: PgDialect,\n\t\tprivate schema: RelationalSchemaConfig<TSchema> | undefined,\n\t\tprivate options: PgliteSessionOptions = {},\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 PglitePreparedQuery(\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\toverride async transaction<T>(\n\t\ttransaction: (tx: PgliteTransaction<TFullSchema, TSchema>) => Promise<T>,\n\t\tconfig?: PgTransactionConfig | undefined,\n\t): Promise<T> {\n\t\treturn (this.client as PgliteClient).transaction(async (client) => {\n\t\t\tconst session = new PgliteSession<TFullSchema, TSchema>(\n\t\t\t\tclient,\n\t\t\t\tthis.dialect,\n\t\t\t\tthis.schema,\n\t\t\t\tthis.options,\n\t\t\t);\n\t\t\tconst tx = new PgliteTransaction<TFullSchema, TSchema>(this.dialect, session, this.schema);\n\t\t\tif (config) {\n\t\t\t\tawait tx.setTransaction(config);\n\t\t\t}\n\t\t\treturn transaction(tx);\n\t\t}) as Promise<T>;\n\t}\n\n\toverride async count(sql: SQL): Promise<number> {\n\t\tconst res = await this.execute<{ rows: [{ count: string }] }>(sql);\n\t\treturn Number(\n\t\t\tres['rows'][0]['count'],\n\t\t);\n\t}\n}\n\nexport class PgliteTransaction<\n\tTFullSchema extends Record<string, unknown>,\n\tTSchema extends TablesRelationalConfig,\n> extends PgTransaction<PgliteQueryResultHKT, TFullSchema, TSchema> {\n\tstatic override readonly [entityKind]: string = 'PgliteTransaction';\n\n\toverride async transaction<T>(transaction: (tx: PgliteTransaction<TFullSchema, TSchema>) => Promise<T>): Promise<T> {\n\t\tconst savepointName = `sp${this.nestedIndex + 1}`;\n\t\tconst tx = new PgliteTransaction<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 PgliteQueryResultHKT extends PgQueryResultHKT {\n\ttype: Results<Assume<this['row'], Row>>;\n}\n"],"mappings":"AACA,SAAS,kBAAkB;AAC3B,SAAsB,kBAAkB;AAExC,SAAS,qBAAqB;AAG9B,SAAS,iBAAiB,iBAAiB;AAE3C,SAAS,kBAAwC,WA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AAAA,MACN,IAAI,MAAM,EAAE,CAAC,EAAE,OAAO;AAAA,IACvB;AAAA,EACD;AACD;AAEO,MAAM,0BAGH,cAA0D;AAAA,EACnE,QAA0B,UAAU,IAAY;AAAA,EAEhD,MAAe,YAAe,aAAsF;AACnH,UAAM,gBAAgB,KAAK,KAAK,cAAc,CAAC;AAC/C,UAAM,KAAK,IAAI;AAAA,MACd,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK,cAAc;AAAA,IACpB;AACA,UAAM,GAAG,QAAQ,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,KAAK;AACb,YAAM,GAAG,QAAQ,IAAI,IAAI,yBAAyB,aAAa,EAAE,CAAC;AAClE,YAAM;AAAA,IACP;AAAA,EACD;AACD;","names":["sql"]}
|
|
1
|
+
{"version":3,"sources":["../../src/pglite/session.ts"],"sourcesContent":["import type { PGlite, QueryOptions, Results, Row, Transaction } from '@electric-sql/pglite';\nimport type * as V1 from '~/_relations.ts';\nimport { entityKind } from '~/entity.ts';\nimport { type Logger, 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 { fillPlaceholders, type Query, type SQL, sql } from '~/sql/sql.ts';\nimport { type Assume, mapResultRow } from '~/utils.ts';\n\nimport { types } from '@electric-sql/pglite';\nimport type { AnyRelations, TablesRelationalConfig } from '~/relations.ts';\n\nexport type PgliteClient = PGlite;\n\nexport class PglitePreparedQuery<T extends PreparedQueryConfig, TIsRqbV2 extends boolean = false>\n\textends PgPreparedQuery<T>\n{\n\tstatic override readonly [entityKind]: string = 'PglitePreparedQuery';\n\n\tprivate rawQueryConfig: QueryOptions;\n\tprivate queryConfig: QueryOptions;\n\n\tconstructor(\n\t\tprivate client: PgliteClient | Transaction,\n\t\tprivate queryString: 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\trowMode: 'object',\n\t\t\tparsers: {\n\t\t\t\t[types.TIMESTAMP]: (value) => value,\n\t\t\t\t[types.TIMESTAMPTZ]: (value) => value,\n\t\t\t\t[types.INTERVAL]: (value) => value,\n\t\t\t\t[types.DATE]: (value) => value,\n\t\t\t},\n\t\t};\n\t\tthis.queryConfig = {\n\t\t\trowMode: 'array',\n\t\t\tparsers: {\n\t\t\t\t[types.TIMESTAMP]: (value) => value,\n\t\t\t\t[types.TIMESTAMPTZ]: (value) => value,\n\t\t\t\t[types.INTERVAL]: (value) => value,\n\t\t\t\t[types.DATE]: (value) => value,\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.queryString, params);\n\n\t\tconst { fields, rawQueryConfig, client, queryConfig, joinsNotNullableMap, customResultMapper, queryString } = this;\n\n\t\tif (!fields && !customResultMapper) {\n\t\t\treturn client.query<any[]>(queryString, params, rawQueryConfig);\n\t\t}\n\n\t\tconst result = await client.query<any[]>(queryString, params, queryConfig);\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.queryString, params);\n\n\t\tconst { rawQueryConfig, client, customResultMapper, queryString } = this;\n\n\t\tconst result = await client.query<Record<string, unknown>>(queryString, params, rawQueryConfig);\n\n\t\treturn (customResultMapper as (rows: Record<string, unknown>[]) => T['execute'])(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.queryString, params);\n\t\treturn this.client.query(this.queryString, params, this.rawQueryConfig).then((result) => result.rows);\n\t}\n\n\t/** @internal */\n\tisResponseInArrayMode(): boolean {\n\t\treturn this._isResponseInArrayMode;\n\t}\n}\n\nexport interface PgliteSessionOptions {\n\tlogger?: Logger;\n}\n\nexport class PgliteSession<\n\tTFullSchema extends Record<string, unknown>,\n\tTRelations extends AnyRelations,\n\tTTablesConfig extends TablesRelationalConfig,\n\tTSchema extends V1.TablesRelationalConfig,\n> extends PgSession<PgliteQueryResultHKT, TFullSchema, TRelations, TTablesConfig, TSchema> {\n\tstatic override readonly [entityKind]: string = 'PgliteSession';\n\n\tprivate logger: Logger;\n\n\tconstructor(\n\t\tprivate client: PgliteClient | Transaction,\n\t\tdialect: PgDialect,\n\t\tprivate relations: AnyRelations | undefined,\n\t\tprivate schema: V1.RelationalSchemaConfig<TSchema> | undefined,\n\t\tprivate options: PgliteSessionOptions = {},\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 PglitePreparedQuery(\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 PglitePreparedQuery(\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\toverride async transaction<T>(\n\t\ttransaction: (tx: PgliteTransaction<TFullSchema, TRelations, TTablesConfig, TSchema>) => Promise<T>,\n\t\tconfig?: PgTransactionConfig | undefined,\n\t): Promise<T> {\n\t\treturn (this.client as PgliteClient).transaction(async (client) => {\n\t\t\tconst session = new PgliteSession<TFullSchema, TRelations, TTablesConfig, TSchema>(\n\t\t\t\tclient,\n\t\t\t\tthis.dialect,\n\t\t\t\tthis.relations,\n\t\t\t\tthis.schema,\n\t\t\t\tthis.options,\n\t\t\t);\n\t\t\tconst tx = new PgliteTransaction<TFullSchema, TRelations, TTablesConfig, TSchema>(\n\t\t\t\tthis.dialect,\n\t\t\t\tsession,\n\t\t\t\tthis.relations,\n\t\t\t\tthis.schema,\n\t\t\t);\n\t\t\tif (config) {\n\t\t\t\tawait tx.setTransaction(config);\n\t\t\t}\n\t\t\treturn transaction(tx);\n\t\t}) as Promise<T>;\n\t}\n\n\toverride async count(sql: SQL): Promise<number> {\n\t\tconst res = await this.execute<{ rows: [{ count: string }] }>(sql);\n\t\treturn Number(\n\t\t\tres['rows'][0]['count'],\n\t\t);\n\t}\n}\n\nexport class PgliteTransaction<\n\tTFullSchema extends Record<string, unknown>,\n\tTRelations extends AnyRelations,\n\tTTablesConfig extends TablesRelationalConfig,\n\tTSchema extends V1.TablesRelationalConfig,\n> extends PgTransaction<PgliteQueryResultHKT, TFullSchema, TRelations, TTablesConfig, TSchema> {\n\tstatic override readonly [entityKind]: string = 'PgliteTransaction';\n\n\toverride async transaction<T>(\n\t\ttransaction: (tx: PgliteTransaction<TFullSchema, TRelations, TTablesConfig, TSchema>) => Promise<T>,\n\t): Promise<T> {\n\t\tconst savepointName = `sp${this.nestedIndex + 1}`;\n\t\tconst tx = new PgliteTransaction<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 PgliteQueryResultHKT extends PgQueryResultHKT {\n\ttype: Results<Assume<this['row'], Row>>;\n}\n"],"mappings":"AAEA,SAAS,kBAAkB;AAC3B,SAAsB,kBAAkB;AAExC,SAAS,qBAAqB;AAG9B,SAAS,iBAAiB,iBAAiB;AAC3C,SAAS,kBAAwC,WAAW;AAC5D,SAAsB,oBAAoB;AAE1C,SAAS,aAAa;AAKf,MAAM,4BACJ,gBACT;AAAA,EAMC,YACS,QACA,aACA,QACA,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.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
var driver_exports = {};
|
|
20
30
|
__export(driver_exports, {
|
|
@@ -23,11 +33,11 @@ __export(driver_exports, {
|
|
|
23
33
|
});
|
|
24
34
|
module.exports = __toCommonJS(driver_exports);
|
|
25
35
|
var import_database = require("@planetscale/database");
|
|
36
|
+
var V1 = __toESM(require("../_relations.cjs"), 1);
|
|
26
37
|
var import_entity = require("../entity.cjs");
|
|
27
38
|
var import_logger = require("../logger.cjs");
|
|
28
39
|
var import_db = require("../mysql-core/db.cjs");
|
|
29
40
|
var import_dialect = require("../mysql-core/dialect.cjs");
|
|
30
|
-
var import_relations = require("../relations.cjs");
|
|
31
41
|
var import_utils = require("../utils.cjs");
|
|
32
42
|
var import_session = require("./session.cjs");
|
|
33
43
|
class PlanetScaleDatabase extends import_db.MySqlDatabase {
|
|
@@ -57,9 +67,9 @@ const db = drizzle(client);
|
|
|
57
67
|
}
|
|
58
68
|
let schema;
|
|
59
69
|
if (config.schema) {
|
|
60
|
-
const tablesConfig =
|
|
70
|
+
const tablesConfig = V1.extractTablesRelationalConfig(
|
|
61
71
|
config.schema,
|
|
62
|
-
|
|
72
|
+
V1.createTableRelationsHelpers
|
|
63
73
|
);
|
|
64
74
|
schema = {
|
|
65
75
|
fullSchema: config.schema,
|
|
@@ -67,8 +77,15 @@ const db = drizzle(client);
|
|
|
67
77
|
tableNamesMap: tablesConfig.tableNamesMap
|
|
68
78
|
};
|
|
69
79
|
}
|
|
70
|
-
const
|
|
71
|
-
const
|
|
80
|
+
const relations = config.relations;
|
|
81
|
+
const session = new import_session.PlanetscaleSession(client, dialect, void 0, relations, schema, { logger });
|
|
82
|
+
const db = new PlanetScaleDatabase(
|
|
83
|
+
dialect,
|
|
84
|
+
session,
|
|
85
|
+
relations,
|
|
86
|
+
schema,
|
|
87
|
+
"planetscale"
|
|
88
|
+
);
|
|
72
89
|
db.$client = client;
|
|
73
90
|
return db;
|
|
74
91
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/planetscale-serverless/driver.ts"],"sourcesContent":["import type { Config } from '@planetscale/database';\nimport { Client } from '@planetscale/database';\nimport { entityKind } from '~/entity.ts';\nimport type { Logger } from '~/logger.ts';\nimport { DefaultLogger } from '~/logger.ts';\nimport { MySqlDatabase } from '~/mysql-core/db.ts';\nimport { MySqlDialect } from '~/mysql-core/dialect.ts';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../src/planetscale-serverless/driver.ts"],"sourcesContent":["import type { Config } from '@planetscale/database';\nimport { Client } from '@planetscale/database';\nimport * as V1 from '~/_relations.ts';\nimport { entityKind } from '~/entity.ts';\nimport type { Logger } from '~/logger.ts';\nimport { DefaultLogger } from '~/logger.ts';\nimport { MySqlDatabase } from '~/mysql-core/db.ts';\nimport { MySqlDialect } from '~/mysql-core/dialect.ts';\nimport type { AnyRelations, EmptyRelations } from '~/relations.ts';\nimport { type DrizzleConfig, isConfig } from '~/utils.ts';\nimport type { PlanetScalePreparedQueryHKT, PlanetscaleQueryResultHKT } from './session.ts';\nimport { PlanetscaleSession } from './session.ts';\n\nexport interface PlanetscaleSDriverOptions {\n\tlogger?: Logger;\n}\n\nexport class PlanetScaleDatabase<\n\tTSchema extends Record<string, unknown> = Record<string, never>,\n\tTRelations extends AnyRelations = EmptyRelations,\n> extends MySqlDatabase<PlanetscaleQueryResultHKT, PlanetScalePreparedQueryHKT, TSchema, TRelations> {\n\tstatic override readonly [entityKind]: string = 'PlanetScaleDatabase';\n}\n\nfunction construct<\n\tTSchema extends Record<string, unknown> = Record<string, never>,\n\tTRelations extends AnyRelations = EmptyRelations,\n\tTClient extends Client = Client,\n>(\n\tclient: TClient,\n\tconfig: DrizzleConfig<TSchema, TRelations> = {},\n): PlanetScaleDatabase<TSchema, TRelations> & {\n\t$client: TClient;\n} {\n\t// Client is not Drizzle Object, so we can ignore this rule here\n\t// eslint-disable-next-line no-instanceof/no-instanceof\n\tif (!(client instanceof Client)) {\n\t\tthrow new Error(`Warning: You need to pass an instance of Client:\n\nimport { Client } from \"@planetscale/database\";\n\nconst client = new Client({\n host: process.env[\"DATABASE_HOST\"],\n username: process.env[\"DATABASE_USERNAME\"],\n password: process.env[\"DATABASE_PASSWORD\"],\n});\n\nconst db = drizzle(client);\n\t\t`);\n\t}\n\n\tconst dialect = new MySqlDialect({ casing: config.casing });\n\tlet logger;\n\tif (config.logger === true) {\n\t\tlogger = new DefaultLogger();\n\t} else if (config.logger !== false) {\n\t\tlogger = config.logger;\n\t}\n\n\tlet schema: V1.RelationalSchemaConfig<V1.TablesRelationalConfig> | undefined;\n\tif (config.schema) {\n\t\tconst tablesConfig = V1.extractTablesRelationalConfig(\n\t\t\tconfig.schema,\n\t\t\tV1.createTableRelationsHelpers,\n\t\t);\n\t\tschema = {\n\t\t\tfullSchema: config.schema,\n\t\t\tschema: tablesConfig.tables,\n\t\t\ttableNamesMap: tablesConfig.tableNamesMap,\n\t\t};\n\t}\n\n\tconst relations = config.relations;\n\tconst session = new PlanetscaleSession(client, dialect, undefined, relations, schema, { logger });\n\tconst db = new PlanetScaleDatabase(\n\t\tdialect,\n\t\tsession,\n\t\trelations,\n\t\tschema as V1.RelationalSchemaConfig<any>,\n\t\t'planetscale',\n\t) as PlanetScaleDatabase<TSchema, TRelations>;\n\t(<any> db).$client = client;\n\n\treturn db as any;\n}\n\nexport function drizzle<\n\tTSchema extends Record<string, unknown> = Record<string, never>,\n\tTRelations extends AnyRelations = EmptyRelations,\n\tTClient extends Client = Client,\n>(\n\t...params: [\n\t\tTClient | string,\n\t] | [\n\t\tTClient | string,\n\t\tDrizzleConfig<TSchema, TRelations>,\n\t] | [\n\t\t(\n\t\t\t& DrizzleConfig<TSchema, TRelations>\n\t\t\t& ({\n\t\t\t\tconnection: string | Config;\n\t\t\t} | {\n\t\t\t\tclient: TClient;\n\t\t\t})\n\t\t),\n\t]\n): PlanetScaleDatabase<TSchema, TRelations> & {\n\t$client: TClient;\n} {\n\tif (typeof params[0] === 'string') {\n\t\tconst instance = new Client({\n\t\t\turl: params[0],\n\t\t});\n\n\t\treturn construct(instance, params[1]) as any;\n\t}\n\n\tif (isConfig(params[0])) {\n\t\tconst { connection, client, ...drizzleConfig } = params[0] as\n\t\t\t& { connection?: Config | string; client?: TClient }\n\t\t\t& DrizzleConfig;\n\n\t\tif (client) return construct(client, drizzleConfig) as any;\n\n\t\tconst instance = typeof connection === 'string'\n\t\t\t? new Client({\n\t\t\t\turl: connection,\n\t\t\t})\n\t\t\t: new Client(\n\t\t\t\tconnection!,\n\t\t\t);\n\n\t\treturn construct(instance, drizzleConfig) as any;\n\t}\n\n\treturn construct(params[0] as TClient, params[1] as DrizzleConfig<TSchema, TRelations> | undefined) as any;\n}\n\nexport namespace drizzle {\n\texport function mock<\n\t\tTSchema extends Record<string, unknown> = Record<string, never>,\n\t\tTRelations extends AnyRelations = EmptyRelations,\n\t>(\n\t\tconfig?: DrizzleConfig<TSchema, TRelations>,\n\t): PlanetScaleDatabase<TSchema, TRelations> & {\n\t\t$client: '$client is not available on drizzle.mock()';\n\t} {\n\t\treturn construct({} as any, config) as any;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sBAAuB;AACvB,SAAoB;AACpB,oBAA2B;AAE3B,oBAA8B;AAC9B,gBAA8B;AAC9B,qBAA6B;AAE7B,mBAA6C;AAE7C,qBAAmC;AAM5B,MAAM,4BAGH,wBAA2F;AAAA,EACpG,QAA0B,wBAAU,IAAY;AACjD;AAEA,SAAS,UAKR,QACA,SAA6C,CAAC,GAG7C;AAGD,MAAI,EAAE,kBAAkB,yBAAS;AAChC,UAAM,IAAI,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GAWf;AAAA,EACF;AAEA,QAAM,UAAU,IAAI,4BAAa,EAAE,QAAQ,OAAO,OAAO,CAAC;AAC1D,MAAI;AACJ,MAAI,OAAO,WAAW,MAAM;AAC3B,aAAS,IAAI,4BAAc;AAAA,EAC5B,WAAW,OAAO,WAAW,OAAO;AACnC,aAAS,OAAO;AAAA,EACjB;AAEA,MAAI;AACJ,MAAI,OAAO,QAAQ;AAClB,UAAM,eAAe,GAAG;AAAA,MACvB,OAAO;AAAA,MACP,GAAG;AAAA,IACJ;AACA,aAAS;AAAA,MACR,YAAY,OAAO;AAAA,MACnB,QAAQ,aAAa;AAAA,MACrB,eAAe,aAAa;AAAA,IAC7B;AAAA,EACD;AAEA,QAAM,YAAY,OAAO;AACzB,QAAM,UAAU,IAAI,kCAAmB,QAAQ,SAAS,QAAW,WAAW,QAAQ,EAAE,OAAO,CAAC;AAChG,QAAM,KAAK,IAAI;AAAA,IACd;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACA,EAAO,GAAI,UAAU;AAErB,SAAO;AACR;AAEO,SAAS,WAKZ,QAiBF;AACD,MAAI,OAAO,OAAO,CAAC,MAAM,UAAU;AAClC,UAAM,WAAW,IAAI,uBAAO;AAAA,MAC3B,KAAK,OAAO,CAAC;AAAA,IACd,CAAC;AAED,WAAO,UAAU,UAAU,OAAO,CAAC,CAAC;AAAA,EACrC;AAEA,UAAI,uBAAS,OAAO,CAAC,CAAC,GAAG;AACxB,UAAM,EAAE,YAAY,QAAQ,GAAG,cAAc,IAAI,OAAO,CAAC;AAIzD,QAAI;AAAQ,aAAO,UAAU,QAAQ,aAAa;AAElD,UAAM,WAAW,OAAO,eAAe,WACpC,IAAI,uBAAO;AAAA,MACZ,KAAK;AAAA,IACN,CAAC,IACC,IAAI;AAAA,MACL;AAAA,IACD;AAED,WAAO,UAAU,UAAU,aAAa;AAAA,EACzC;AAEA,SAAO,UAAU,OAAO,CAAC,GAAc,OAAO,CAAC,CAAmD;AACnG;AAAA,CAEO,CAAUA,aAAV;AACC,WAAS,KAIf,QAGC;AACD,WAAO,UAAU,CAAC,GAAU,MAAM;AAAA,EACnC;AATO,EAAAA,SAAS;AAAA,GADA;","names":["drizzle"]}
|
|
@@ -3,30 +3,31 @@ import { Client } from '@planetscale/database';
|
|
|
3
3
|
import { entityKind } from "../entity.cjs";
|
|
4
4
|
import type { Logger } from "../logger.cjs";
|
|
5
5
|
import { MySqlDatabase } from "../mysql-core/db.cjs";
|
|
6
|
+
import type { AnyRelations, EmptyRelations } from "../relations.cjs";
|
|
6
7
|
import { type DrizzleConfig } from "../utils.cjs";
|
|
7
8
|
import type { PlanetScalePreparedQueryHKT, PlanetscaleQueryResultHKT } from "./session.cjs";
|
|
8
9
|
export interface PlanetscaleSDriverOptions {
|
|
9
10
|
logger?: Logger;
|
|
10
11
|
}
|
|
11
|
-
export declare class PlanetScaleDatabase<TSchema extends Record<string, unknown> = Record<string, never
|
|
12
|
+
export declare class PlanetScaleDatabase<TSchema extends Record<string, unknown> = Record<string, never>, TRelations extends AnyRelations = EmptyRelations> extends MySqlDatabase<PlanetscaleQueryResultHKT, PlanetScalePreparedQueryHKT, TSchema, TRelations> {
|
|
12
13
|
static readonly [entityKind]: string;
|
|
13
14
|
}
|
|
14
|
-
export declare function drizzle<TSchema extends Record<string, unknown> = Record<string, never>, TClient extends Client = Client>(...params: [
|
|
15
|
+
export declare function drizzle<TSchema extends Record<string, unknown> = Record<string, never>, TRelations extends AnyRelations = EmptyRelations, TClient extends Client = Client>(...params: [
|
|
15
16
|
TClient | string
|
|
16
17
|
] | [
|
|
17
18
|
TClient | string,
|
|
18
|
-
DrizzleConfig<TSchema>
|
|
19
|
+
DrizzleConfig<TSchema, TRelations>
|
|
19
20
|
] | [
|
|
20
|
-
(DrizzleConfig<TSchema> & ({
|
|
21
|
+
(DrizzleConfig<TSchema, TRelations> & ({
|
|
21
22
|
connection: string | Config;
|
|
22
23
|
} | {
|
|
23
24
|
client: TClient;
|
|
24
25
|
}))
|
|
25
|
-
]): PlanetScaleDatabase<TSchema> & {
|
|
26
|
+
]): PlanetScaleDatabase<TSchema, TRelations> & {
|
|
26
27
|
$client: TClient;
|
|
27
28
|
};
|
|
28
29
|
export declare namespace drizzle {
|
|
29
|
-
function mock<TSchema extends Record<string, unknown> = Record<string, never
|
|
30
|
+
function mock<TSchema extends Record<string, unknown> = Record<string, never>, TRelations extends AnyRelations = EmptyRelations>(config?: DrizzleConfig<TSchema, TRelations>): PlanetScaleDatabase<TSchema, TRelations> & {
|
|
30
31
|
$client: '$client is not available on drizzle.mock()';
|
|
31
32
|
};
|
|
32
33
|
}
|
|
@@ -3,30 +3,31 @@ import { Client } from '@planetscale/database';
|
|
|
3
3
|
import { entityKind } from "../entity.js";
|
|
4
4
|
import type { Logger } from "../logger.js";
|
|
5
5
|
import { MySqlDatabase } from "../mysql-core/db.js";
|
|
6
|
+
import type { AnyRelations, EmptyRelations } from "../relations.js";
|
|
6
7
|
import { type DrizzleConfig } from "../utils.js";
|
|
7
8
|
import type { PlanetScalePreparedQueryHKT, PlanetscaleQueryResultHKT } from "./session.js";
|
|
8
9
|
export interface PlanetscaleSDriverOptions {
|
|
9
10
|
logger?: Logger;
|
|
10
11
|
}
|
|
11
|
-
export declare class PlanetScaleDatabase<TSchema extends Record<string, unknown> = Record<string, never
|
|
12
|
+
export declare class PlanetScaleDatabase<TSchema extends Record<string, unknown> = Record<string, never>, TRelations extends AnyRelations = EmptyRelations> extends MySqlDatabase<PlanetscaleQueryResultHKT, PlanetScalePreparedQueryHKT, TSchema, TRelations> {
|
|
12
13
|
static readonly [entityKind]: string;
|
|
13
14
|
}
|
|
14
|
-
export declare function drizzle<TSchema extends Record<string, unknown> = Record<string, never>, TClient extends Client = Client>(...params: [
|
|
15
|
+
export declare function drizzle<TSchema extends Record<string, unknown> = Record<string, never>, TRelations extends AnyRelations = EmptyRelations, TClient extends Client = Client>(...params: [
|
|
15
16
|
TClient | string
|
|
16
17
|
] | [
|
|
17
18
|
TClient | string,
|
|
18
|
-
DrizzleConfig<TSchema>
|
|
19
|
+
DrizzleConfig<TSchema, TRelations>
|
|
19
20
|
] | [
|
|
20
|
-
(DrizzleConfig<TSchema> & ({
|
|
21
|
+
(DrizzleConfig<TSchema, TRelations> & ({
|
|
21
22
|
connection: string | Config;
|
|
22
23
|
} | {
|
|
23
24
|
client: TClient;
|
|
24
25
|
}))
|
|
25
|
-
]): PlanetScaleDatabase<TSchema> & {
|
|
26
|
+
]): PlanetScaleDatabase<TSchema, TRelations> & {
|
|
26
27
|
$client: TClient;
|
|
27
28
|
};
|
|
28
29
|
export declare namespace drizzle {
|
|
29
|
-
function mock<TSchema extends Record<string, unknown> = Record<string, never
|
|
30
|
+
function mock<TSchema extends Record<string, unknown> = Record<string, never>, TRelations extends AnyRelations = EmptyRelations>(config?: DrizzleConfig<TSchema, TRelations>): PlanetScaleDatabase<TSchema, TRelations> & {
|
|
30
31
|
$client: '$client is not available on drizzle.mock()';
|
|
31
32
|
};
|
|
32
33
|
}
|