drizzle-orm 0.40.0 → 1.0.0-beta.1-cacd055
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/casing.cjs +3 -0
- package/casing.cjs.map +1 -1
- package/casing.d.cts +1 -1
- package/casing.d.ts +1 -1
- package/casing.js +4 -1
- package/casing.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/gel/driver.cjs +17 -6
- package/gel/driver.cjs.map +1 -1
- package/gel/driver.d.cts +8 -7
- package/gel/driver.d.ts +8 -7
- package/gel/driver.js +7 -9
- package/gel/driver.js.map +1 -1
- package/gel/migrator.cjs.map +1 -1
- package/gel/migrator.d.cts +1 -1
- package/gel/migrator.d.ts +1 -1
- package/gel/migrator.js.map +1 -1
- package/gel/session.cjs +46 -4
- package/gel/session.cjs.map +1 -1
- package/gel/session.d.cts +13 -8
- package/gel/session.d.ts +13 -8
- package/gel/session.js +46 -4
- package/gel/session.js.map +1 -1
- package/gel-core/columns/timestamptz.cjs +5 -0
- package/gel-core/columns/timestamptz.cjs.map +1 -1
- package/gel-core/columns/timestamptz.d.cts +1 -0
- package/gel-core/columns/timestamptz.d.ts +1 -0
- package/gel-core/columns/timestamptz.js +5 -0
- package/gel-core/columns/timestamptz.js.map +1 -1
- package/gel-core/db.cjs +28 -4
- package/gel-core/db.cjs.map +1 -1
- package/gel-core/db.d.cts +16 -9
- package/gel-core/db.d.ts +16 -9
- package/gel-core/db.js +27 -3
- package/gel-core/db.js.map +1 -1
- package/gel-core/dialect.cjs +172 -488
- package/gel-core/dialect.cjs.map +1 -1
- package/gel-core/dialect.d.cts +26 -8
- package/gel-core/dialect.d.ts +26 -8
- package/gel-core/dialect.js +170 -495
- package/gel-core/dialect.js.map +1 -1
- package/gel-core/query-builders/_query.cjs +149 -0
- package/gel-core/query-builders/_query.cjs.map +1 -0
- package/gel-core/query-builders/_query.d.cts +46 -0
- package/gel-core/query-builders/_query.d.ts +46 -0
- package/gel-core/query-builders/_query.js +114 -0
- package/gel-core/query-builders/_query.js.map +1 -0
- package/gel-core/query-builders/query.cjs +27 -24
- package/gel-core/query-builders/query.cjs.map +1 -1
- package/gel-core/query-builders/query.d.cts +9 -8
- package/gel-core/query-builders/query.d.ts +9 -8
- package/gel-core/query-builders/query.js +26 -23
- package/gel-core/query-builders/query.js.map +1 -1
- package/gel-core/session.cjs +3 -2
- package/gel-core/session.cjs.map +1 -1
- package/gel-core/session.d.cts +9 -6
- package/gel-core/session.d.ts +9 -6
- package/gel-core/session.js +3 -2
- package/gel-core/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/columns/binary.cjs +11 -0
- package/mysql-core/columns/binary.cjs.map +1 -1
- package/mysql-core/columns/binary.d.cts +1 -0
- package/mysql-core/columns/binary.d.ts +1 -0
- package/mysql-core/columns/binary.js +11 -0
- package/mysql-core/columns/binary.js.map +1 -1
- package/mysql-core/columns/decimal.cjs +5 -0
- package/mysql-core/columns/decimal.cjs.map +1 -1
- package/mysql-core/columns/decimal.d.cts +1 -0
- package/mysql-core/columns/decimal.d.ts +1 -0
- package/mysql-core/columns/decimal.js +5 -0
- package/mysql-core/columns/decimal.js.map +1 -1
- package/mysql-core/columns/float.cjs +6 -0
- package/mysql-core/columns/float.cjs.map +1 -1
- package/mysql-core/columns/float.d.cts +1 -0
- package/mysql-core/columns/float.d.ts +1 -0
- package/mysql-core/columns/float.js +6 -0
- package/mysql-core/columns/float.js.map +1 -1
- package/mysql-core/columns/varbinary.cjs +11 -0
- package/mysql-core/columns/varbinary.cjs.map +1 -1
- package/mysql-core/columns/varbinary.d.cts +1 -0
- package/mysql-core/columns/varbinary.d.ts +1 -0
- package/mysql-core/columns/varbinary.js +11 -0
- package/mysql-core/columns/varbinary.js.map +1 -1
- package/mysql-core/columns/varchar.cjs.map +1 -1
- package/mysql-core/columns/varchar.d.cts +1 -1
- package/mysql-core/columns/varchar.d.ts +1 -1
- package/mysql-core/columns/varchar.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 +208 -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 +206 -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 +64 -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 +64 -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 +69 -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 +69 -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 +111 -51
- package/pg-core/columns/numeric.cjs +5 -0
- package/pg-core/columns/numeric.cjs.map +1 -1
- package/pg-core/columns/numeric.d.cts +1 -0
- package/pg-core/columns/numeric.d.ts +1 -0
- package/pg-core/columns/numeric.js +5 -0
- package/pg-core/columns/numeric.js.map +1 -1
- package/pg-core/columns/postgis_extension/geometry.cjs +2 -0
- package/pg-core/columns/postgis_extension/geometry.cjs.map +1 -1
- package/pg-core/columns/postgis_extension/geometry.d.cts +1 -1
- package/pg-core/columns/postgis_extension/geometry.d.ts +1 -1
- package/pg-core/columns/postgis_extension/geometry.js +2 -0
- package/pg-core/columns/postgis_extension/geometry.js.map +1 -1
- 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 +190 -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 +189 -495
- package/pg-core/dialect.js.map +1 -1
- package/pg-core/query-builders/_query.cjs +155 -0
- 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/pg-core/query-builders/_query.js +120 -0
- 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-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 +48 -5
- 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 +48 -5
- 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 +7 -6
- 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 +7 -9
- 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 +657 -245
- package/relations.cjs.map +1 -1
- package/relations.d.cts +339 -140
- package/relations.d.ts +339 -140
- package/relations.js +643 -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/columns/blob.cjs +12 -0
- package/sqlite-core/columns/blob.cjs.map +1 -1
- package/sqlite-core/columns/blob.d.cts +2 -1
- package/sqlite-core/columns/blob.d.ts +2 -1
- package/sqlite-core/columns/blob.js +12 -0
- package/sqlite-core/columns/blob.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 +193 -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 +191 -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 +58 -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 +58 -4
- package/vercel-postgres/session.js.map +1 -1
- package/version.cjs +2 -2
- package/version.cjs.map +1 -1
- package/version.d.cts +2 -2
- package/version.d.ts +2 -2
- package/version.js +2 -2
- package/version.js.map +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
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import * as V1 from "../../_relations.js";
|
|
2
|
+
import { entityKind } from "../../entity.js";
|
|
3
|
+
import { QueryPromise } from "../../query-promise.js";
|
|
4
|
+
class _RelationalQueryBuilder {
|
|
5
|
+
constructor(fullSchema, schema, tableNamesMap, table, tableConfig, dialect, session, mode) {
|
|
6
|
+
this.fullSchema = fullSchema;
|
|
7
|
+
this.schema = schema;
|
|
8
|
+
this.tableNamesMap = tableNamesMap;
|
|
9
|
+
this.table = table;
|
|
10
|
+
this.tableConfig = tableConfig;
|
|
11
|
+
this.dialect = dialect;
|
|
12
|
+
this.session = session;
|
|
13
|
+
this.mode = mode;
|
|
14
|
+
}
|
|
15
|
+
static [entityKind] = "MySqlRelationalQueryBuilder";
|
|
16
|
+
findMany(config) {
|
|
17
|
+
return new MySqlRelationalQuery(
|
|
18
|
+
this.fullSchema,
|
|
19
|
+
this.schema,
|
|
20
|
+
this.tableNamesMap,
|
|
21
|
+
this.table,
|
|
22
|
+
this.tableConfig,
|
|
23
|
+
this.dialect,
|
|
24
|
+
this.session,
|
|
25
|
+
config ? config : {},
|
|
26
|
+
"many",
|
|
27
|
+
this.mode
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
findFirst(config) {
|
|
31
|
+
return new MySqlRelationalQuery(
|
|
32
|
+
this.fullSchema,
|
|
33
|
+
this.schema,
|
|
34
|
+
this.tableNamesMap,
|
|
35
|
+
this.table,
|
|
36
|
+
this.tableConfig,
|
|
37
|
+
this.dialect,
|
|
38
|
+
this.session,
|
|
39
|
+
config ? { ...config, limit: 1 } : { limit: 1 },
|
|
40
|
+
"first",
|
|
41
|
+
this.mode
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
class MySqlRelationalQuery extends QueryPromise {
|
|
46
|
+
constructor(fullSchema, schema, tableNamesMap, table, tableConfig, dialect, session, config, queryMode, mode) {
|
|
47
|
+
super();
|
|
48
|
+
this.fullSchema = fullSchema;
|
|
49
|
+
this.schema = schema;
|
|
50
|
+
this.tableNamesMap = tableNamesMap;
|
|
51
|
+
this.table = table;
|
|
52
|
+
this.tableConfig = tableConfig;
|
|
53
|
+
this.dialect = dialect;
|
|
54
|
+
this.session = session;
|
|
55
|
+
this.config = config;
|
|
56
|
+
this.queryMode = queryMode;
|
|
57
|
+
this.mode = mode;
|
|
58
|
+
}
|
|
59
|
+
static [entityKind] = "MySqlRelationalQuery";
|
|
60
|
+
prepare() {
|
|
61
|
+
const { query, builtQuery } = this._toSQL();
|
|
62
|
+
return this.session.prepareQuery(
|
|
63
|
+
builtQuery,
|
|
64
|
+
void 0,
|
|
65
|
+
(rawRows) => {
|
|
66
|
+
const rows = rawRows.map((row) => V1.mapRelationalRow(this.schema, this.tableConfig, row, query.selection));
|
|
67
|
+
if (this.queryMode === "first") {
|
|
68
|
+
return rows[0];
|
|
69
|
+
}
|
|
70
|
+
return rows;
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
_getQuery() {
|
|
75
|
+
const query = this.mode === "planetscale" ? this.dialect._buildRelationalQueryWithoutLateralSubqueries({
|
|
76
|
+
fullSchema: this.fullSchema,
|
|
77
|
+
schema: this.schema,
|
|
78
|
+
tableNamesMap: this.tableNamesMap,
|
|
79
|
+
table: this.table,
|
|
80
|
+
tableConfig: this.tableConfig,
|
|
81
|
+
queryConfig: this.config,
|
|
82
|
+
tableAlias: this.tableConfig.tsName
|
|
83
|
+
}) : this.dialect._buildRelationalQuery({
|
|
84
|
+
fullSchema: this.fullSchema,
|
|
85
|
+
schema: this.schema,
|
|
86
|
+
tableNamesMap: this.tableNamesMap,
|
|
87
|
+
table: this.table,
|
|
88
|
+
tableConfig: this.tableConfig,
|
|
89
|
+
queryConfig: this.config,
|
|
90
|
+
tableAlias: this.tableConfig.tsName
|
|
91
|
+
});
|
|
92
|
+
return query;
|
|
93
|
+
}
|
|
94
|
+
_toSQL() {
|
|
95
|
+
const query = this._getQuery();
|
|
96
|
+
const builtQuery = this.dialect.sqlToQuery(query.sql);
|
|
97
|
+
return { builtQuery, query };
|
|
98
|
+
}
|
|
99
|
+
/** @internal */
|
|
100
|
+
getSQL() {
|
|
101
|
+
return this._getQuery().sql;
|
|
102
|
+
}
|
|
103
|
+
toSQL() {
|
|
104
|
+
return this._toSQL().builtQuery;
|
|
105
|
+
}
|
|
106
|
+
execute() {
|
|
107
|
+
return this.prepare().execute();
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
export {
|
|
111
|
+
MySqlRelationalQuery,
|
|
112
|
+
_RelationalQueryBuilder
|
|
113
|
+
};
|
|
114
|
+
//# sourceMappingURL=_query.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/mysql-core/query-builders/_query.ts"],"sourcesContent":["import * as V1 from '~/_relations.ts';\nimport { entityKind } from '~/entity.ts';\nimport { QueryPromise } from '~/query-promise.ts';\nimport type { Query, QueryWithTypings, SQL } from '~/sql/sql.ts';\nimport type { KnownKeysOnly } from '~/utils.ts';\nimport type { MySqlDialect } from '../dialect.ts';\nimport type {\n\tMode,\n\tMySqlPreparedQueryConfig,\n\tMySqlSession,\n\tPreparedQueryHKTBase,\n\tPreparedQueryKind,\n} from '../session.ts';\nimport type { MySqlTable } from '../table.ts';\n\nexport class _RelationalQueryBuilder<\n\tTPreparedQueryHKT extends PreparedQueryHKTBase,\n\tTSchema extends V1.TablesRelationalConfig,\n\tTFields extends V1.TableRelationalConfig,\n> {\n\tstatic readonly [entityKind]: string = 'MySqlRelationalQueryBuilder';\n\n\tconstructor(\n\t\tprivate fullSchema: Record<string, unknown>,\n\t\tprivate schema: TSchema,\n\t\tprivate tableNamesMap: Record<string, string>,\n\t\tprivate table: MySqlTable,\n\t\tprivate tableConfig: V1.TableRelationalConfig,\n\t\tprivate dialect: MySqlDialect,\n\t\tprivate session: MySqlSession,\n\t\tprivate mode: Mode,\n\t) {}\n\n\tfindMany<TConfig extends V1.DBQueryConfig<'many', true, TSchema, TFields>>(\n\t\tconfig?: KnownKeysOnly<TConfig, V1.DBQueryConfig<'many', true, TSchema, TFields>>,\n\t): MySqlRelationalQuery<TPreparedQueryHKT, V1.BuildQueryResult<TSchema, TFields, TConfig>[]> {\n\t\treturn new MySqlRelationalQuery(\n\t\t\tthis.fullSchema,\n\t\t\tthis.schema,\n\t\t\tthis.tableNamesMap,\n\t\t\tthis.table,\n\t\t\tthis.tableConfig,\n\t\t\tthis.dialect,\n\t\t\tthis.session,\n\t\t\tconfig ? (config as V1.DBQueryConfig<'many', true>) : {},\n\t\t\t'many',\n\t\t\tthis.mode,\n\t\t);\n\t}\n\n\tfindFirst<TSelection extends Omit<V1.DBQueryConfig<'many', true, TSchema, TFields>, 'limit'>>(\n\t\tconfig?: KnownKeysOnly<TSelection, Omit<V1.DBQueryConfig<'many', true, TSchema, TFields>, 'limit'>>,\n\t): MySqlRelationalQuery<TPreparedQueryHKT, V1.BuildQueryResult<TSchema, TFields, TSelection> | undefined> {\n\t\treturn new MySqlRelationalQuery(\n\t\t\tthis.fullSchema,\n\t\t\tthis.schema,\n\t\t\tthis.tableNamesMap,\n\t\t\tthis.table,\n\t\t\tthis.tableConfig,\n\t\t\tthis.dialect,\n\t\t\tthis.session,\n\t\t\tconfig ? { ...(config as V1.DBQueryConfig<'many', true> | undefined), limit: 1 } : { limit: 1 },\n\t\t\t'first',\n\t\t\tthis.mode,\n\t\t);\n\t}\n}\n\nexport class MySqlRelationalQuery<\n\tTPreparedQueryHKT extends PreparedQueryHKTBase,\n\tTResult,\n> extends QueryPromise<TResult> {\n\tstatic override readonly [entityKind]: string = 'MySqlRelationalQuery';\n\n\tdeclare protected $brand: 'MySqlRelationalQuery';\n\n\tconstructor(\n\t\tprivate fullSchema: Record<string, unknown>,\n\t\tprivate schema: V1.TablesRelationalConfig,\n\t\tprivate tableNamesMap: Record<string, string>,\n\t\tprivate table: MySqlTable,\n\t\tprivate tableConfig: V1.TableRelationalConfig,\n\t\tprivate dialect: MySqlDialect,\n\t\tprivate session: MySqlSession,\n\t\tprivate config: V1.DBQueryConfig<'many', true> | true,\n\t\tprivate queryMode: 'many' | 'first',\n\t\tprivate mode?: Mode,\n\t) {\n\t\tsuper();\n\t}\n\n\tprepare() {\n\t\tconst { query, builtQuery } = this._toSQL();\n\t\treturn this.session.prepareQuery(\n\t\t\tbuiltQuery,\n\t\t\tundefined,\n\t\t\t(rawRows) => {\n\t\t\t\tconst rows = rawRows.map((row) => V1.mapRelationalRow(this.schema, this.tableConfig, row, query.selection));\n\t\t\t\tif (this.queryMode === 'first') {\n\t\t\t\t\treturn rows[0] as TResult;\n\t\t\t\t}\n\t\t\t\treturn rows as TResult;\n\t\t\t},\n\t\t) as PreparedQueryKind<TPreparedQueryHKT, MySqlPreparedQueryConfig & { execute: TResult }, true>;\n\t}\n\n\tprivate _getQuery() {\n\t\tconst query = this.mode === 'planetscale'\n\t\t\t? this.dialect._buildRelationalQueryWithoutLateralSubqueries({\n\t\t\t\tfullSchema: this.fullSchema,\n\t\t\t\tschema: this.schema,\n\t\t\t\ttableNamesMap: this.tableNamesMap,\n\t\t\t\ttable: this.table,\n\t\t\t\ttableConfig: this.tableConfig,\n\t\t\t\tqueryConfig: this.config,\n\t\t\t\ttableAlias: this.tableConfig.tsName,\n\t\t\t})\n\t\t\t: this.dialect._buildRelationalQuery({\n\t\t\t\tfullSchema: this.fullSchema,\n\t\t\t\tschema: this.schema,\n\t\t\t\ttableNamesMap: this.tableNamesMap,\n\t\t\t\ttable: this.table,\n\t\t\t\ttableConfig: this.tableConfig,\n\t\t\t\tqueryConfig: this.config,\n\t\t\t\ttableAlias: this.tableConfig.tsName,\n\t\t\t});\n\t\treturn query;\n\t}\n\n\tprivate _toSQL(): { query: V1.BuildRelationalQueryResult; builtQuery: QueryWithTypings } {\n\t\tconst query = this._getQuery();\n\n\t\tconst builtQuery = this.dialect.sqlToQuery(query.sql as SQL);\n\n\t\treturn { builtQuery, query };\n\t}\n\n\t/** @internal */\n\tgetSQL(): SQL {\n\t\treturn this._getQuery().sql as SQL;\n\t}\n\n\ttoSQL(): Query {\n\t\treturn this._toSQL().builtQuery;\n\t}\n\n\toverride execute(): Promise<TResult> {\n\t\treturn this.prepare().execute();\n\t}\n}\n"],"mappings":"AAAA,YAAY,QAAQ;AACpB,SAAS,kBAAkB;AAC3B,SAAS,oBAAoB;AAatB,MAAM,wBAIX;AAAA,EAGD,YACS,YACA,QACA,eACA,OACA,aACA,SACA,SACA,MACP;AARO;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA,EACN;AAAA,EAXH,QAAiB,UAAU,IAAY;AAAA,EAavC,SACC,QAC4F;AAC5F,WAAO,IAAI;AAAA,MACV,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,SAAU,SAA4C,CAAC;AAAA,MACvD;AAAA,MACA,KAAK;AAAA,IACN;AAAA,EACD;AAAA,EAEA,UACC,QACyG;AACzG,WAAO,IAAI;AAAA,MACV,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,SAAS,EAAE,GAAI,QAAuD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE;AAAA,MAC9F;AAAA,MACA,KAAK;AAAA,IACN;AAAA,EACD;AACD;AAEO,MAAM,6BAGH,aAAsB;AAAA,EAK/B,YACS,YACA,QACA,eACA,OACA,aACA,SACA,SACA,QACA,WACA,MACP;AACD,UAAM;AAXE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA,EAGT;AAAA,EAjBA,QAA0B,UAAU,IAAY;AAAA,EAmBhD,UAAU;AACT,UAAM,EAAE,OAAO,WAAW,IAAI,KAAK,OAAO;AAC1C,WAAO,KAAK,QAAQ;AAAA,MACnB;AAAA,MACA;AAAA,MACA,CAAC,YAAY;AACZ,cAAM,OAAO,QAAQ,IAAI,CAAC,QAAQ,GAAG,iBAAiB,KAAK,QAAQ,KAAK,aAAa,KAAK,MAAM,SAAS,CAAC;AAC1G,YAAI,KAAK,cAAc,SAAS;AAC/B,iBAAO,KAAK,CAAC;AAAA,QACd;AACA,eAAO;AAAA,MACR;AAAA,IACD;AAAA,EACD;AAAA,EAEQ,YAAY;AACnB,UAAM,QAAQ,KAAK,SAAS,gBACzB,KAAK,QAAQ,8CAA8C;AAAA,MAC5D,YAAY,KAAK;AAAA,MACjB,QAAQ,KAAK;AAAA,MACb,eAAe,KAAK;AAAA,MACpB,OAAO,KAAK;AAAA,MACZ,aAAa,KAAK;AAAA,MAClB,aAAa,KAAK;AAAA,MAClB,YAAY,KAAK,YAAY;AAAA,IAC9B,CAAC,IACC,KAAK,QAAQ,sBAAsB;AAAA,MACpC,YAAY,KAAK;AAAA,MACjB,QAAQ,KAAK;AAAA,MACb,eAAe,KAAK;AAAA,MACpB,OAAO,KAAK;AAAA,MACZ,aAAa,KAAK;AAAA,MAClB,aAAa,KAAK;AAAA,MAClB,YAAY,KAAK,YAAY;AAAA,IAC9B,CAAC;AACF,WAAO;AAAA,EACR;AAAA,EAEQ,SAAiF;AACxF,UAAM,QAAQ,KAAK,UAAU;AAE7B,UAAM,aAAa,KAAK,QAAQ,WAAW,MAAM,GAAU;AAE3D,WAAO,EAAE,YAAY,MAAM;AAAA,EAC5B;AAAA;AAAA,EAGA,SAAc;AACb,WAAO,KAAK,UAAU,EAAE;AAAA,EACzB;AAAA,EAEA,QAAe;AACd,WAAO,KAAK,OAAO,EAAE;AAAA,EACtB;AAAA,EAES,UAA4B;AACpC,WAAO,KAAK,QAAQ,EAAE,QAAQ;AAAA,EAC/B;AACD;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/mysql-core/query-builders/count.ts"],"sourcesContent":["import { entityKind } from '~/entity.ts';\nimport { SQL, sql, type SQLWrapper } from '~/sql/sql.ts';\nimport type { MySqlSession } from '../session.ts';\nimport type { MySqlTable } from '../table.ts';\nimport type { MySqlViewBase } from '../view-base.ts';\n\nexport class MySqlCountBuilder<\n\tTSession extends MySqlSession<any, any, any>,\n> extends SQL<number> implements Promise<number>, SQLWrapper {\n\tprivate sql: SQL<number>;\n\n\tstatic override readonly [entityKind] = 'MySqlCountBuilder';\n\t[Symbol.toStringTag] = 'MySqlCountBuilder';\n\n\tprivate session: TSession;\n\n\tprivate static buildEmbeddedCount(\n\t\tsource: MySqlTable | MySqlViewBase | SQL | SQLWrapper,\n\t\tfilters?: SQL<unknown>,\n\t): SQL<number> {\n\t\treturn sql<number>`(select count(*) from ${source}${sql.raw(' where ').if(filters)}${filters})`;\n\t}\n\n\tprivate static buildCount(\n\t\tsource: MySqlTable | MySqlViewBase | SQL | SQLWrapper,\n\t\tfilters?: SQL<unknown>,\n\t): SQL<number> {\n\t\treturn sql<number>`select count(*) as count from ${source}${sql.raw(' where ').if(filters)}${filters}`;\n\t}\n\n\tconstructor(\n\t\treadonly params: {\n\t\t\tsource: MySqlTable | MySqlViewBase | SQL | SQLWrapper;\n\t\t\tfilters?: SQL<unknown>;\n\t\t\tsession: TSession;\n\t\t},\n\t) {\n\t\tsuper(MySqlCountBuilder.buildEmbeddedCount(params.source, params.filters).queryChunks);\n\n\t\tthis.mapWith(Number);\n\n\t\tthis.session = params.session;\n\n\t\tthis.sql = MySqlCountBuilder.buildCount(\n\t\t\tparams.source,\n\t\t\tparams.filters,\n\t\t);\n\t}\n\n\tthen<TResult1 = number, TResult2 = never>(\n\t\tonfulfilled?: ((value: number) => TResult1 | PromiseLike<TResult1>) | null | undefined,\n\t\tonrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined,\n\t): Promise<TResult1 | TResult2> {\n\t\treturn Promise.resolve(this.session.count(this.sql))\n\t\t\t.then(\n\t\t\t\tonfulfilled,\n\t\t\t\tonrejected,\n\t\t\t);\n\t}\n\n\tcatch(\n\t\tonRejected?: ((reason: any) => never | PromiseLike<never>) | null | undefined,\n\t): Promise<number> {\n\t\treturn this.then(undefined, onRejected);\n\t}\n\n\tfinally(onFinally?: (() => void) | null | undefined): Promise<number> {\n\t\treturn this.then(\n\t\t\t(value) => {\n\t\t\t\tonFinally?.();\n\t\t\t\treturn value;\n\t\t\t},\n\t\t\t(reason) => {\n\t\t\t\tonFinally?.();\n\t\t\t\tthrow reason;\n\t\t\t},\n\t\t);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA2B;AAC3B,iBAA0C;AAKnC,MAAM,0BAEH,
|
|
1
|
+
{"version":3,"sources":["../../../src/mysql-core/query-builders/count.ts"],"sourcesContent":["import { entityKind } from '~/entity.ts';\nimport { SQL, sql, type SQLWrapper } from '~/sql/sql.ts';\nimport type { MySqlSession } from '../session.ts';\nimport type { MySqlTable } from '../table.ts';\nimport type { MySqlViewBase } from '../view-base.ts';\n\nexport class MySqlCountBuilder<\n\tTSession extends MySqlSession<any, any, any>,\n> extends SQL<number> implements Promise<number>, SQLWrapper<number> {\n\tprivate sql: SQL<number>;\n\n\tstatic override readonly [entityKind] = 'MySqlCountBuilder';\n\t[Symbol.toStringTag] = 'MySqlCountBuilder';\n\n\tprivate session: TSession;\n\n\tprivate static buildEmbeddedCount(\n\t\tsource: MySqlTable | MySqlViewBase | SQL | SQLWrapper,\n\t\tfilters?: SQL<unknown>,\n\t): SQL<number> {\n\t\treturn sql<number>`(select count(*) from ${source}${sql.raw(' where ').if(filters)}${filters})`;\n\t}\n\n\tprivate static buildCount(\n\t\tsource: MySqlTable | MySqlViewBase | SQL | SQLWrapper,\n\t\tfilters?: SQL<unknown>,\n\t): SQL<number> {\n\t\treturn sql<number>`select count(*) as count from ${source}${sql.raw(' where ').if(filters)}${filters}`;\n\t}\n\n\tconstructor(\n\t\treadonly params: {\n\t\t\tsource: MySqlTable | MySqlViewBase | SQL | SQLWrapper;\n\t\t\tfilters?: SQL<unknown>;\n\t\t\tsession: TSession;\n\t\t},\n\t) {\n\t\tsuper(MySqlCountBuilder.buildEmbeddedCount(params.source, params.filters).queryChunks);\n\n\t\tthis.mapWith(Number);\n\n\t\tthis.session = params.session;\n\n\t\tthis.sql = MySqlCountBuilder.buildCount(\n\t\t\tparams.source,\n\t\t\tparams.filters,\n\t\t);\n\t}\n\n\tthen<TResult1 = number, TResult2 = never>(\n\t\tonfulfilled?: ((value: number) => TResult1 | PromiseLike<TResult1>) | null | undefined,\n\t\tonrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined,\n\t): Promise<TResult1 | TResult2> {\n\t\treturn Promise.resolve(this.session.count(this.sql))\n\t\t\t.then(\n\t\t\t\tonfulfilled,\n\t\t\t\tonrejected,\n\t\t\t);\n\t}\n\n\tcatch(\n\t\tonRejected?: ((reason: any) => never | PromiseLike<never>) | null | undefined,\n\t): Promise<number> {\n\t\treturn this.then(undefined, onRejected);\n\t}\n\n\tfinally(onFinally?: (() => void) | null | undefined): Promise<number> {\n\t\treturn this.then(\n\t\t\t(value) => {\n\t\t\t\tonFinally?.();\n\t\t\t\treturn value;\n\t\t\t},\n\t\t\t(reason) => {\n\t\t\t\tonFinally?.();\n\t\t\t\tthrow reason;\n\t\t\t},\n\t\t);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA2B;AAC3B,iBAA0C;AAKnC,MAAM,0BAEH,eAA2D;AAAA,EAsBpE,YACU,QAKR;AACD,UAAM,kBAAkB,mBAAmB,OAAO,QAAQ,OAAO,OAAO,EAAE,WAAW;AAN5E;AAQT,SAAK,QAAQ,MAAM;AAEnB,SAAK,UAAU,OAAO;AAEtB,SAAK,MAAM,kBAAkB;AAAA,MAC5B,OAAO;AAAA,MACP,OAAO;AAAA,IACR;AAAA,EACD;AAAA,EAtCQ;AAAA,EAER,QAA0B,wBAAU,IAAI;AAAA,EACxC,CAAC,OAAO,WAAW,IAAI;AAAA,EAEf;AAAA,EAER,OAAe,mBACd,QACA,SACc;AACd,WAAO,uCAAoC,MAAM,GAAG,eAAI,IAAI,SAAS,EAAE,GAAG,OAAO,CAAC,GAAG,OAAO;AAAA,EAC7F;AAAA,EAEA,OAAe,WACd,QACA,SACc;AACd,WAAO,+CAA4C,MAAM,GAAG,eAAI,IAAI,SAAS,EAAE,GAAG,OAAO,CAAC,GAAG,OAAO;AAAA,EACrG;AAAA,EAqBA,KACC,aACA,YAC+B;AAC/B,WAAO,QAAQ,QAAQ,KAAK,QAAQ,MAAM,KAAK,GAAG,CAAC,EACjD;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EACF;AAAA,EAEA,MACC,YACkB;AAClB,WAAO,KAAK,KAAK,QAAW,UAAU;AAAA,EACvC;AAAA,EAEA,QAAQ,WAA8D;AACrE,WAAO,KAAK;AAAA,MACX,CAAC,UAAU;AACV,oBAAY;AACZ,eAAO;AAAA,MACR;AAAA,MACA,CAAC,WAAW;AACX,oBAAY;AACZ,cAAM;AAAA,MACP;AAAA,IACD;AAAA,EACD;AACD;","names":[]}
|
|
@@ -3,7 +3,7 @@ import { SQL, type SQLWrapper } from "../../sql/sql.cjs";
|
|
|
3
3
|
import type { MySqlSession } from "../session.cjs";
|
|
4
4
|
import type { MySqlTable } from "../table.cjs";
|
|
5
5
|
import type { MySqlViewBase } from "../view-base.cjs";
|
|
6
|
-
export declare class MySqlCountBuilder<TSession extends MySqlSession<any, any, any>> extends SQL<number> implements Promise<number>, SQLWrapper {
|
|
6
|
+
export declare class MySqlCountBuilder<TSession extends MySqlSession<any, any, any>> extends SQL<number> implements Promise<number>, SQLWrapper<number> {
|
|
7
7
|
readonly params: {
|
|
8
8
|
source: MySqlTable | MySqlViewBase | SQL | SQLWrapper;
|
|
9
9
|
filters?: SQL<unknown>;
|
|
@@ -3,7 +3,7 @@ import { SQL, type SQLWrapper } from "../../sql/sql.js";
|
|
|
3
3
|
import type { MySqlSession } from "../session.js";
|
|
4
4
|
import type { MySqlTable } from "../table.js";
|
|
5
5
|
import type { MySqlViewBase } from "../view-base.js";
|
|
6
|
-
export declare class MySqlCountBuilder<TSession extends MySqlSession<any, any, any>> extends SQL<number> implements Promise<number>, SQLWrapper {
|
|
6
|
+
export declare class MySqlCountBuilder<TSession extends MySqlSession<any, any, any>> extends SQL<number> implements Promise<number>, SQLWrapper<number> {
|
|
7
7
|
readonly params: {
|
|
8
8
|
source: MySqlTable | MySqlViewBase | SQL | SQLWrapper;
|
|
9
9
|
filters?: SQL<unknown>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/mysql-core/query-builders/count.ts"],"sourcesContent":["import { entityKind } from '~/entity.ts';\nimport { SQL, sql, type SQLWrapper } from '~/sql/sql.ts';\nimport type { MySqlSession } from '../session.ts';\nimport type { MySqlTable } from '../table.ts';\nimport type { MySqlViewBase } from '../view-base.ts';\n\nexport class MySqlCountBuilder<\n\tTSession extends MySqlSession<any, any, any>,\n> extends SQL<number> implements Promise<number>, SQLWrapper {\n\tprivate sql: SQL<number>;\n\n\tstatic override readonly [entityKind] = 'MySqlCountBuilder';\n\t[Symbol.toStringTag] = 'MySqlCountBuilder';\n\n\tprivate session: TSession;\n\n\tprivate static buildEmbeddedCount(\n\t\tsource: MySqlTable | MySqlViewBase | SQL | SQLWrapper,\n\t\tfilters?: SQL<unknown>,\n\t): SQL<number> {\n\t\treturn sql<number>`(select count(*) from ${source}${sql.raw(' where ').if(filters)}${filters})`;\n\t}\n\n\tprivate static buildCount(\n\t\tsource: MySqlTable | MySqlViewBase | SQL | SQLWrapper,\n\t\tfilters?: SQL<unknown>,\n\t): SQL<number> {\n\t\treturn sql<number>`select count(*) as count from ${source}${sql.raw(' where ').if(filters)}${filters}`;\n\t}\n\n\tconstructor(\n\t\treadonly params: {\n\t\t\tsource: MySqlTable | MySqlViewBase | SQL | SQLWrapper;\n\t\t\tfilters?: SQL<unknown>;\n\t\t\tsession: TSession;\n\t\t},\n\t) {\n\t\tsuper(MySqlCountBuilder.buildEmbeddedCount(params.source, params.filters).queryChunks);\n\n\t\tthis.mapWith(Number);\n\n\t\tthis.session = params.session;\n\n\t\tthis.sql = MySqlCountBuilder.buildCount(\n\t\t\tparams.source,\n\t\t\tparams.filters,\n\t\t);\n\t}\n\n\tthen<TResult1 = number, TResult2 = never>(\n\t\tonfulfilled?: ((value: number) => TResult1 | PromiseLike<TResult1>) | null | undefined,\n\t\tonrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined,\n\t): Promise<TResult1 | TResult2> {\n\t\treturn Promise.resolve(this.session.count(this.sql))\n\t\t\t.then(\n\t\t\t\tonfulfilled,\n\t\t\t\tonrejected,\n\t\t\t);\n\t}\n\n\tcatch(\n\t\tonRejected?: ((reason: any) => never | PromiseLike<never>) | null | undefined,\n\t): Promise<number> {\n\t\treturn this.then(undefined, onRejected);\n\t}\n\n\tfinally(onFinally?: (() => void) | null | undefined): Promise<number> {\n\t\treturn this.then(\n\t\t\t(value) => {\n\t\t\t\tonFinally?.();\n\t\t\t\treturn value;\n\t\t\t},\n\t\t\t(reason) => {\n\t\t\t\tonFinally?.();\n\t\t\t\tthrow reason;\n\t\t\t},\n\t\t);\n\t}\n}\n"],"mappings":"AAAA,SAAS,kBAAkB;AAC3B,SAAS,KAAK,WAA4B;AAKnC,MAAM,0BAEH,
|
|
1
|
+
{"version":3,"sources":["../../../src/mysql-core/query-builders/count.ts"],"sourcesContent":["import { entityKind } from '~/entity.ts';\nimport { SQL, sql, type SQLWrapper } from '~/sql/sql.ts';\nimport type { MySqlSession } from '../session.ts';\nimport type { MySqlTable } from '../table.ts';\nimport type { MySqlViewBase } from '../view-base.ts';\n\nexport class MySqlCountBuilder<\n\tTSession extends MySqlSession<any, any, any>,\n> extends SQL<number> implements Promise<number>, SQLWrapper<number> {\n\tprivate sql: SQL<number>;\n\n\tstatic override readonly [entityKind] = 'MySqlCountBuilder';\n\t[Symbol.toStringTag] = 'MySqlCountBuilder';\n\n\tprivate session: TSession;\n\n\tprivate static buildEmbeddedCount(\n\t\tsource: MySqlTable | MySqlViewBase | SQL | SQLWrapper,\n\t\tfilters?: SQL<unknown>,\n\t): SQL<number> {\n\t\treturn sql<number>`(select count(*) from ${source}${sql.raw(' where ').if(filters)}${filters})`;\n\t}\n\n\tprivate static buildCount(\n\t\tsource: MySqlTable | MySqlViewBase | SQL | SQLWrapper,\n\t\tfilters?: SQL<unknown>,\n\t): SQL<number> {\n\t\treturn sql<number>`select count(*) as count from ${source}${sql.raw(' where ').if(filters)}${filters}`;\n\t}\n\n\tconstructor(\n\t\treadonly params: {\n\t\t\tsource: MySqlTable | MySqlViewBase | SQL | SQLWrapper;\n\t\t\tfilters?: SQL<unknown>;\n\t\t\tsession: TSession;\n\t\t},\n\t) {\n\t\tsuper(MySqlCountBuilder.buildEmbeddedCount(params.source, params.filters).queryChunks);\n\n\t\tthis.mapWith(Number);\n\n\t\tthis.session = params.session;\n\n\t\tthis.sql = MySqlCountBuilder.buildCount(\n\t\t\tparams.source,\n\t\t\tparams.filters,\n\t\t);\n\t}\n\n\tthen<TResult1 = number, TResult2 = never>(\n\t\tonfulfilled?: ((value: number) => TResult1 | PromiseLike<TResult1>) | null | undefined,\n\t\tonrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined,\n\t): Promise<TResult1 | TResult2> {\n\t\treturn Promise.resolve(this.session.count(this.sql))\n\t\t\t.then(\n\t\t\t\tonfulfilled,\n\t\t\t\tonrejected,\n\t\t\t);\n\t}\n\n\tcatch(\n\t\tonRejected?: ((reason: any) => never | PromiseLike<never>) | null | undefined,\n\t): Promise<number> {\n\t\treturn this.then(undefined, onRejected);\n\t}\n\n\tfinally(onFinally?: (() => void) | null | undefined): Promise<number> {\n\t\treturn this.then(\n\t\t\t(value) => {\n\t\t\t\tonFinally?.();\n\t\t\t\treturn value;\n\t\t\t},\n\t\t\t(reason) => {\n\t\t\t\tonFinally?.();\n\t\t\t\tthrow reason;\n\t\t\t},\n\t\t);\n\t}\n}\n"],"mappings":"AAAA,SAAS,kBAAkB;AAC3B,SAAS,KAAK,WAA4B;AAKnC,MAAM,0BAEH,IAA2D;AAAA,EAsBpE,YACU,QAKR;AACD,UAAM,kBAAkB,mBAAmB,OAAO,QAAQ,OAAO,OAAO,EAAE,WAAW;AAN5E;AAQT,SAAK,QAAQ,MAAM;AAEnB,SAAK,UAAU,OAAO;AAEtB,SAAK,MAAM,kBAAkB;AAAA,MAC5B,OAAO;AAAA,MACP,OAAO;AAAA,IACR;AAAA,EACD;AAAA,EAtCQ;AAAA,EAER,QAA0B,UAAU,IAAI;AAAA,EACxC,CAAC,OAAO,WAAW,IAAI;AAAA,EAEf;AAAA,EAER,OAAe,mBACd,QACA,SACc;AACd,WAAO,4BAAoC,MAAM,GAAG,IAAI,IAAI,SAAS,EAAE,GAAG,OAAO,CAAC,GAAG,OAAO;AAAA,EAC7F;AAAA,EAEA,OAAe,WACd,QACA,SACc;AACd,WAAO,oCAA4C,MAAM,GAAG,IAAI,IAAI,SAAS,EAAE,GAAG,OAAO,CAAC,GAAG,OAAO;AAAA,EACrG;AAAA,EAqBA,KACC,aACA,YAC+B;AAC/B,WAAO,QAAQ,QAAQ,KAAK,QAAQ,MAAM,KAAK,GAAG,CAAC,EACjD;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EACF;AAAA,EAEA,MACC,YACkB;AAClB,WAAO,KAAK,KAAK,QAAW,UAAU;AAAA,EACvC;AAAA,EAEA,QAAQ,WAA8D;AACrE,WAAO,KAAK;AAAA,MACX,CAAC,UAAU;AACV,oBAAY;AACZ,eAAO;AAAA,MACR;AAAA,MACA,CAAC,WAAW;AACX,oBAAY;AACZ,cAAM;AAAA,MACP;AAAA,IACD;AAAA,EACD;AACD;","names":[]}
|
|
@@ -26,50 +26,47 @@ var import_entity = require("../../entity.cjs");
|
|
|
26
26
|
var import_query_promise = require("../../query-promise.cjs");
|
|
27
27
|
var import_relations = require("../../relations.cjs");
|
|
28
28
|
class RelationalQueryBuilder {
|
|
29
|
-
constructor(
|
|
30
|
-
this.
|
|
29
|
+
constructor(tables, schema, tableNamesMap, table, tableConfig, dialect, session) {
|
|
30
|
+
this.tables = tables;
|
|
31
31
|
this.schema = schema;
|
|
32
32
|
this.tableNamesMap = tableNamesMap;
|
|
33
33
|
this.table = table;
|
|
34
34
|
this.tableConfig = tableConfig;
|
|
35
35
|
this.dialect = dialect;
|
|
36
36
|
this.session = session;
|
|
37
|
-
this.mode = mode;
|
|
38
37
|
}
|
|
39
|
-
static [import_entity.entityKind] = "
|
|
38
|
+
static [import_entity.entityKind] = "MySqlRelationalQueryBuilderV2";
|
|
40
39
|
findMany(config) {
|
|
41
40
|
return new MySqlRelationalQuery(
|
|
42
|
-
this.
|
|
41
|
+
this.tables,
|
|
43
42
|
this.schema,
|
|
44
43
|
this.tableNamesMap,
|
|
45
44
|
this.table,
|
|
46
45
|
this.tableConfig,
|
|
47
46
|
this.dialect,
|
|
48
47
|
this.session,
|
|
49
|
-
config
|
|
50
|
-
"many"
|
|
51
|
-
this.mode
|
|
48
|
+
config ?? true,
|
|
49
|
+
"many"
|
|
52
50
|
);
|
|
53
51
|
}
|
|
54
52
|
findFirst(config) {
|
|
55
53
|
return new MySqlRelationalQuery(
|
|
56
|
-
this.
|
|
54
|
+
this.tables,
|
|
57
55
|
this.schema,
|
|
58
56
|
this.tableNamesMap,
|
|
59
57
|
this.table,
|
|
60
58
|
this.tableConfig,
|
|
61
59
|
this.dialect,
|
|
62
60
|
this.session,
|
|
63
|
-
config
|
|
64
|
-
"first"
|
|
65
|
-
this.mode
|
|
61
|
+
config ?? true,
|
|
62
|
+
"first"
|
|
66
63
|
);
|
|
67
64
|
}
|
|
68
65
|
}
|
|
69
66
|
class MySqlRelationalQuery extends import_query_promise.QueryPromise {
|
|
70
|
-
constructor(
|
|
67
|
+
constructor(tables, schema, tableNamesMap, table, tableConfig, dialect, session, config, mode) {
|
|
71
68
|
super();
|
|
72
|
-
this.
|
|
69
|
+
this.tables = tables;
|
|
73
70
|
this.schema = schema;
|
|
74
71
|
this.tableNamesMap = tableNamesMap;
|
|
75
72
|
this.table = table;
|
|
@@ -77,18 +74,17 @@ class MySqlRelationalQuery extends import_query_promise.QueryPromise {
|
|
|
77
74
|
this.dialect = dialect;
|
|
78
75
|
this.session = session;
|
|
79
76
|
this.config = config;
|
|
80
|
-
this.queryMode = queryMode;
|
|
81
77
|
this.mode = mode;
|
|
82
78
|
}
|
|
83
|
-
static [import_entity.entityKind] = "
|
|
79
|
+
static [import_entity.entityKind] = "MySqlRelationalQueryV2";
|
|
84
80
|
prepare() {
|
|
85
81
|
const { query, builtQuery } = this._toSQL();
|
|
86
|
-
return this.session.
|
|
82
|
+
return this.session.prepareRelationalQuery(
|
|
87
83
|
builtQuery,
|
|
88
84
|
void 0,
|
|
89
85
|
(rawRows) => {
|
|
90
|
-
const rows = rawRows.map((row) => (0, import_relations.mapRelationalRow)(
|
|
91
|
-
if (this.
|
|
86
|
+
const rows = rawRows.map((row) => (0, import_relations.mapRelationalRow)(row, query.selection));
|
|
87
|
+
if (this.mode === "first") {
|
|
92
88
|
return rows[0];
|
|
93
89
|
}
|
|
94
90
|
return rows;
|
|
@@ -96,24 +92,15 @@ class MySqlRelationalQuery extends import_query_promise.QueryPromise {
|
|
|
96
92
|
);
|
|
97
93
|
}
|
|
98
94
|
_getQuery() {
|
|
99
|
-
|
|
100
|
-
fullSchema: this.fullSchema,
|
|
101
|
-
schema: this.schema,
|
|
102
|
-
tableNamesMap: this.tableNamesMap,
|
|
103
|
-
table: this.table,
|
|
104
|
-
tableConfig: this.tableConfig,
|
|
105
|
-
queryConfig: this.config,
|
|
106
|
-
tableAlias: this.tableConfig.tsName
|
|
107
|
-
}) : this.dialect.buildRelationalQuery({
|
|
108
|
-
fullSchema: this.fullSchema,
|
|
95
|
+
return this.dialect.buildRelationalQuery({
|
|
109
96
|
schema: this.schema,
|
|
110
97
|
tableNamesMap: this.tableNamesMap,
|
|
111
98
|
table: this.table,
|
|
112
99
|
tableConfig: this.tableConfig,
|
|
113
100
|
queryConfig: this.config,
|
|
114
|
-
|
|
101
|
+
tables: this.tables,
|
|
102
|
+
mode: this.mode
|
|
115
103
|
});
|
|
116
|
-
return query;
|
|
117
104
|
}
|
|
118
105
|
_toSQL() {
|
|
119
106
|
const query = this._getQuery();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/mysql-core/query-builders/query.ts"],"sourcesContent":["import { entityKind } from '~/entity.ts';\nimport { QueryPromise } from '~/query-promise.ts';\nimport {\n\ttype BuildQueryResult,\n\ttype BuildRelationalQueryResult,\n\ttype DBQueryConfig,\n\tmapRelationalRow,\n\ttype TableRelationalConfig,\n\ttype TablesRelationalConfig,\n} from '~/relations.ts';\nimport type { Query, QueryWithTypings, SQL } from '~/sql/sql.ts';\nimport type { KnownKeysOnly } from '~/utils.ts';\nimport type { MySqlDialect } from '../dialect.ts';\nimport type {
|
|
1
|
+
{"version":3,"sources":["../../../src/mysql-core/query-builders/query.ts"],"sourcesContent":["import { entityKind } from '~/entity.ts';\nimport { QueryPromise } from '~/query-promise.ts';\nimport {\n\ttype BuildQueryResult,\n\ttype BuildRelationalQueryResult,\n\ttype DBQueryConfig,\n\tmapRelationalRow,\n\ttype TableRelationalConfig,\n\ttype TablesRelationalConfig,\n} from '~/relations.ts';\nimport type { Query, QueryWithTypings, SQL } from '~/sql/sql.ts';\nimport type { KnownKeysOnly } from '~/utils.ts';\nimport type { MySqlDialect } from '../dialect.ts';\nimport type { MySqlPreparedQueryConfig, MySqlSession, PreparedQueryHKTBase, PreparedQueryKind } from '../session.ts';\nimport type { MySqlTable } from '../table.ts';\n\nexport class RelationalQueryBuilder<\n\tTPreparedQueryHKT extends PreparedQueryHKTBase,\n\tTSchema extends TablesRelationalConfig,\n\tTFields extends TableRelationalConfig,\n> {\n\tstatic readonly [entityKind]: string = 'MySqlRelationalQueryBuilderV2';\n\n\tconstructor(\n\t\tprivate tables: Record<string, MySqlTable>,\n\t\tprivate schema: TSchema,\n\t\tprivate tableNamesMap: Record<string, string>,\n\t\tprivate table: MySqlTable,\n\t\tprivate tableConfig: TableRelationalConfig,\n\t\tprivate dialect: MySqlDialect,\n\t\tprivate session: MySqlSession,\n\t) {}\n\n\tfindMany<TConfig extends DBQueryConfig<'many', TSchema, TFields>>(\n\t\tconfig?: KnownKeysOnly<TConfig, DBQueryConfig<'many', TSchema, TFields>>,\n\t): MySqlRelationalQuery<TPreparedQueryHKT, BuildQueryResult<TSchema, TFields, TConfig>[]> {\n\t\treturn new MySqlRelationalQuery(\n\t\t\tthis.tables,\n\t\t\tthis.schema,\n\t\t\tthis.tableNamesMap,\n\t\t\tthis.table,\n\t\t\tthis.tableConfig,\n\t\t\tthis.dialect,\n\t\t\tthis.session,\n\t\t\tconfig as DBQueryConfig<'many'> | undefined ?? true,\n\t\t\t'many',\n\t\t);\n\t}\n\n\tfindFirst<TSelection extends DBQueryConfig<'one', TSchema, TFields>>(\n\t\tconfig?: KnownKeysOnly<TSelection, DBQueryConfig<'one', TSchema, TFields>>,\n\t): MySqlRelationalQuery<TPreparedQueryHKT, BuildQueryResult<TSchema, TFields, TSelection> | undefined> {\n\t\treturn new MySqlRelationalQuery(\n\t\t\tthis.tables,\n\t\t\tthis.schema,\n\t\t\tthis.tableNamesMap,\n\t\t\tthis.table,\n\t\t\tthis.tableConfig,\n\t\t\tthis.dialect,\n\t\t\tthis.session,\n\t\t\tconfig as DBQueryConfig<'one'> | undefined ?? true,\n\t\t\t'first',\n\t\t);\n\t}\n}\n\nexport class MySqlRelationalQuery<\n\tTPreparedQueryHKT extends PreparedQueryHKTBase,\n\tTResult,\n> extends QueryPromise<TResult> {\n\tstatic override readonly [entityKind]: string = 'MySqlRelationalQueryV2';\n\n\tdeclare protected $brand: 'MySqlRelationalQuery';\n\n\tconstructor(\n\t\tprivate tables: Record<string, MySqlTable>,\n\t\tprivate schema: TablesRelationalConfig,\n\t\tprivate tableNamesMap: Record<string, string>,\n\t\tprivate table: MySqlTable,\n\t\tprivate tableConfig: TableRelationalConfig,\n\t\tprivate dialect: MySqlDialect,\n\t\tprivate session: MySqlSession,\n\t\tprivate config: DBQueryConfig<'many' | 'one'> | true,\n\t\tprivate mode: 'many' | 'first',\n\t) {\n\t\tsuper();\n\t}\n\n\tprepare() {\n\t\tconst { query, builtQuery } = this._toSQL();\n\t\treturn this.session.prepareRelationalQuery(\n\t\t\tbuiltQuery,\n\t\t\tundefined,\n\t\t\t(rawRows) => {\n\t\t\t\tconst rows = rawRows.map((row) => mapRelationalRow(row, query.selection));\n\t\t\t\tif (this.mode === 'first') {\n\t\t\t\t\treturn rows[0] as TResult;\n\t\t\t\t}\n\t\t\t\treturn rows as TResult;\n\t\t\t},\n\t\t) as PreparedQueryKind<TPreparedQueryHKT, MySqlPreparedQueryConfig & { execute: TResult }, true>;\n\t}\n\n\tprivate _getQuery() {\n\t\treturn this.dialect.buildRelationalQuery({\n\t\t\tschema: this.schema,\n\t\t\ttableNamesMap: this.tableNamesMap,\n\t\t\ttable: this.table,\n\t\t\ttableConfig: this.tableConfig,\n\t\t\tqueryConfig: this.config,\n\t\t\ttables: this.tables,\n\t\t\tmode: this.mode,\n\t\t});\n\t}\n\n\tprivate _toSQL(): { query: BuildRelationalQueryResult; builtQuery: QueryWithTypings } {\n\t\tconst query = this._getQuery();\n\n\t\tconst builtQuery = this.dialect.sqlToQuery(query.sql);\n\n\t\treturn { builtQuery, query };\n\t}\n\n\t/** @internal */\n\tgetSQL(): SQL {\n\t\treturn this._getQuery().sql;\n\t}\n\n\ttoSQL(): Query {\n\t\treturn this._toSQL().builtQuery;\n\t}\n\n\toverride execute(): Promise<TResult> {\n\t\treturn this.prepare().execute();\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA2B;AAC3B,2BAA6B;AAC7B,uBAOO;AAOA,MAAM,uBAIX;AAAA,EAGD,YACS,QACA,QACA,eACA,OACA,aACA,SACA,SACP;AAPO;AACA;AACA;AACA;AACA;AACA;AACA;AAAA,EACN;AAAA,EAVH,QAAiB,wBAAU,IAAY;AAAA,EAYvC,SACC,QACyF;AACzF,WAAO,IAAI;AAAA,MACV,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,UAA+C;AAAA,MAC/C;AAAA,IACD;AAAA,EACD;AAAA,EAEA,UACC,QACsG;AACtG,WAAO,IAAI;AAAA,MACV,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,UAA8C;AAAA,MAC9C;AAAA,IACD;AAAA,EACD;AACD;AAEO,MAAM,6BAGH,kCAAsB;AAAA,EAK/B,YACS,QACA,QACA,eACA,OACA,aACA,SACA,SACA,QACA,MACP;AACD,UAAM;AAVE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA,EAGT;AAAA,EAhBA,QAA0B,wBAAU,IAAY;AAAA,EAkBhD,UAAU;AACT,UAAM,EAAE,OAAO,WAAW,IAAI,KAAK,OAAO;AAC1C,WAAO,KAAK,QAAQ;AAAA,MACnB;AAAA,MACA;AAAA,MACA,CAAC,YAAY;AACZ,cAAM,OAAO,QAAQ,IAAI,CAAC,YAAQ,mCAAiB,KAAK,MAAM,SAAS,CAAC;AACxE,YAAI,KAAK,SAAS,SAAS;AAC1B,iBAAO,KAAK,CAAC;AAAA,QACd;AACA,eAAO;AAAA,MACR;AAAA,IACD;AAAA,EACD;AAAA,EAEQ,YAAY;AACnB,WAAO,KAAK,QAAQ,qBAAqB;AAAA,MACxC,QAAQ,KAAK;AAAA,MACb,eAAe,KAAK;AAAA,MACpB,OAAO,KAAK;AAAA,MACZ,aAAa,KAAK;AAAA,MAClB,aAAa,KAAK;AAAA,MAClB,QAAQ,KAAK;AAAA,MACb,MAAM,KAAK;AAAA,IACZ,CAAC;AAAA,EACF;AAAA,EAEQ,SAA8E;AACrF,UAAM,QAAQ,KAAK,UAAU;AAE7B,UAAM,aAAa,KAAK,QAAQ,WAAW,MAAM,GAAG;AAEpD,WAAO,EAAE,YAAY,MAAM;AAAA,EAC5B;AAAA;AAAA,EAGA,SAAc;AACb,WAAO,KAAK,UAAU,EAAE;AAAA,EACzB;AAAA,EAEA,QAAe;AACd,WAAO,KAAK,OAAO,EAAE;AAAA,EACtB;AAAA,EAES,UAA4B;AACpC,WAAO,KAAK,QAAQ,EAAE,QAAQ;AAAA,EAC/B;AACD;","names":[]}
|
|
@@ -4,24 +4,23 @@ import { type BuildQueryResult, type DBQueryConfig, type TableRelationalConfig,
|
|
|
4
4
|
import type { Query } from "../../sql/sql.cjs";
|
|
5
5
|
import type { KnownKeysOnly } from "../../utils.cjs";
|
|
6
6
|
import type { MySqlDialect } from "../dialect.cjs";
|
|
7
|
-
import type {
|
|
7
|
+
import type { MySqlPreparedQueryConfig, MySqlSession, PreparedQueryHKTBase, PreparedQueryKind } from "../session.cjs";
|
|
8
8
|
import type { MySqlTable } from "../table.cjs";
|
|
9
9
|
export declare class RelationalQueryBuilder<TPreparedQueryHKT extends PreparedQueryHKTBase, TSchema extends TablesRelationalConfig, TFields extends TableRelationalConfig> {
|
|
10
|
-
private
|
|
10
|
+
private tables;
|
|
11
11
|
private schema;
|
|
12
12
|
private tableNamesMap;
|
|
13
13
|
private table;
|
|
14
14
|
private tableConfig;
|
|
15
15
|
private dialect;
|
|
16
16
|
private session;
|
|
17
|
-
private mode;
|
|
18
17
|
static readonly [entityKind]: string;
|
|
19
|
-
constructor(
|
|
20
|
-
findMany<TConfig extends DBQueryConfig<'many',
|
|
21
|
-
findFirst<TSelection extends
|
|
18
|
+
constructor(tables: Record<string, MySqlTable>, schema: TSchema, tableNamesMap: Record<string, string>, table: MySqlTable, tableConfig: TableRelationalConfig, dialect: MySqlDialect, session: MySqlSession);
|
|
19
|
+
findMany<TConfig extends DBQueryConfig<'many', TSchema, TFields>>(config?: KnownKeysOnly<TConfig, DBQueryConfig<'many', TSchema, TFields>>): MySqlRelationalQuery<TPreparedQueryHKT, BuildQueryResult<TSchema, TFields, TConfig>[]>;
|
|
20
|
+
findFirst<TSelection extends DBQueryConfig<'one', TSchema, TFields>>(config?: KnownKeysOnly<TSelection, DBQueryConfig<'one', TSchema, TFields>>): MySqlRelationalQuery<TPreparedQueryHKT, BuildQueryResult<TSchema, TFields, TSelection> | undefined>;
|
|
22
21
|
}
|
|
23
22
|
export declare class MySqlRelationalQuery<TPreparedQueryHKT extends PreparedQueryHKTBase, TResult> extends QueryPromise<TResult> {
|
|
24
|
-
private
|
|
23
|
+
private tables;
|
|
25
24
|
private schema;
|
|
26
25
|
private tableNamesMap;
|
|
27
26
|
private table;
|
|
@@ -29,11 +28,10 @@ export declare class MySqlRelationalQuery<TPreparedQueryHKT extends PreparedQuer
|
|
|
29
28
|
private dialect;
|
|
30
29
|
private session;
|
|
31
30
|
private config;
|
|
32
|
-
private
|
|
33
|
-
private mode?;
|
|
31
|
+
private mode;
|
|
34
32
|
static readonly [entityKind]: string;
|
|
35
33
|
protected $brand: 'MySqlRelationalQuery';
|
|
36
|
-
constructor(
|
|
34
|
+
constructor(tables: Record<string, MySqlTable>, schema: TablesRelationalConfig, tableNamesMap: Record<string, string>, table: MySqlTable, tableConfig: TableRelationalConfig, dialect: MySqlDialect, session: MySqlSession, config: DBQueryConfig<'many' | 'one'> | true, mode: 'many' | 'first');
|
|
37
35
|
prepare(): PreparedQueryKind<TPreparedQueryHKT, MySqlPreparedQueryConfig & {
|
|
38
36
|
execute: TResult;
|
|
39
37
|
}, true>;
|
|
@@ -4,24 +4,23 @@ import { type BuildQueryResult, type DBQueryConfig, type TableRelationalConfig,
|
|
|
4
4
|
import type { Query } from "../../sql/sql.js";
|
|
5
5
|
import type { KnownKeysOnly } from "../../utils.js";
|
|
6
6
|
import type { MySqlDialect } from "../dialect.js";
|
|
7
|
-
import type {
|
|
7
|
+
import type { MySqlPreparedQueryConfig, MySqlSession, PreparedQueryHKTBase, PreparedQueryKind } from "../session.js";
|
|
8
8
|
import type { MySqlTable } from "../table.js";
|
|
9
9
|
export declare class RelationalQueryBuilder<TPreparedQueryHKT extends PreparedQueryHKTBase, TSchema extends TablesRelationalConfig, TFields extends TableRelationalConfig> {
|
|
10
|
-
private
|
|
10
|
+
private tables;
|
|
11
11
|
private schema;
|
|
12
12
|
private tableNamesMap;
|
|
13
13
|
private table;
|
|
14
14
|
private tableConfig;
|
|
15
15
|
private dialect;
|
|
16
16
|
private session;
|
|
17
|
-
private mode;
|
|
18
17
|
static readonly [entityKind]: string;
|
|
19
|
-
constructor(
|
|
20
|
-
findMany<TConfig extends DBQueryConfig<'many',
|
|
21
|
-
findFirst<TSelection extends
|
|
18
|
+
constructor(tables: Record<string, MySqlTable>, schema: TSchema, tableNamesMap: Record<string, string>, table: MySqlTable, tableConfig: TableRelationalConfig, dialect: MySqlDialect, session: MySqlSession);
|
|
19
|
+
findMany<TConfig extends DBQueryConfig<'many', TSchema, TFields>>(config?: KnownKeysOnly<TConfig, DBQueryConfig<'many', TSchema, TFields>>): MySqlRelationalQuery<TPreparedQueryHKT, BuildQueryResult<TSchema, TFields, TConfig>[]>;
|
|
20
|
+
findFirst<TSelection extends DBQueryConfig<'one', TSchema, TFields>>(config?: KnownKeysOnly<TSelection, DBQueryConfig<'one', TSchema, TFields>>): MySqlRelationalQuery<TPreparedQueryHKT, BuildQueryResult<TSchema, TFields, TSelection> | undefined>;
|
|
22
21
|
}
|
|
23
22
|
export declare class MySqlRelationalQuery<TPreparedQueryHKT extends PreparedQueryHKTBase, TResult> extends QueryPromise<TResult> {
|
|
24
|
-
private
|
|
23
|
+
private tables;
|
|
25
24
|
private schema;
|
|
26
25
|
private tableNamesMap;
|
|
27
26
|
private table;
|
|
@@ -29,11 +28,10 @@ export declare class MySqlRelationalQuery<TPreparedQueryHKT extends PreparedQuer
|
|
|
29
28
|
private dialect;
|
|
30
29
|
private session;
|
|
31
30
|
private config;
|
|
32
|
-
private
|
|
33
|
-
private mode?;
|
|
31
|
+
private mode;
|
|
34
32
|
static readonly [entityKind]: string;
|
|
35
33
|
protected $brand: 'MySqlRelationalQuery';
|
|
36
|
-
constructor(
|
|
34
|
+
constructor(tables: Record<string, MySqlTable>, schema: TablesRelationalConfig, tableNamesMap: Record<string, string>, table: MySqlTable, tableConfig: TableRelationalConfig, dialect: MySqlDialect, session: MySqlSession, config: DBQueryConfig<'many' | 'one'> | true, mode: 'many' | 'first');
|
|
37
35
|
prepare(): PreparedQueryKind<TPreparedQueryHKT, MySqlPreparedQueryConfig & {
|
|
38
36
|
execute: TResult;
|
|
39
37
|
}, true>;
|
|
@@ -4,50 +4,47 @@ import {
|
|
|
4
4
|
mapRelationalRow
|
|
5
5
|
} from "../../relations.js";
|
|
6
6
|
class RelationalQueryBuilder {
|
|
7
|
-
constructor(
|
|
8
|
-
this.
|
|
7
|
+
constructor(tables, schema, tableNamesMap, table, tableConfig, dialect, session) {
|
|
8
|
+
this.tables = tables;
|
|
9
9
|
this.schema = schema;
|
|
10
10
|
this.tableNamesMap = tableNamesMap;
|
|
11
11
|
this.table = table;
|
|
12
12
|
this.tableConfig = tableConfig;
|
|
13
13
|
this.dialect = dialect;
|
|
14
14
|
this.session = session;
|
|
15
|
-
this.mode = mode;
|
|
16
15
|
}
|
|
17
|
-
static [entityKind] = "
|
|
16
|
+
static [entityKind] = "MySqlRelationalQueryBuilderV2";
|
|
18
17
|
findMany(config) {
|
|
19
18
|
return new MySqlRelationalQuery(
|
|
20
|
-
this.
|
|
19
|
+
this.tables,
|
|
21
20
|
this.schema,
|
|
22
21
|
this.tableNamesMap,
|
|
23
22
|
this.table,
|
|
24
23
|
this.tableConfig,
|
|
25
24
|
this.dialect,
|
|
26
25
|
this.session,
|
|
27
|
-
config
|
|
28
|
-
"many"
|
|
29
|
-
this.mode
|
|
26
|
+
config ?? true,
|
|
27
|
+
"many"
|
|
30
28
|
);
|
|
31
29
|
}
|
|
32
30
|
findFirst(config) {
|
|
33
31
|
return new MySqlRelationalQuery(
|
|
34
|
-
this.
|
|
32
|
+
this.tables,
|
|
35
33
|
this.schema,
|
|
36
34
|
this.tableNamesMap,
|
|
37
35
|
this.table,
|
|
38
36
|
this.tableConfig,
|
|
39
37
|
this.dialect,
|
|
40
38
|
this.session,
|
|
41
|
-
config
|
|
42
|
-
"first"
|
|
43
|
-
this.mode
|
|
39
|
+
config ?? true,
|
|
40
|
+
"first"
|
|
44
41
|
);
|
|
45
42
|
}
|
|
46
43
|
}
|
|
47
44
|
class MySqlRelationalQuery extends QueryPromise {
|
|
48
|
-
constructor(
|
|
45
|
+
constructor(tables, schema, tableNamesMap, table, tableConfig, dialect, session, config, mode) {
|
|
49
46
|
super();
|
|
50
|
-
this.
|
|
47
|
+
this.tables = tables;
|
|
51
48
|
this.schema = schema;
|
|
52
49
|
this.tableNamesMap = tableNamesMap;
|
|
53
50
|
this.table = table;
|
|
@@ -55,18 +52,17 @@ class MySqlRelationalQuery extends QueryPromise {
|
|
|
55
52
|
this.dialect = dialect;
|
|
56
53
|
this.session = session;
|
|
57
54
|
this.config = config;
|
|
58
|
-
this.queryMode = queryMode;
|
|
59
55
|
this.mode = mode;
|
|
60
56
|
}
|
|
61
|
-
static [entityKind] = "
|
|
57
|
+
static [entityKind] = "MySqlRelationalQueryV2";
|
|
62
58
|
prepare() {
|
|
63
59
|
const { query, builtQuery } = this._toSQL();
|
|
64
|
-
return this.session.
|
|
60
|
+
return this.session.prepareRelationalQuery(
|
|
65
61
|
builtQuery,
|
|
66
62
|
void 0,
|
|
67
63
|
(rawRows) => {
|
|
68
|
-
const rows = rawRows.map((row) => mapRelationalRow(
|
|
69
|
-
if (this.
|
|
64
|
+
const rows = rawRows.map((row) => mapRelationalRow(row, query.selection));
|
|
65
|
+
if (this.mode === "first") {
|
|
70
66
|
return rows[0];
|
|
71
67
|
}
|
|
72
68
|
return rows;
|
|
@@ -74,24 +70,15 @@ class MySqlRelationalQuery extends QueryPromise {
|
|
|
74
70
|
);
|
|
75
71
|
}
|
|
76
72
|
_getQuery() {
|
|
77
|
-
|
|
78
|
-
fullSchema: this.fullSchema,
|
|
79
|
-
schema: this.schema,
|
|
80
|
-
tableNamesMap: this.tableNamesMap,
|
|
81
|
-
table: this.table,
|
|
82
|
-
tableConfig: this.tableConfig,
|
|
83
|
-
queryConfig: this.config,
|
|
84
|
-
tableAlias: this.tableConfig.tsName
|
|
85
|
-
}) : this.dialect.buildRelationalQuery({
|
|
86
|
-
fullSchema: this.fullSchema,
|
|
73
|
+
return this.dialect.buildRelationalQuery({
|
|
87
74
|
schema: this.schema,
|
|
88
75
|
tableNamesMap: this.tableNamesMap,
|
|
89
76
|
table: this.table,
|
|
90
77
|
tableConfig: this.tableConfig,
|
|
91
78
|
queryConfig: this.config,
|
|
92
|
-
|
|
79
|
+
tables: this.tables,
|
|
80
|
+
mode: this.mode
|
|
93
81
|
});
|
|
94
|
-
return query;
|
|
95
82
|
}
|
|
96
83
|
_toSQL() {
|
|
97
84
|
const query = this._getQuery();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/mysql-core/query-builders/query.ts"],"sourcesContent":["import { entityKind } from '~/entity.ts';\nimport { QueryPromise } from '~/query-promise.ts';\nimport {\n\ttype BuildQueryResult,\n\ttype BuildRelationalQueryResult,\n\ttype DBQueryConfig,\n\tmapRelationalRow,\n\ttype TableRelationalConfig,\n\ttype TablesRelationalConfig,\n} from '~/relations.ts';\nimport type { Query, QueryWithTypings, SQL } from '~/sql/sql.ts';\nimport type { KnownKeysOnly } from '~/utils.ts';\nimport type { MySqlDialect } from '../dialect.ts';\nimport type {
|
|
1
|
+
{"version":3,"sources":["../../../src/mysql-core/query-builders/query.ts"],"sourcesContent":["import { entityKind } from '~/entity.ts';\nimport { QueryPromise } from '~/query-promise.ts';\nimport {\n\ttype BuildQueryResult,\n\ttype BuildRelationalQueryResult,\n\ttype DBQueryConfig,\n\tmapRelationalRow,\n\ttype TableRelationalConfig,\n\ttype TablesRelationalConfig,\n} from '~/relations.ts';\nimport type { Query, QueryWithTypings, SQL } from '~/sql/sql.ts';\nimport type { KnownKeysOnly } from '~/utils.ts';\nimport type { MySqlDialect } from '../dialect.ts';\nimport type { MySqlPreparedQueryConfig, MySqlSession, PreparedQueryHKTBase, PreparedQueryKind } from '../session.ts';\nimport type { MySqlTable } from '../table.ts';\n\nexport class RelationalQueryBuilder<\n\tTPreparedQueryHKT extends PreparedQueryHKTBase,\n\tTSchema extends TablesRelationalConfig,\n\tTFields extends TableRelationalConfig,\n> {\n\tstatic readonly [entityKind]: string = 'MySqlRelationalQueryBuilderV2';\n\n\tconstructor(\n\t\tprivate tables: Record<string, MySqlTable>,\n\t\tprivate schema: TSchema,\n\t\tprivate tableNamesMap: Record<string, string>,\n\t\tprivate table: MySqlTable,\n\t\tprivate tableConfig: TableRelationalConfig,\n\t\tprivate dialect: MySqlDialect,\n\t\tprivate session: MySqlSession,\n\t) {}\n\n\tfindMany<TConfig extends DBQueryConfig<'many', TSchema, TFields>>(\n\t\tconfig?: KnownKeysOnly<TConfig, DBQueryConfig<'many', TSchema, TFields>>,\n\t): MySqlRelationalQuery<TPreparedQueryHKT, BuildQueryResult<TSchema, TFields, TConfig>[]> {\n\t\treturn new MySqlRelationalQuery(\n\t\t\tthis.tables,\n\t\t\tthis.schema,\n\t\t\tthis.tableNamesMap,\n\t\t\tthis.table,\n\t\t\tthis.tableConfig,\n\t\t\tthis.dialect,\n\t\t\tthis.session,\n\t\t\tconfig as DBQueryConfig<'many'> | undefined ?? true,\n\t\t\t'many',\n\t\t);\n\t}\n\n\tfindFirst<TSelection extends DBQueryConfig<'one', TSchema, TFields>>(\n\t\tconfig?: KnownKeysOnly<TSelection, DBQueryConfig<'one', TSchema, TFields>>,\n\t): MySqlRelationalQuery<TPreparedQueryHKT, BuildQueryResult<TSchema, TFields, TSelection> | undefined> {\n\t\treturn new MySqlRelationalQuery(\n\t\t\tthis.tables,\n\t\t\tthis.schema,\n\t\t\tthis.tableNamesMap,\n\t\t\tthis.table,\n\t\t\tthis.tableConfig,\n\t\t\tthis.dialect,\n\t\t\tthis.session,\n\t\t\tconfig as DBQueryConfig<'one'> | undefined ?? true,\n\t\t\t'first',\n\t\t);\n\t}\n}\n\nexport class MySqlRelationalQuery<\n\tTPreparedQueryHKT extends PreparedQueryHKTBase,\n\tTResult,\n> extends QueryPromise<TResult> {\n\tstatic override readonly [entityKind]: string = 'MySqlRelationalQueryV2';\n\n\tdeclare protected $brand: 'MySqlRelationalQuery';\n\n\tconstructor(\n\t\tprivate tables: Record<string, MySqlTable>,\n\t\tprivate schema: TablesRelationalConfig,\n\t\tprivate tableNamesMap: Record<string, string>,\n\t\tprivate table: MySqlTable,\n\t\tprivate tableConfig: TableRelationalConfig,\n\t\tprivate dialect: MySqlDialect,\n\t\tprivate session: MySqlSession,\n\t\tprivate config: DBQueryConfig<'many' | 'one'> | true,\n\t\tprivate mode: 'many' | 'first',\n\t) {\n\t\tsuper();\n\t}\n\n\tprepare() {\n\t\tconst { query, builtQuery } = this._toSQL();\n\t\treturn this.session.prepareRelationalQuery(\n\t\t\tbuiltQuery,\n\t\t\tundefined,\n\t\t\t(rawRows) => {\n\t\t\t\tconst rows = rawRows.map((row) => mapRelationalRow(row, query.selection));\n\t\t\t\tif (this.mode === 'first') {\n\t\t\t\t\treturn rows[0] as TResult;\n\t\t\t\t}\n\t\t\t\treturn rows as TResult;\n\t\t\t},\n\t\t) as PreparedQueryKind<TPreparedQueryHKT, MySqlPreparedQueryConfig & { execute: TResult }, true>;\n\t}\n\n\tprivate _getQuery() {\n\t\treturn this.dialect.buildRelationalQuery({\n\t\t\tschema: this.schema,\n\t\t\ttableNamesMap: this.tableNamesMap,\n\t\t\ttable: this.table,\n\t\t\ttableConfig: this.tableConfig,\n\t\t\tqueryConfig: this.config,\n\t\t\ttables: this.tables,\n\t\t\tmode: this.mode,\n\t\t});\n\t}\n\n\tprivate _toSQL(): { query: BuildRelationalQueryResult; builtQuery: QueryWithTypings } {\n\t\tconst query = this._getQuery();\n\n\t\tconst builtQuery = this.dialect.sqlToQuery(query.sql);\n\n\t\treturn { builtQuery, query };\n\t}\n\n\t/** @internal */\n\tgetSQL(): SQL {\n\t\treturn this._getQuery().sql;\n\t}\n\n\ttoSQL(): Query {\n\t\treturn this._toSQL().builtQuery;\n\t}\n\n\toverride execute(): Promise<TResult> {\n\t\treturn this.prepare().execute();\n\t}\n}\n"],"mappings":"AAAA,SAAS,kBAAkB;AAC3B,SAAS,oBAAoB;AAC7B;AAAA,EAIC;AAAA,OAGM;AAOA,MAAM,uBAIX;AAAA,EAGD,YACS,QACA,QACA,eACA,OACA,aACA,SACA,SACP;AAPO;AACA;AACA;AACA;AACA;AACA;AACA;AAAA,EACN;AAAA,EAVH,QAAiB,UAAU,IAAY;AAAA,EAYvC,SACC,QACyF;AACzF,WAAO,IAAI;AAAA,MACV,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,UAA+C;AAAA,MAC/C;AAAA,IACD;AAAA,EACD;AAAA,EAEA,UACC,QACsG;AACtG,WAAO,IAAI;AAAA,MACV,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,UAA8C;AAAA,MAC9C;AAAA,IACD;AAAA,EACD;AACD;AAEO,MAAM,6BAGH,aAAsB;AAAA,EAK/B,YACS,QACA,QACA,eACA,OACA,aACA,SACA,SACA,QACA,MACP;AACD,UAAM;AAVE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA,EAGT;AAAA,EAhBA,QAA0B,UAAU,IAAY;AAAA,EAkBhD,UAAU;AACT,UAAM,EAAE,OAAO,WAAW,IAAI,KAAK,OAAO;AAC1C,WAAO,KAAK,QAAQ;AAAA,MACnB;AAAA,MACA;AAAA,MACA,CAAC,YAAY;AACZ,cAAM,OAAO,QAAQ,IAAI,CAAC,QAAQ,iBAAiB,KAAK,MAAM,SAAS,CAAC;AACxE,YAAI,KAAK,SAAS,SAAS;AAC1B,iBAAO,KAAK,CAAC;AAAA,QACd;AACA,eAAO;AAAA,MACR;AAAA,IACD;AAAA,EACD;AAAA,EAEQ,YAAY;AACnB,WAAO,KAAK,QAAQ,qBAAqB;AAAA,MACxC,QAAQ,KAAK;AAAA,MACb,eAAe,KAAK;AAAA,MACpB,OAAO,KAAK;AAAA,MACZ,aAAa,KAAK;AAAA,MAClB,aAAa,KAAK;AAAA,MAClB,QAAQ,KAAK;AAAA,MACb,MAAM,KAAK;AAAA,IACZ,CAAC;AAAA,EACF;AAAA,EAEQ,SAA8E;AACrF,UAAM,QAAQ,KAAK,UAAU;AAE7B,UAAM,aAAa,KAAK,QAAQ,WAAW,MAAM,GAAG;AAEpD,WAAO,EAAE,YAAY,MAAM;AAAA,EAC5B;AAAA;AAAA,EAGA,SAAc;AACb,WAAO,KAAK,UAAU,EAAE;AAAA,EACzB;AAAA,EAEA,QAAe;AACd,WAAO,KAAK,OAAO,EAAE;AAAA,EACtB;AAAA,EAES,UAA4B;AACpC,WAAO,KAAK,QAAQ,EAAE,QAAQ;AAAA,EAC/B;AACD;","names":[]}
|
package/mysql-core/session.cjs
CHANGED
|
@@ -68,8 +68,9 @@ class MySqlSession {
|
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
class MySqlTransaction extends import_db.MySqlDatabase {
|
|
71
|
-
constructor(dialect, session, schema, nestedIndex, mode) {
|
|
72
|
-
super(dialect, session, schema, mode);
|
|
71
|
+
constructor(dialect, session, relations, schema, nestedIndex, mode) {
|
|
72
|
+
super(dialect, session, relations, schema, mode);
|
|
73
|
+
this.relations = relations;
|
|
73
74
|
this.schema = schema;
|
|
74
75
|
this.nestedIndex = nestedIndex;
|
|
75
76
|
}
|