drizzle-orm 0.39.0-b06bbcd → 0.39.0-f36e3ea
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/alias.cjs.map +1 -1
- package/alias.d.cts +3 -3
- package/alias.d.ts +3 -3
- package/alias.js.map +1 -1
- package/aws-data-api/pg/driver.cjs +5 -19
- package/aws-data-api/pg/driver.cjs.map +1 -1
- package/aws-data-api/pg/driver.d.cts +8 -9
- package/aws-data-api/pg/driver.d.ts +8 -9
- package/aws-data-api/pg/driver.js +8 -9
- package/aws-data-api/pg/driver.js.map +1 -1
- package/aws-data-api/pg/migrator.cjs.map +1 -1
- package/aws-data-api/pg/migrator.d.cts +1 -2
- package/aws-data-api/pg/migrator.d.ts +1 -2
- package/aws-data-api/pg/migrator.js.map +1 -1
- package/aws-data-api/pg/session.cjs +4 -67
- package/aws-data-api/pg/session.cjs.map +1 -1
- package/aws-data-api/pg/session.d.cts +8 -13
- package/aws-data-api/pg/session.d.ts +8 -13
- package/aws-data-api/pg/session.js +4 -67
- package/aws-data-api/pg/session.js.map +1 -1
- package/better-sqlite3/driver.cjs +5 -12
- package/better-sqlite3/driver.cjs.map +1 -1
- package/better-sqlite3/driver.d.cts +6 -7
- package/better-sqlite3/driver.d.ts +6 -7
- package/better-sqlite3/driver.js +8 -12
- package/better-sqlite3/driver.js.map +1 -1
- package/better-sqlite3/migrator.cjs.map +1 -1
- package/better-sqlite3/migrator.d.cts +1 -2
- package/better-sqlite3/migrator.d.ts +1 -2
- package/better-sqlite3/migrator.js.map +1 -1
- package/better-sqlite3/session.cjs +4 -49
- package/better-sqlite3/session.cjs.map +1 -1
- package/better-sqlite3/session.d.cts +8 -14
- package/better-sqlite3/session.d.ts +8 -14
- package/better-sqlite3/session.js +4 -49
- package/better-sqlite3/session.js.map +1 -1
- package/bun-sql/driver.cjs +96 -0
- package/bun-sql/driver.cjs.map +1 -0
- package/bun-sql/driver.d.cts +30 -0
- package/bun-sql/driver.d.ts +30 -0
- package/bun-sql/driver.js +74 -0
- package/bun-sql/driver.js.map +1 -0
- package/bun-sql/index.cjs +25 -0
- package/bun-sql/index.cjs.map +1 -0
- package/bun-sql/index.d.cts +2 -0
- package/bun-sql/index.d.ts +2 -0
- package/bun-sql/index.js +3 -0
- package/bun-sql/index.js.map +1 -0
- package/bun-sql/migrator.cjs +33 -0
- package/bun-sql/migrator.cjs.map +1 -0
- package/bun-sql/migrator.d.cts +3 -0
- package/bun-sql/migrator.d.ts +3 -0
- package/bun-sql/migrator.js +9 -0
- package/bun-sql/migrator.js.map +1 -0
- package/bun-sql/session.cjs +162 -0
- package/bun-sql/session.cjs.map +1 -0
- package/bun-sql/session.d.cts +50 -0
- package/bun-sql/session.d.ts +50 -0
- package/bun-sql/session.js +136 -0
- package/bun-sql/session.js.map +1 -0
- package/bun-sqlite/driver.cjs +5 -22
- package/bun-sqlite/driver.cjs.map +1 -1
- package/bun-sqlite/driver.d.cts +6 -7
- package/bun-sqlite/driver.d.ts +6 -7
- package/bun-sqlite/driver.js +8 -12
- package/bun-sqlite/driver.js.map +1 -1
- package/bun-sqlite/migrator.cjs.map +1 -1
- package/bun-sqlite/migrator.d.cts +1 -2
- package/bun-sqlite/migrator.d.ts +1 -2
- package/bun-sqlite/migrator.js.map +1 -1
- package/bun-sqlite/session.cjs +4 -49
- package/bun-sqlite/session.cjs.map +1 -1
- package/bun-sqlite/session.d.cts +9 -15
- package/bun-sqlite/session.d.ts +9 -15
- package/bun-sqlite/session.js +4 -49
- package/bun-sqlite/session.js.map +1 -1
- package/d1/driver.cjs +5 -22
- package/d1/driver.cjs.map +1 -1
- package/d1/driver.d.cts +2 -3
- package/d1/driver.d.ts +2 -3
- package/d1/driver.js +8 -12
- package/d1/driver.js.map +1 -1
- package/d1/migrator.cjs.map +1 -1
- package/d1/migrator.d.cts +1 -2
- package/d1/migrator.d.ts +1 -2
- package/d1/migrator.js.map +1 -1
- package/d1/session.cjs +6 -48
- package/d1/session.cjs.map +1 -1
- package/d1/session.d.cts +8 -15
- package/d1/session.d.ts +8 -15
- package/d1/session.js +6 -48
- package/d1/session.js.map +1 -1
- package/durable-sqlite/driver.cjs +5 -16
- package/durable-sqlite/driver.cjs.map +1 -1
- package/durable-sqlite/driver.d.cts +2 -3
- package/durable-sqlite/driver.d.ts +2 -3
- package/durable-sqlite/driver.js +8 -6
- package/durable-sqlite/driver.js.map +1 -1
- package/durable-sqlite/migrator.cjs.map +1 -1
- package/durable-sqlite/migrator.d.cts +1 -2
- package/durable-sqlite/migrator.d.ts +1 -2
- package/durable-sqlite/migrator.js.map +1 -1
- package/durable-sqlite/session.cjs +4 -46
- package/durable-sqlite/session.cjs.map +1 -1
- package/durable-sqlite/session.d.cts +8 -14
- package/durable-sqlite/session.d.ts +8 -14
- package/durable-sqlite/session.js +4 -46
- package/durable-sqlite/session.js.map +1 -1
- package/expo-sqlite/driver.cjs +5 -22
- package/expo-sqlite/driver.cjs.map +1 -1
- package/expo-sqlite/driver.d.cts +2 -3
- package/expo-sqlite/driver.d.ts +2 -3
- package/expo-sqlite/driver.js +8 -12
- package/expo-sqlite/driver.js.map +1 -1
- package/expo-sqlite/migrator.cjs.map +1 -1
- package/expo-sqlite/migrator.d.cts +2 -3
- package/expo-sqlite/migrator.d.ts +2 -3
- package/expo-sqlite/migrator.js.map +1 -1
- package/expo-sqlite/query.cjs +2 -13
- package/expo-sqlite/query.cjs.map +1 -1
- package/expo-sqlite/query.d.cts +1 -2
- package/expo-sqlite/query.d.ts +1 -2
- package/expo-sqlite/query.js +2 -3
- package/expo-sqlite/query.js.map +1 -1
- package/expo-sqlite/session.cjs +4 -47
- package/expo-sqlite/session.cjs.map +1 -1
- package/expo-sqlite/session.d.cts +8 -14
- package/expo-sqlite/session.d.ts +8 -14
- package/expo-sqlite/session.js +4 -47
- package/expo-sqlite/session.js.map +1 -1
- package/libsql/driver-core.cjs +5 -22
- package/libsql/driver-core.cjs.map +1 -1
- package/libsql/driver-core.d.cts +1 -2
- package/libsql/driver-core.d.ts +1 -2
- package/libsql/driver-core.js +8 -12
- package/libsql/driver-core.js.map +1 -1
- package/libsql/driver.cjs.map +1 -1
- package/libsql/driver.d.cts +5 -6
- package/libsql/driver.d.ts +5 -6
- package/libsql/driver.js.map +1 -1
- package/libsql/http/index.cjs.map +1 -1
- package/libsql/http/index.d.cts +5 -6
- package/libsql/http/index.d.ts +5 -6
- package/libsql/http/index.js.map +1 -1
- package/libsql/migrator.cjs.map +1 -1
- package/libsql/migrator.d.cts +1 -2
- package/libsql/migrator.d.ts +1 -2
- package/libsql/migrator.js.map +1 -1
- package/libsql/node/index.cjs.map +1 -1
- package/libsql/node/index.d.cts +5 -6
- package/libsql/node/index.d.ts +5 -6
- package/libsql/node/index.js.map +1 -1
- package/libsql/session.cjs +4 -56
- package/libsql/session.cjs.map +1 -1
- package/libsql/session.d.cts +9 -15
- package/libsql/session.d.ts +9 -15
- package/libsql/session.js +4 -56
- package/libsql/session.js.map +1 -1
- package/libsql/sqlite3/index.cjs.map +1 -1
- package/libsql/sqlite3/index.d.cts +5 -6
- package/libsql/sqlite3/index.d.ts +5 -6
- package/libsql/sqlite3/index.js.map +1 -1
- package/libsql/wasm/index.cjs.map +1 -1
- package/libsql/wasm/index.d.cts +5 -6
- package/libsql/wasm/index.d.ts +5 -6
- package/libsql/wasm/index.js.map +1 -1
- package/libsql/web/index.cjs.map +1 -1
- package/libsql/web/index.d.cts +5 -6
- package/libsql/web/index.d.ts +5 -6
- package/libsql/web/index.js.map +1 -1
- package/libsql/ws/index.cjs.map +1 -1
- package/libsql/ws/index.d.cts +5 -6
- package/libsql/ws/index.d.ts +5 -6
- package/libsql/ws/index.js.map +1 -1
- package/mysql-core/db.cjs +25 -40
- package/mysql-core/db.cjs.map +1 -1
- package/mysql-core/db.d.cts +12 -22
- package/mysql-core/db.d.ts +12 -22
- package/mysql-core/db.js +24 -39
- package/mysql-core/db.js.map +1 -1
- package/mysql-core/dialect.cjs +15 -194
- package/mysql-core/dialect.cjs.map +1 -1
- package/mysql-core/dialect.d.cts +13 -33
- package/mysql-core/dialect.d.ts +13 -33
- package/mysql-core/dialect.js +21 -191
- package/mysql-core/dialect.js.map +1 -1
- package/mysql-core/query-builders/count.cjs.map +1 -1
- package/mysql-core/query-builders/count.d.cts +1 -1
- package/mysql-core/query-builders/count.d.ts +1 -1
- package/mysql-core/query-builders/count.js.map +1 -1
- package/mysql-core/query-builders/query-builder.cjs +15 -11
- package/mysql-core/query-builders/query-builder.cjs.map +1 -1
- package/mysql-core/query-builders/query-builder.d.cts +2 -6
- package/mysql-core/query-builders/query-builder.d.ts +2 -6
- package/mysql-core/query-builders/query-builder.js +15 -11
- package/mysql-core/query-builders/query-builder.js.map +1 -1
- package/mysql-core/query-builders/query.cjs +31 -18
- package/mysql-core/query-builders/query.cjs.map +1 -1
- package/mysql-core/query-builders/query.d.cts +10 -8
- package/mysql-core/query-builders/query.d.ts +10 -8
- package/mysql-core/query-builders/query.js +31 -18
- package/mysql-core/query-builders/query.js.map +1 -1
- package/mysql-core/session.cjs +2 -3
- package/mysql-core/session.cjs.map +1 -1
- package/mysql-core/session.d.cts +7 -10
- package/mysql-core/session.d.ts +7 -10
- package/mysql-core/session.js +2 -3
- package/mysql-core/session.js.map +1 -1
- package/mysql-core/subquery.cjs.map +1 -1
- package/mysql-core/subquery.d.cts +15 -2
- package/mysql-core/subquery.d.ts +15 -2
- package/mysql-proxy/driver.cjs +5 -22
- package/mysql-proxy/driver.cjs.map +1 -1
- package/mysql-proxy/driver.d.cts +2 -3
- package/mysql-proxy/driver.d.ts +2 -3
- package/mysql-proxy/driver.js +8 -12
- package/mysql-proxy/driver.js.map +1 -1
- package/mysql-proxy/migrator.cjs.map +1 -1
- package/mysql-proxy/migrator.d.cts +1 -2
- package/mysql-proxy/migrator.d.ts +1 -2
- package/mysql-proxy/migrator.js.map +1 -1
- package/mysql-proxy/session.cjs +2 -27
- package/mysql-proxy/session.cjs.map +1 -1
- package/mysql-proxy/session.d.cts +8 -13
- package/mysql-proxy/session.d.ts +8 -13
- package/mysql-proxy/session.js +2 -27
- package/mysql-proxy/session.js.map +1 -1
- package/mysql2/driver.cjs +7 -24
- package/mysql2/driver.cjs.map +1 -1
- package/mysql2/driver.d.cts +9 -10
- package/mysql2/driver.d.ts +9 -10
- package/mysql2/driver.js +10 -14
- package/mysql2/driver.js.map +1 -1
- package/mysql2/migrator.cjs.map +1 -1
- package/mysql2/migrator.d.cts +1 -2
- package/mysql2/migrator.d.ts +1 -2
- package/mysql2/migrator.js.map +1 -1
- package/mysql2/session.cjs +2 -30
- package/mysql2/session.cjs.map +1 -1
- package/mysql2/session.d.cts +8 -13
- package/mysql2/session.d.ts +8 -13
- package/mysql2/session.js +2 -30
- package/mysql2/session.js.map +1 -1
- package/neon/index.cjs +2 -0
- package/neon/index.cjs.map +1 -1
- package/neon/index.d.cts +1 -0
- package/neon/index.d.ts +1 -0
- package/neon/index.js +1 -0
- package/neon/index.js.map +1 -1
- package/neon/neon-identity.cjs +38 -0
- package/neon/neon-identity.cjs.map +1 -0
- package/neon/neon-identity.d.cts +116 -0
- package/neon/neon-identity.d.ts +116 -0
- package/neon/neon-identity.js +14 -0
- package/neon/neon-identity.js.map +1 -0
- package/neon-http/driver.cjs +7 -21
- package/neon-http/driver.cjs.map +1 -1
- package/neon-http/driver.d.cts +9 -10
- package/neon-http/driver.d.ts +9 -10
- package/neon-http/driver.js +7 -11
- package/neon-http/driver.js.map +1 -1
- package/neon-http/migrator.cjs.map +1 -1
- package/neon-http/migrator.d.cts +1 -2
- package/neon-http/migrator.d.ts +1 -2
- package/neon-http/migrator.js.map +1 -1
- package/neon-http/session.cjs +2 -32
- package/neon-http/session.cjs.map +1 -1
- package/neon-http/session.d.cts +8 -13
- package/neon-http/session.d.ts +8 -13
- package/neon-http/session.js +2 -32
- package/neon-http/session.js.map +1 -1
- package/neon-serverless/driver.cjs +7 -18
- package/neon-serverless/driver.cjs.map +1 -1
- package/neon-serverless/driver.d.cts +8 -9
- package/neon-serverless/driver.d.ts +8 -9
- package/neon-serverless/driver.js +10 -8
- package/neon-serverless/driver.js.map +1 -1
- package/neon-serverless/migrator.cjs.map +1 -1
- package/neon-serverless/migrator.d.cts +1 -2
- package/neon-serverless/migrator.d.ts +1 -2
- package/neon-serverless/migrator.js.map +1 -1
- package/neon-serverless/session.cjs +5 -40
- package/neon-serverless/session.cjs.map +1 -1
- package/neon-serverless/session.d.cts +8 -13
- package/neon-serverless/session.d.ts +8 -13
- package/neon-serverless/session.js +5 -40
- package/neon-serverless/session.js.map +1 -1
- package/node-postgres/driver.cjs +7 -13
- package/node-postgres/driver.cjs.map +1 -1
- package/node-postgres/driver.d.cts +8 -9
- package/node-postgres/driver.d.ts +8 -9
- package/node-postgres/driver.js +10 -13
- package/node-postgres/driver.js.map +1 -1
- package/node-postgres/migrator.cjs.map +1 -1
- package/node-postgres/migrator.d.cts +1 -2
- package/node-postgres/migrator.d.ts +1 -2
- package/node-postgres/migrator.js.map +1 -1
- package/node-postgres/session.cjs +4 -45
- package/node-postgres/session.cjs.map +1 -1
- package/node-postgres/session.d.cts +8 -13
- package/node-postgres/session.d.ts +8 -13
- package/node-postgres/session.js +4 -45
- package/node-postgres/session.js.map +1 -1
- package/op-sqlite/driver.cjs +5 -22
- package/op-sqlite/driver.cjs.map +1 -1
- package/op-sqlite/driver.d.cts +2 -3
- package/op-sqlite/driver.d.ts +2 -3
- package/op-sqlite/driver.js +8 -12
- package/op-sqlite/driver.js.map +1 -1
- package/op-sqlite/migrator.cjs.map +1 -1
- package/op-sqlite/migrator.d.cts +2 -3
- package/op-sqlite/migrator.d.ts +2 -3
- package/op-sqlite/migrator.js.map +1 -1
- package/op-sqlite/session.cjs +4 -47
- package/op-sqlite/session.cjs.map +1 -1
- package/op-sqlite/session.d.cts +8 -14
- package/op-sqlite/session.d.ts +8 -14
- package/op-sqlite/session.js +4 -47
- package/op-sqlite/session.js.map +1 -1
- package/package.json +64 -52
- package/pg-core/db.cjs +24 -42
- package/pg-core/db.cjs.map +1 -1
- package/pg-core/db.d.cts +13 -23
- package/pg-core/db.d.ts +13 -23
- package/pg-core/db.js +23 -41
- package/pg-core/db.js.map +1 -1
- package/pg-core/dialect.cjs +488 -161
- package/pg-core/dialect.cjs.map +1 -1
- package/pg-core/dialect.d.cts +7 -24
- package/pg-core/dialect.d.ts +7 -24
- package/pg-core/dialect.js +494 -158
- package/pg-core/dialect.js.map +1 -1
- package/pg-core/query-builders/count.cjs.map +1 -1
- package/pg-core/query-builders/count.d.cts +1 -1
- package/pg-core/query-builders/count.d.ts +1 -1
- package/pg-core/query-builders/count.js.map +1 -1
- package/pg-core/query-builders/delete.cjs +13 -0
- package/pg-core/query-builders/delete.cjs.map +1 -1
- package/pg-core/query-builders/delete.d.cts +13 -10
- package/pg-core/query-builders/delete.d.ts +13 -10
- package/pg-core/query-builders/delete.js +14 -1
- package/pg-core/query-builders/delete.js.map +1 -1
- package/pg-core/query-builders/insert.cjs +13 -0
- package/pg-core/query-builders/insert.cjs.map +1 -1
- package/pg-core/query-builders/insert.d.cts +10 -8
- package/pg-core/query-builders/insert.d.ts +10 -8
- package/pg-core/query-builders/insert.js +14 -1
- package/pg-core/query-builders/insert.js.map +1 -1
- package/pg-core/query-builders/query-builder.cjs +15 -11
- package/pg-core/query-builders/query-builder.cjs.map +1 -1
- package/pg-core/query-builders/query-builder.d.cts +3 -6
- package/pg-core/query-builders/query-builder.d.ts +3 -6
- package/pg-core/query-builders/query-builder.js +15 -11
- package/pg-core/query-builders/query-builder.js.map +1 -1
- package/pg-core/query-builders/query.cjs +18 -15
- package/pg-core/query-builders/query.cjs.map +1 -1
- package/pg-core/query-builders/query.d.cts +6 -6
- package/pg-core/query-builders/query.d.ts +6 -6
- package/pg-core/query-builders/query.js +18 -15
- package/pg-core/query-builders/query.js.map +1 -1
- package/pg-core/query-builders/select.cjs +8 -7
- package/pg-core/query-builders/select.cjs.map +1 -1
- package/pg-core/query-builders/select.d.cts +3 -3
- package/pg-core/query-builders/select.d.ts +3 -3
- package/pg-core/query-builders/select.js +8 -7
- package/pg-core/query-builders/select.js.map +1 -1
- package/pg-core/query-builders/select.types.cjs.map +1 -1
- package/pg-core/query-builders/select.types.d.cts +3 -2
- package/pg-core/query-builders/select.types.d.ts +3 -2
- package/pg-core/query-builders/update.cjs +15 -2
- package/pg-core/query-builders/update.cjs.map +1 -1
- package/pg-core/query-builders/update.d.cts +18 -13
- package/pg-core/query-builders/update.d.ts +18 -13
- package/pg-core/query-builders/update.js +16 -3
- package/pg-core/query-builders/update.js.map +1 -1
- package/pg-core/session.cjs +2 -3
- package/pg-core/session.cjs.map +1 -1
- package/pg-core/session.d.cts +6 -9
- package/pg-core/session.d.ts +6 -9
- package/pg-core/session.js +2 -3
- package/pg-core/session.js.map +1 -1
- package/pg-core/subquery.cjs.map +1 -1
- package/pg-core/subquery.d.cts +15 -2
- package/pg-core/subquery.d.ts +15 -2
- package/pg-proxy/driver.cjs +5 -21
- package/pg-proxy/driver.cjs.map +1 -1
- package/pg-proxy/driver.d.cts +2 -3
- package/pg-proxy/driver.d.ts +2 -3
- package/pg-proxy/driver.js +8 -11
- package/pg-proxy/driver.js.map +1 -1
- package/pg-proxy/migrator.cjs.map +1 -1
- package/pg-proxy/migrator.d.cts +1 -2
- package/pg-proxy/migrator.d.ts +1 -2
- package/pg-proxy/migrator.js.map +1 -1
- package/pg-proxy/session.cjs +2 -37
- package/pg-proxy/session.cjs.map +1 -1
- package/pg-proxy/session.d.cts +8 -13
- package/pg-proxy/session.d.ts +8 -13
- package/pg-proxy/session.js +2 -37
- package/pg-proxy/session.js.map +1 -1
- package/pglite/driver.cjs +7 -23
- package/pglite/driver.cjs.map +1 -1
- package/pglite/driver.d.cts +8 -9
- package/pglite/driver.d.ts +8 -9
- package/pglite/driver.js +10 -13
- package/pglite/driver.js.map +1 -1
- package/pglite/migrator.cjs.map +1 -1
- package/pglite/migrator.d.cts +1 -2
- package/pglite/migrator.d.ts +1 -2
- package/pglite/migrator.js.map +1 -1
- package/pglite/session.cjs +3 -34
- package/pglite/session.cjs.map +1 -1
- package/pglite/session.d.cts +8 -13
- package/pglite/session.d.ts +8 -13
- package/pglite/session.js +3 -34
- package/pglite/session.js.map +1 -1
- package/planetscale-serverless/driver.cjs +5 -22
- package/planetscale-serverless/driver.cjs.map +1 -1
- package/planetscale-serverless/driver.d.cts +6 -7
- package/planetscale-serverless/driver.d.ts +6 -7
- package/planetscale-serverless/driver.js +8 -12
- package/planetscale-serverless/driver.js.map +1 -1
- package/planetscale-serverless/migrator.cjs.map +1 -1
- package/planetscale-serverless/migrator.d.cts +1 -2
- package/planetscale-serverless/migrator.d.ts +1 -2
- package/planetscale-serverless/migrator.js.map +1 -1
- package/planetscale-serverless/session.cjs +5 -45
- package/planetscale-serverless/session.cjs.map +1 -1
- package/planetscale-serverless/session.d.cts +9 -14
- package/planetscale-serverless/session.d.ts +9 -14
- package/planetscale-serverless/session.js +5 -45
- package/planetscale-serverless/session.js.map +1 -1
- package/postgres-js/driver.cjs +5 -6
- package/postgres-js/driver.cjs.map +1 -1
- package/postgres-js/driver.d.cts +6 -7
- package/postgres-js/driver.d.ts +6 -7
- package/postgres-js/driver.js +8 -6
- package/postgres-js/driver.js.map +1 -1
- package/postgres-js/migrator.cjs.map +1 -1
- package/postgres-js/migrator.d.cts +1 -2
- package/postgres-js/migrator.d.ts +1 -2
- package/postgres-js/migrator.js.map +1 -1
- package/postgres-js/session.cjs +6 -51
- package/postgres-js/session.cjs.map +1 -1
- package/postgres-js/session.d.cts +9 -15
- package/postgres-js/session.d.ts +9 -15
- package/postgres-js/session.js +6 -51
- package/postgres-js/session.js.map +1 -1
- package/prisma/mysql/driver.cjs +1 -1
- package/prisma/mysql/driver.cjs.map +1 -1
- package/prisma/mysql/driver.js +1 -1
- package/prisma/mysql/driver.js.map +1 -1
- package/prisma/mysql/session.cjs +0 -3
- package/prisma/mysql/session.cjs.map +1 -1
- package/prisma/mysql/session.d.cts +1 -3
- package/prisma/mysql/session.d.ts +1 -3
- package/prisma/mysql/session.js +0 -3
- package/prisma/mysql/session.js.map +1 -1
- package/prisma/pg/driver.cjs +1 -1
- package/prisma/pg/driver.cjs.map +1 -1
- package/prisma/pg/driver.js +1 -1
- package/prisma/pg/driver.js.map +1 -1
- package/prisma/pg/session.cjs +0 -3
- package/prisma/pg/session.cjs.map +1 -1
- package/prisma/pg/session.d.cts +1 -3
- package/prisma/pg/session.d.ts +1 -3
- package/prisma/pg/session.js +0 -3
- package/prisma/pg/session.js.map +1 -1
- package/prisma/sqlite/driver.cjs +1 -1
- package/prisma/sqlite/driver.cjs.map +1 -1
- package/prisma/sqlite/driver.js +1 -1
- package/prisma/sqlite/driver.js.map +1 -1
- package/prisma/sqlite/session.cjs +0 -3
- package/prisma/sqlite/session.cjs.map +1 -1
- package/prisma/sqlite/session.d.cts +2 -4
- package/prisma/sqlite/session.d.ts +2 -4
- package/prisma/sqlite/session.js +0 -3
- package/prisma/sqlite/session.js.map +1 -1
- package/query-builders/select.types.cjs.map +1 -1
- package/query-builders/select.types.d.cts +1 -1
- package/query-builders/select.types.d.ts +1 -1
- package/relations.cjs +245 -595
- package/relations.cjs.map +1 -1
- package/relations.d.cts +131 -276
- package/relations.d.ts +131 -276
- package/relations.js +239 -589
- package/relations.js.map +1 -1
- package/singlestore/driver.cjs +1 -1
- package/singlestore/driver.cjs.map +1 -1
- package/singlestore/driver.d.cts +1 -1
- package/singlestore/driver.d.ts +1 -1
- package/singlestore/driver.js +3 -3
- package/singlestore/driver.js.map +1 -1
- package/singlestore/session.cjs.map +1 -1
- package/singlestore/session.d.cts +4 -4
- package/singlestore/session.d.ts +4 -4
- package/singlestore/session.js.map +1 -1
- package/singlestore-core/db.cjs +17 -11
- package/singlestore-core/db.cjs.map +1 -1
- package/singlestore-core/db.d.cts +7 -10
- package/singlestore-core/db.d.ts +7 -10
- package/singlestore-core/db.js +17 -11
- package/singlestore-core/db.js.map +1 -1
- package/singlestore-core/dialect.cjs +6 -16
- package/singlestore-core/dialect.cjs.map +1 -1
- package/singlestore-core/dialect.d.cts +6 -6
- package/singlestore-core/dialect.d.ts +6 -6
- package/singlestore-core/dialect.js +12 -6
- package/singlestore-core/dialect.js.map +1 -1
- package/singlestore-core/query-builders/query-builder.cjs +15 -11
- package/singlestore-core/query-builders/query-builder.cjs.map +1 -1
- package/singlestore-core/query-builders/query-builder.d.cts +2 -6
- package/singlestore-core/query-builders/query-builder.d.ts +2 -6
- package/singlestore-core/query-builders/query-builder.js +15 -11
- package/singlestore-core/query-builders/query-builder.js.map +1 -1
- package/singlestore-core/query-builders/query.cjs +2 -12
- package/singlestore-core/query-builders/query.cjs.map +1 -1
- package/singlestore-core/query-builders/query.d.cts +6 -6
- package/singlestore-core/query-builders/query.d.ts +6 -6
- package/singlestore-core/query-builders/query.js +4 -2
- package/singlestore-core/query-builders/query.js.map +1 -1
- package/singlestore-core/session.cjs.map +1 -1
- package/singlestore-core/session.d.cts +5 -5
- package/singlestore-core/session.d.ts +5 -5
- package/singlestore-core/session.js.map +1 -1
- package/singlestore-core/subquery.cjs.map +1 -1
- package/singlestore-core/subquery.d.cts +15 -2
- package/singlestore-core/subquery.d.ts +15 -2
- package/singlestore-core/table.cjs.map +1 -1
- package/singlestore-core/table.d.cts +12 -12
- package/singlestore-core/table.d.ts +12 -12
- package/singlestore-core/table.js.map +1 -1
- package/singlestore-proxy/driver.cjs +1 -1
- package/singlestore-proxy/driver.cjs.map +1 -1
- package/singlestore-proxy/driver.js +3 -3
- package/singlestore-proxy/driver.js.map +1 -1
- package/singlestore-proxy/session.cjs.map +1 -1
- package/singlestore-proxy/session.d.cts +4 -4
- package/singlestore-proxy/session.d.ts +4 -4
- package/singlestore-proxy/session.js.map +1 -1
- package/sql/sql.cjs +6 -1
- package/sql/sql.cjs.map +1 -1
- package/sql/sql.d.cts +9 -8
- package/sql/sql.d.ts +9 -8
- package/sql/sql.js +5 -1
- package/sql/sql.js.map +1 -1
- package/sql-js/driver.cjs +5 -16
- package/sql-js/driver.cjs.map +1 -1
- package/sql-js/driver.d.cts +2 -3
- package/sql-js/driver.d.ts +2 -3
- package/sql-js/driver.js +8 -6
- package/sql-js/driver.js.map +1 -1
- package/sql-js/migrator.cjs.map +1 -1
- package/sql-js/migrator.d.cts +1 -2
- package/sql-js/migrator.d.ts +1 -2
- package/sql-js/migrator.js.map +1 -1
- package/sql-js/session.cjs +4 -76
- package/sql-js/session.cjs.map +1 -1
- package/sql-js/session.d.cts +8 -15
- package/sql-js/session.d.ts +8 -15
- package/sql-js/session.js +4 -76
- package/sql-js/session.js.map +1 -1
- package/sqlite-core/db.cjs +31 -49
- package/sqlite-core/db.cjs.map +1 -1
- package/sqlite-core/db.d.cts +12 -23
- package/sqlite-core/db.d.ts +12 -23
- package/sqlite-core/db.js +30 -48
- package/sqlite-core/db.js.map +1 -1
- package/sqlite-core/dialect.cjs +7 -183
- package/sqlite-core/dialect.cjs.map +1 -1
- package/sqlite-core/dialect.d.cts +9 -28
- package/sqlite-core/dialect.d.ts +9 -28
- package/sqlite-core/dialect.js +13 -180
- package/sqlite-core/dialect.js.map +1 -1
- package/sqlite-core/query-builders/count.cjs.map +1 -1
- package/sqlite-core/query-builders/count.d.cts +1 -1
- package/sqlite-core/query-builders/count.d.ts +1 -1
- package/sqlite-core/query-builders/count.js.map +1 -1
- package/sqlite-core/query-builders/delete.cjs.map +1 -1
- package/sqlite-core/query-builders/delete.d.cts +1 -1
- package/sqlite-core/query-builders/delete.d.ts +1 -1
- package/sqlite-core/query-builders/delete.js.map +1 -1
- package/sqlite-core/query-builders/insert.cjs.map +1 -1
- package/sqlite-core/query-builders/insert.d.cts +3 -3
- package/sqlite-core/query-builders/insert.d.ts +3 -3
- package/sqlite-core/query-builders/insert.js.map +1 -1
- package/sqlite-core/query-builders/query-builder.cjs +15 -11
- package/sqlite-core/query-builders/query-builder.cjs.map +1 -1
- package/sqlite-core/query-builders/query-builder.d.cts +2 -6
- package/sqlite-core/query-builders/query-builder.d.ts +2 -6
- package/sqlite-core/query-builders/query-builder.js +15 -11
- package/sqlite-core/query-builders/query-builder.js.map +1 -1
- package/sqlite-core/query-builders/query.cjs +32 -53
- package/sqlite-core/query-builders/query.cjs.map +1 -1
- package/sqlite-core/query-builders/query.d.cts +17 -18
- package/sqlite-core/query-builders/query.d.ts +17 -18
- package/sqlite-core/query-builders/query.js +32 -53
- package/sqlite-core/query-builders/query.js.map +1 -1
- package/sqlite-core/query-builders/select.cjs.map +1 -1
- package/sqlite-core/query-builders/select.d.cts +3 -3
- package/sqlite-core/query-builders/select.d.ts +3 -3
- package/sqlite-core/query-builders/select.js.map +1 -1
- package/sqlite-core/query-builders/update.cjs.map +1 -1
- package/sqlite-core/query-builders/update.d.cts +3 -3
- package/sqlite-core/query-builders/update.d.ts +3 -3
- package/sqlite-core/query-builders/update.js.map +1 -1
- package/sqlite-core/session.cjs +2 -6
- package/sqlite-core/session.cjs.map +1 -1
- package/sqlite-core/session.d.cts +7 -15
- package/sqlite-core/session.d.ts +7 -15
- package/sqlite-core/session.js +2 -6
- package/sqlite-core/session.js.map +1 -1
- package/sqlite-core/subquery.cjs.map +1 -1
- package/sqlite-core/subquery.d.cts +15 -2
- package/sqlite-core/subquery.d.ts +15 -2
- package/sqlite-proxy/driver.cjs +5 -23
- package/sqlite-proxy/driver.cjs.map +1 -1
- package/sqlite-proxy/driver.d.cts +3 -4
- package/sqlite-proxy/driver.d.ts +3 -4
- package/sqlite-proxy/driver.js +5 -13
- package/sqlite-proxy/driver.js.map +1 -1
- package/sqlite-proxy/migrator.cjs.map +1 -1
- package/sqlite-proxy/migrator.d.cts +1 -2
- package/sqlite-proxy/migrator.d.ts +1 -2
- package/sqlite-proxy/migrator.js.map +1 -1
- package/sqlite-proxy/session.cjs +6 -50
- package/sqlite-proxy/session.cjs.map +1 -1
- package/sqlite-proxy/session.d.cts +8 -14
- package/sqlite-proxy/session.d.ts +8 -14
- package/sqlite-proxy/session.js +6 -50
- package/sqlite-proxy/session.js.map +1 -1
- package/subquery.cjs.map +1 -1
- package/subquery.d.cts +1 -0
- package/subquery.d.ts +1 -0
- package/subquery.js.map +1 -1
- package/table.cjs.map +1 -1
- package/table.d.cts +1 -1
- package/table.d.ts +1 -1
- package/table.js.map +1 -1
- package/tidb-serverless/driver.cjs +5 -22
- package/tidb-serverless/driver.cjs.map +1 -1
- package/tidb-serverless/driver.d.cts +6 -7
- package/tidb-serverless/driver.d.ts +6 -7
- package/tidb-serverless/driver.js +8 -12
- package/tidb-serverless/driver.js.map +1 -1
- package/tidb-serverless/migrator.cjs.map +1 -1
- package/tidb-serverless/migrator.d.cts +1 -2
- package/tidb-serverless/migrator.d.ts +1 -2
- package/tidb-serverless/migrator.js.map +1 -1
- package/tidb-serverless/session.cjs +5 -62
- package/tidb-serverless/session.cjs.map +1 -1
- package/tidb-serverless/session.d.cts +9 -14
- package/tidb-serverless/session.d.ts +9 -14
- package/tidb-serverless/session.js +5 -62
- package/tidb-serverless/session.js.map +1 -1
- package/utils.cjs +2 -2
- package/utils.cjs.map +1 -1
- package/utils.d.cts +1 -3
- package/utils.d.ts +1 -3
- package/utils.js +2 -2
- package/utils.js.map +1 -1
- package/vercel-postgres/driver.cjs +7 -23
- package/vercel-postgres/driver.cjs.map +1 -1
- package/vercel-postgres/driver.d.cts +8 -9
- package/vercel-postgres/driver.d.ts +8 -9
- package/vercel-postgres/driver.js +10 -13
- package/vercel-postgres/driver.js.map +1 -1
- package/vercel-postgres/migrator.cjs.map +1 -1
- package/vercel-postgres/migrator.d.cts +1 -2
- package/vercel-postgres/migrator.d.ts +1 -2
- package/vercel-postgres/migrator.js.map +1 -1
- package/vercel-postgres/session.cjs +8 -34
- package/vercel-postgres/session.cjs.map +1 -1
- package/vercel-postgres/session.d.cts +10 -14
- package/vercel-postgres/session.d.ts +10 -14
- package/vercel-postgres/session.js +8 -34
- package/vercel-postgres/session.js.map +1 -1
- package/version.cjs +1 -1
- package/version.d.cts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/xata-http/driver.cjs +5 -17
- package/xata-http/driver.cjs.map +1 -1
- package/xata-http/driver.d.cts +4 -5
- package/xata-http/driver.d.ts +4 -5
- package/xata-http/driver.js +5 -7
- package/xata-http/driver.js.map +1 -1
- package/xata-http/migrator.cjs.map +1 -1
- package/xata-http/migrator.d.cts +1 -2
- package/xata-http/migrator.d.ts +1 -2
- package/xata-http/migrator.js.map +1 -1
- package/xata-http/session.cjs +2 -30
- package/xata-http/session.cjs.map +1 -1
- package/xata-http/session.d.cts +8 -13
- package/xata-http/session.d.ts +8 -13
- package/xata-http/session.js +2 -30
- package/xata-http/session.js.map +1 -1
- package/_relations.cjs +0 -328
- package/_relations.cjs.map +0 -1
- package/_relations.d.cts +0 -215
- package/_relations.d.ts +0 -215
- package/_relations.js +0 -316
- package/_relations.js.map +0 -1
- package/mysql-core/query-builders/_query.cjs +0 -149
- package/mysql-core/query-builders/_query.cjs.map +0 -1
- package/mysql-core/query-builders/_query.d.cts +0 -44
- package/mysql-core/query-builders/_query.d.ts +0 -44
- package/mysql-core/query-builders/_query.js +0 -114
- package/mysql-core/query-builders/_query.js.map +0 -1
- package/pg-core/query-builders/_query.cjs +0 -155
- package/pg-core/query-builders/_query.cjs.map +0 -1
- package/pg-core/query-builders/_query.d.cts +0 -47
- package/pg-core/query-builders/_query.d.ts +0 -47
- package/pg-core/query-builders/_query.js +0 -120
- package/pg-core/query-builders/_query.js.map +0 -1
- package/sqlite-core/query-builders/_query.cjs +0 -187
- package/sqlite-core/query-builders/_query.cjs.map +0 -1
- package/sqlite-core/query-builders/_query.d.cts +0 -55
- package/sqlite-core/query-builders/_query.d.ts +0 -55
- package/sqlite-core/query-builders/_query.js +0 -151
- package/sqlite-core/query-builders/_query.js.map +0 -1
|
@@ -26,47 +26,50 @@ 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(fullSchema, schema, tableNamesMap, table, tableConfig, dialect, session, mode) {
|
|
30
|
+
this.fullSchema = fullSchema;
|
|
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;
|
|
37
38
|
}
|
|
38
|
-
static [import_entity.entityKind] = "
|
|
39
|
+
static [import_entity.entityKind] = "MySqlRelationalQueryBuilder";
|
|
39
40
|
findMany(config) {
|
|
40
41
|
return new MySqlRelationalQuery(
|
|
41
|
-
this.
|
|
42
|
+
this.fullSchema,
|
|
42
43
|
this.schema,
|
|
43
44
|
this.tableNamesMap,
|
|
44
45
|
this.table,
|
|
45
46
|
this.tableConfig,
|
|
46
47
|
this.dialect,
|
|
47
48
|
this.session,
|
|
48
|
-
config
|
|
49
|
-
"many"
|
|
49
|
+
config ? config : {},
|
|
50
|
+
"many",
|
|
51
|
+
this.mode
|
|
50
52
|
);
|
|
51
53
|
}
|
|
52
54
|
findFirst(config) {
|
|
53
55
|
return new MySqlRelationalQuery(
|
|
54
|
-
this.
|
|
56
|
+
this.fullSchema,
|
|
55
57
|
this.schema,
|
|
56
58
|
this.tableNamesMap,
|
|
57
59
|
this.table,
|
|
58
60
|
this.tableConfig,
|
|
59
61
|
this.dialect,
|
|
60
62
|
this.session,
|
|
61
|
-
config
|
|
62
|
-
"first"
|
|
63
|
+
config ? { ...config, limit: 1 } : { limit: 1 },
|
|
64
|
+
"first",
|
|
65
|
+
this.mode
|
|
63
66
|
);
|
|
64
67
|
}
|
|
65
68
|
}
|
|
66
69
|
class MySqlRelationalQuery extends import_query_promise.QueryPromise {
|
|
67
|
-
constructor(
|
|
70
|
+
constructor(fullSchema, schema, tableNamesMap, table, tableConfig, dialect, session, config, queryMode, mode) {
|
|
68
71
|
super();
|
|
69
|
-
this.
|
|
72
|
+
this.fullSchema = fullSchema;
|
|
70
73
|
this.schema = schema;
|
|
71
74
|
this.tableNamesMap = tableNamesMap;
|
|
72
75
|
this.table = table;
|
|
@@ -74,17 +77,18 @@ class MySqlRelationalQuery extends import_query_promise.QueryPromise {
|
|
|
74
77
|
this.dialect = dialect;
|
|
75
78
|
this.session = session;
|
|
76
79
|
this.config = config;
|
|
80
|
+
this.queryMode = queryMode;
|
|
77
81
|
this.mode = mode;
|
|
78
82
|
}
|
|
79
|
-
static [import_entity.entityKind] = "
|
|
83
|
+
static [import_entity.entityKind] = "MySqlRelationalQuery";
|
|
80
84
|
prepare() {
|
|
81
85
|
const { query, builtQuery } = this._toSQL();
|
|
82
|
-
return this.session.
|
|
86
|
+
return this.session.prepareQuery(
|
|
83
87
|
builtQuery,
|
|
84
88
|
void 0,
|
|
85
89
|
(rawRows) => {
|
|
86
|
-
const rows = rawRows.map((row) => (0, import_relations.mapRelationalRow)(row, query.selection));
|
|
87
|
-
if (this.
|
|
90
|
+
const rows = rawRows.map((row) => (0, import_relations.mapRelationalRow)(this.schema, this.tableConfig, row, query.selection));
|
|
91
|
+
if (this.queryMode === "first") {
|
|
88
92
|
return rows[0];
|
|
89
93
|
}
|
|
90
94
|
return rows;
|
|
@@ -92,15 +96,24 @@ class MySqlRelationalQuery extends import_query_promise.QueryPromise {
|
|
|
92
96
|
);
|
|
93
97
|
}
|
|
94
98
|
_getQuery() {
|
|
95
|
-
|
|
99
|
+
const query = this.mode === "planetscale" ? this.dialect.buildRelationalQueryWithoutLateralSubqueries({
|
|
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,
|
|
96
109
|
schema: this.schema,
|
|
97
110
|
tableNamesMap: this.tableNamesMap,
|
|
98
111
|
table: this.table,
|
|
99
112
|
tableConfig: this.tableConfig,
|
|
100
113
|
queryConfig: this.config,
|
|
101
|
-
|
|
102
|
-
mode: this.mode
|
|
114
|
+
tableAlias: this.tableConfig.tsName
|
|
103
115
|
});
|
|
116
|
+
return query;
|
|
104
117
|
}
|
|
105
118
|
_toSQL() {
|
|
106
119
|
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 {\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 TablesRelationalConfig,\n\tTFields extends 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: TableRelationalConfig,\n\t\tprivate dialect: MySqlDialect,\n\t\tprivate session: MySqlSession,\n\t\tprivate mode: Mode,\n\t) {}\n\n\tfindMany<TConfig extends DBQueryConfig<'many', true, TSchema, TFields>>(\n\t\tconfig?: KnownKeysOnly<TConfig, DBQueryConfig<'many', true, TSchema, TFields>>,\n\t): MySqlRelationalQuery<TPreparedQueryHKT, 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 DBQueryConfig<'many', true>) : {},\n\t\t\t'many',\n\t\t\tthis.mode,\n\t\t);\n\t}\n\n\tfindFirst<TSelection extends Omit<DBQueryConfig<'many', true, TSchema, TFields>, 'limit'>>(\n\t\tconfig?: KnownKeysOnly<TSelection, Omit<DBQueryConfig<'many', true, TSchema, TFields>, 'limit'>>,\n\t): MySqlRelationalQuery<TPreparedQueryHKT, 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 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: 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', 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) => 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: 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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA2B;AAC3B,2BAA6B;AAC7B,uBAOO;AAaA,MAAM,uBAIX;AAAA,EAGD,YACS,YACA,QACA,eACA,OACA,aACA,SACA,SACA,MACP;AARO;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA,EACN;AAAA,EAXH,QAAiB,wBAAU,IAAY;AAAA,EAavC,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,SAAU,SAAyC,CAAC;AAAA,MACpD;AAAA,MACA,KAAK;AAAA,IACN;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,SAAS,EAAE,GAAI,QAAoD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE;AAAA,MAC3F;AAAA,MACA,KAAK;AAAA,IACN;AAAA,EACD;AACD;AAEO,MAAM,6BAGH,kCAAsB;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,wBAAU,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,YAAQ,mCAAiB,KAAK,QAAQ,KAAK,aAAa,KAAK,MAAM,SAAS,CAAC;AACvG,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,6CAA6C;AAAA,MAC3D,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,qBAAqB;AAAA,MACnC,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,SAA8E;AACrF,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":[]}
|
|
@@ -4,23 +4,24 @@ 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 { MySqlPreparedQueryConfig, MySqlSession, PreparedQueryHKTBase, PreparedQueryKind } from "../session.cjs";
|
|
7
|
+
import type { Mode, 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 fullSchema;
|
|
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;
|
|
17
18
|
static readonly [entityKind]: string;
|
|
18
|
-
constructor(
|
|
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<'
|
|
19
|
+
constructor(fullSchema: Record<string, unknown>, schema: TSchema, tableNamesMap: Record<string, string>, table: MySqlTable, tableConfig: TableRelationalConfig, dialect: MySqlDialect, session: MySqlSession, mode: Mode);
|
|
20
|
+
findMany<TConfig extends DBQueryConfig<'many', true, TSchema, TFields>>(config?: KnownKeysOnly<TConfig, DBQueryConfig<'many', true, TSchema, TFields>>): MySqlRelationalQuery<TPreparedQueryHKT, BuildQueryResult<TSchema, TFields, TConfig>[]>;
|
|
21
|
+
findFirst<TSelection extends Omit<DBQueryConfig<'many', true, TSchema, TFields>, 'limit'>>(config?: KnownKeysOnly<TSelection, Omit<DBQueryConfig<'many', true, TSchema, TFields>, 'limit'>>): MySqlRelationalQuery<TPreparedQueryHKT, BuildQueryResult<TSchema, TFields, TSelection> | undefined>;
|
|
21
22
|
}
|
|
22
23
|
export declare class MySqlRelationalQuery<TPreparedQueryHKT extends PreparedQueryHKTBase, TResult> extends QueryPromise<TResult> {
|
|
23
|
-
private
|
|
24
|
+
private fullSchema;
|
|
24
25
|
private schema;
|
|
25
26
|
private tableNamesMap;
|
|
26
27
|
private table;
|
|
@@ -28,10 +29,11 @@ export declare class MySqlRelationalQuery<TPreparedQueryHKT extends PreparedQuer
|
|
|
28
29
|
private dialect;
|
|
29
30
|
private session;
|
|
30
31
|
private config;
|
|
31
|
-
private
|
|
32
|
+
private queryMode;
|
|
33
|
+
private mode?;
|
|
32
34
|
static readonly [entityKind]: string;
|
|
33
35
|
protected $brand: 'MySqlRelationalQuery';
|
|
34
|
-
constructor(
|
|
36
|
+
constructor(fullSchema: Record<string, unknown>, schema: TablesRelationalConfig, tableNamesMap: Record<string, string>, table: MySqlTable, tableConfig: TableRelationalConfig, dialect: MySqlDialect, session: MySqlSession, config: DBQueryConfig<'many', true> | true, queryMode: 'many' | 'first', mode?: Mode | undefined);
|
|
35
37
|
prepare(): PreparedQueryKind<TPreparedQueryHKT, MySqlPreparedQueryConfig & {
|
|
36
38
|
execute: TResult;
|
|
37
39
|
}, true>;
|
|
@@ -4,23 +4,24 @@ 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 { MySqlPreparedQueryConfig, MySqlSession, PreparedQueryHKTBase, PreparedQueryKind } from "../session.js";
|
|
7
|
+
import type { Mode, 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 fullSchema;
|
|
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;
|
|
17
18
|
static readonly [entityKind]: string;
|
|
18
|
-
constructor(
|
|
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<'
|
|
19
|
+
constructor(fullSchema: Record<string, unknown>, schema: TSchema, tableNamesMap: Record<string, string>, table: MySqlTable, tableConfig: TableRelationalConfig, dialect: MySqlDialect, session: MySqlSession, mode: Mode);
|
|
20
|
+
findMany<TConfig extends DBQueryConfig<'many', true, TSchema, TFields>>(config?: KnownKeysOnly<TConfig, DBQueryConfig<'many', true, TSchema, TFields>>): MySqlRelationalQuery<TPreparedQueryHKT, BuildQueryResult<TSchema, TFields, TConfig>[]>;
|
|
21
|
+
findFirst<TSelection extends Omit<DBQueryConfig<'many', true, TSchema, TFields>, 'limit'>>(config?: KnownKeysOnly<TSelection, Omit<DBQueryConfig<'many', true, TSchema, TFields>, 'limit'>>): MySqlRelationalQuery<TPreparedQueryHKT, BuildQueryResult<TSchema, TFields, TSelection> | undefined>;
|
|
21
22
|
}
|
|
22
23
|
export declare class MySqlRelationalQuery<TPreparedQueryHKT extends PreparedQueryHKTBase, TResult> extends QueryPromise<TResult> {
|
|
23
|
-
private
|
|
24
|
+
private fullSchema;
|
|
24
25
|
private schema;
|
|
25
26
|
private tableNamesMap;
|
|
26
27
|
private table;
|
|
@@ -28,10 +29,11 @@ export declare class MySqlRelationalQuery<TPreparedQueryHKT extends PreparedQuer
|
|
|
28
29
|
private dialect;
|
|
29
30
|
private session;
|
|
30
31
|
private config;
|
|
31
|
-
private
|
|
32
|
+
private queryMode;
|
|
33
|
+
private mode?;
|
|
32
34
|
static readonly [entityKind]: string;
|
|
33
35
|
protected $brand: 'MySqlRelationalQuery';
|
|
34
|
-
constructor(
|
|
36
|
+
constructor(fullSchema: Record<string, unknown>, schema: TablesRelationalConfig, tableNamesMap: Record<string, string>, table: MySqlTable, tableConfig: TableRelationalConfig, dialect: MySqlDialect, session: MySqlSession, config: DBQueryConfig<'many', true> | true, queryMode: 'many' | 'first', mode?: Mode | undefined);
|
|
35
37
|
prepare(): PreparedQueryKind<TPreparedQueryHKT, MySqlPreparedQueryConfig & {
|
|
36
38
|
execute: TResult;
|
|
37
39
|
}, true>;
|
|
@@ -4,47 +4,50 @@ import {
|
|
|
4
4
|
mapRelationalRow
|
|
5
5
|
} from "../../relations.js";
|
|
6
6
|
class RelationalQueryBuilder {
|
|
7
|
-
constructor(
|
|
8
|
-
this.
|
|
7
|
+
constructor(fullSchema, schema, tableNamesMap, table, tableConfig, dialect, session, mode) {
|
|
8
|
+
this.fullSchema = fullSchema;
|
|
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;
|
|
15
16
|
}
|
|
16
|
-
static [entityKind] = "
|
|
17
|
+
static [entityKind] = "MySqlRelationalQueryBuilder";
|
|
17
18
|
findMany(config) {
|
|
18
19
|
return new MySqlRelationalQuery(
|
|
19
|
-
this.
|
|
20
|
+
this.fullSchema,
|
|
20
21
|
this.schema,
|
|
21
22
|
this.tableNamesMap,
|
|
22
23
|
this.table,
|
|
23
24
|
this.tableConfig,
|
|
24
25
|
this.dialect,
|
|
25
26
|
this.session,
|
|
26
|
-
config
|
|
27
|
-
"many"
|
|
27
|
+
config ? config : {},
|
|
28
|
+
"many",
|
|
29
|
+
this.mode
|
|
28
30
|
);
|
|
29
31
|
}
|
|
30
32
|
findFirst(config) {
|
|
31
33
|
return new MySqlRelationalQuery(
|
|
32
|
-
this.
|
|
34
|
+
this.fullSchema,
|
|
33
35
|
this.schema,
|
|
34
36
|
this.tableNamesMap,
|
|
35
37
|
this.table,
|
|
36
38
|
this.tableConfig,
|
|
37
39
|
this.dialect,
|
|
38
40
|
this.session,
|
|
39
|
-
config
|
|
40
|
-
"first"
|
|
41
|
+
config ? { ...config, limit: 1 } : { limit: 1 },
|
|
42
|
+
"first",
|
|
43
|
+
this.mode
|
|
41
44
|
);
|
|
42
45
|
}
|
|
43
46
|
}
|
|
44
47
|
class MySqlRelationalQuery extends QueryPromise {
|
|
45
|
-
constructor(
|
|
48
|
+
constructor(fullSchema, schema, tableNamesMap, table, tableConfig, dialect, session, config, queryMode, mode) {
|
|
46
49
|
super();
|
|
47
|
-
this.
|
|
50
|
+
this.fullSchema = fullSchema;
|
|
48
51
|
this.schema = schema;
|
|
49
52
|
this.tableNamesMap = tableNamesMap;
|
|
50
53
|
this.table = table;
|
|
@@ -52,17 +55,18 @@ class MySqlRelationalQuery extends QueryPromise {
|
|
|
52
55
|
this.dialect = dialect;
|
|
53
56
|
this.session = session;
|
|
54
57
|
this.config = config;
|
|
58
|
+
this.queryMode = queryMode;
|
|
55
59
|
this.mode = mode;
|
|
56
60
|
}
|
|
57
|
-
static [entityKind] = "
|
|
61
|
+
static [entityKind] = "MySqlRelationalQuery";
|
|
58
62
|
prepare() {
|
|
59
63
|
const { query, builtQuery } = this._toSQL();
|
|
60
|
-
return this.session.
|
|
64
|
+
return this.session.prepareQuery(
|
|
61
65
|
builtQuery,
|
|
62
66
|
void 0,
|
|
63
67
|
(rawRows) => {
|
|
64
|
-
const rows = rawRows.map((row) => mapRelationalRow(row, query.selection));
|
|
65
|
-
if (this.
|
|
68
|
+
const rows = rawRows.map((row) => mapRelationalRow(this.schema, this.tableConfig, row, query.selection));
|
|
69
|
+
if (this.queryMode === "first") {
|
|
66
70
|
return rows[0];
|
|
67
71
|
}
|
|
68
72
|
return rows;
|
|
@@ -70,15 +74,24 @@ class MySqlRelationalQuery extends QueryPromise {
|
|
|
70
74
|
);
|
|
71
75
|
}
|
|
72
76
|
_getQuery() {
|
|
73
|
-
|
|
77
|
+
const query = this.mode === "planetscale" ? this.dialect.buildRelationalQueryWithoutLateralSubqueries({
|
|
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,
|
|
74
87
|
schema: this.schema,
|
|
75
88
|
tableNamesMap: this.tableNamesMap,
|
|
76
89
|
table: this.table,
|
|
77
90
|
tableConfig: this.tableConfig,
|
|
78
91
|
queryConfig: this.config,
|
|
79
|
-
|
|
80
|
-
mode: this.mode
|
|
92
|
+
tableAlias: this.tableConfig.tsName
|
|
81
93
|
});
|
|
94
|
+
return query;
|
|
82
95
|
}
|
|
83
96
|
_toSQL() {
|
|
84
97
|
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 {\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 TablesRelationalConfig,\n\tTFields extends 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: TableRelationalConfig,\n\t\tprivate dialect: MySqlDialect,\n\t\tprivate session: MySqlSession,\n\t\tprivate mode: Mode,\n\t) {}\n\n\tfindMany<TConfig extends DBQueryConfig<'many', true, TSchema, TFields>>(\n\t\tconfig?: KnownKeysOnly<TConfig, DBQueryConfig<'many', true, TSchema, TFields>>,\n\t): MySqlRelationalQuery<TPreparedQueryHKT, 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 DBQueryConfig<'many', true>) : {},\n\t\t\t'many',\n\t\t\tthis.mode,\n\t\t);\n\t}\n\n\tfindFirst<TSelection extends Omit<DBQueryConfig<'many', true, TSchema, TFields>, 'limit'>>(\n\t\tconfig?: KnownKeysOnly<TSelection, Omit<DBQueryConfig<'many', true, TSchema, TFields>, 'limit'>>,\n\t): MySqlRelationalQuery<TPreparedQueryHKT, 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 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: 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', 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) => 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: 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,SAAS,kBAAkB;AAC3B,SAAS,oBAAoB;AAC7B;AAAA,EAIC;AAAA,OAGM;AAaA,MAAM,uBAIX;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,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,SAAU,SAAyC,CAAC;AAAA,MACpD;AAAA,MACA,KAAK;AAAA,IACN;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,SAAS,EAAE,GAAI,QAAoD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE;AAAA,MAC3F;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,iBAAiB,KAAK,QAAQ,KAAK,aAAa,KAAK,MAAM,SAAS,CAAC;AACvG,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,6CAA6C;AAAA,MAC3D,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,qBAAqB;AAAA,MACnC,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,SAA8E;AACrF,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":[]}
|
package/mysql-core/session.cjs
CHANGED
|
@@ -68,9 +68,8 @@ class MySqlSession {
|
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
class MySqlTransaction extends import_db.MySqlDatabase {
|
|
71
|
-
constructor(dialect, session,
|
|
72
|
-
super(dialect, session,
|
|
73
|
-
this.relations = relations;
|
|
71
|
+
constructor(dialect, session, schema, nestedIndex, mode) {
|
|
72
|
+
super(dialect, session, schema, mode);
|
|
74
73
|
this.schema = schema;
|
|
75
74
|
this.nestedIndex = nestedIndex;
|
|
76
75
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/mysql-core/session.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"sources":["../../src/mysql-core/session.ts"],"sourcesContent":["import { entityKind } from '~/entity.ts';\nimport { TransactionRollbackError } from '~/errors.ts';\nimport type { RelationalSchemaConfig, TablesRelationalConfig } from '~/relations.ts';\nimport { type Query, type SQL, sql } from '~/sql/sql.ts';\nimport type { Assume, Equal } from '~/utils.ts';\nimport { MySqlDatabase } from './db.ts';\nimport type { MySqlDialect } from './dialect.ts';\nimport type { SelectedFieldsOrdered } from './query-builders/select.types.ts';\n\nexport type Mode = 'default' | 'planetscale';\n\nexport interface MySqlQueryResultHKT {\n\treadonly $brand: 'MySqlQueryResultHKT';\n\treadonly row: unknown;\n\treadonly type: unknown;\n}\n\nexport interface AnyMySqlQueryResultHKT extends MySqlQueryResultHKT {\n\treadonly type: any;\n}\n\nexport type MySqlQueryResultKind<TKind extends MySqlQueryResultHKT, TRow> = (TKind & {\n\treadonly row: TRow;\n})['type'];\n\nexport interface MySqlPreparedQueryConfig {\n\texecute: unknown;\n\titerator: unknown;\n}\n\nexport interface MySqlPreparedQueryHKT {\n\treadonly $brand: 'MySqlPreparedQueryHKT';\n\treadonly config: unknown;\n\treadonly type: unknown;\n}\n\nexport type PreparedQueryKind<\n\tTKind extends MySqlPreparedQueryHKT,\n\tTConfig extends MySqlPreparedQueryConfig,\n\tTAssume extends boolean = false,\n> = Equal<TAssume, true> extends true\n\t? Assume<(TKind & { readonly config: TConfig })['type'], MySqlPreparedQuery<TConfig>>\n\t: (TKind & { readonly config: TConfig })['type'];\n\nexport abstract class MySqlPreparedQuery<T extends MySqlPreparedQueryConfig> {\n\tstatic readonly [entityKind]: string = 'MySqlPreparedQuery';\n\n\t/** @internal */\n\tjoinsNotNullableMap?: Record<string, boolean>;\n\n\tabstract execute(placeholderValues?: Record<string, unknown>): Promise<T['execute']>;\n\n\tabstract iterator(placeholderValues?: Record<string, unknown>): AsyncGenerator<T['iterator']>;\n}\n\nexport interface MySqlTransactionConfig {\n\twithConsistentSnapshot?: boolean;\n\taccessMode?: 'read only' | 'read write';\n\tisolationLevel: 'read uncommitted' | 'read committed' | 'repeatable read' | 'serializable';\n}\n\nexport abstract class MySqlSession<\n\tTQueryResult extends MySqlQueryResultHKT = MySqlQueryResultHKT,\n\tTPreparedQueryHKT extends PreparedQueryHKTBase = PreparedQueryHKTBase,\n\tTFullSchema extends Record<string, unknown> = Record<string, never>,\n\tTSchema extends TablesRelationalConfig = Record<string, never>,\n> {\n\tstatic readonly [entityKind]: string = 'MySqlSession';\n\n\tconstructor(protected dialect: MySqlDialect) {}\n\n\tabstract prepareQuery<T extends MySqlPreparedQueryConfig, TPreparedQueryHKT extends MySqlPreparedQueryHKT>(\n\t\tquery: Query,\n\t\tfields: SelectedFieldsOrdered | undefined,\n\t\tcustomResultMapper?: (rows: unknown[][]) => T['execute'],\n\t\tgeneratedIds?: Record<string, unknown>[],\n\t\treturningIds?: SelectedFieldsOrdered,\n\t): PreparedQueryKind<TPreparedQueryHKT, T>;\n\n\texecute<T>(query: SQL): Promise<T> {\n\t\treturn this.prepareQuery<MySqlPreparedQueryConfig & { execute: T }, PreparedQueryHKTBase>(\n\t\t\tthis.dialect.sqlToQuery(query),\n\t\t\tundefined,\n\t\t).execute();\n\t}\n\n\tabstract all<T = unknown>(query: SQL): Promise<T[]>;\n\n\tasync count(sql: SQL): Promise<number> {\n\t\tconst res = await this.execute<[[{ count: string }]]>(sql);\n\n\t\treturn Number(\n\t\t\tres[0][0]['count'],\n\t\t);\n\t}\n\n\tabstract transaction<T>(\n\t\ttransaction: (tx: MySqlTransaction<TQueryResult, TPreparedQueryHKT, TFullSchema, TSchema>) => Promise<T>,\n\t\tconfig?: MySqlTransactionConfig,\n\t): Promise<T>;\n\n\tprotected getSetTransactionSQL(config: MySqlTransactionConfig): SQL | undefined {\n\t\tconst parts: string[] = [];\n\n\t\tif (config.isolationLevel) {\n\t\t\tparts.push(`isolation level ${config.isolationLevel}`);\n\t\t}\n\n\t\treturn parts.length ? sql`set transaction ${sql.raw(parts.join(' '))}` : undefined;\n\t}\n\n\tprotected getStartTransactionSQL(config: MySqlTransactionConfig): SQL | undefined {\n\t\tconst parts: string[] = [];\n\n\t\tif (config.withConsistentSnapshot) {\n\t\t\tparts.push('with consistent snapshot');\n\t\t}\n\n\t\tif (config.accessMode) {\n\t\t\tparts.push(config.accessMode);\n\t\t}\n\n\t\treturn parts.length ? sql`start transaction ${sql.raw(parts.join(' '))}` : undefined;\n\t}\n}\n\nexport abstract class MySqlTransaction<\n\tTQueryResult extends MySqlQueryResultHKT,\n\tTPreparedQueryHKT extends PreparedQueryHKTBase,\n\tTFullSchema extends Record<string, unknown> = Record<string, never>,\n\tTSchema extends TablesRelationalConfig = Record<string, never>,\n> extends MySqlDatabase<TQueryResult, TPreparedQueryHKT, TFullSchema, TSchema> {\n\tstatic override readonly [entityKind]: string = 'MySqlTransaction';\n\n\tconstructor(\n\t\tdialect: MySqlDialect,\n\t\tsession: MySqlSession,\n\t\tprotected schema: RelationalSchemaConfig<TSchema> | undefined,\n\t\tprotected readonly nestedIndex: number,\n\t\tmode: Mode,\n\t) {\n\t\tsuper(dialect, session, schema, mode);\n\t}\n\n\trollback(): never {\n\t\tthrow new TransactionRollbackError();\n\t}\n\n\t/** Nested transactions (aka savepoints) only work with InnoDB engine. */\n\tabstract override transaction<T>(\n\t\ttransaction: (tx: MySqlTransaction<TQueryResult, TPreparedQueryHKT, TFullSchema, TSchema>) => Promise<T>,\n\t): Promise<T>;\n}\n\nexport interface PreparedQueryHKTBase extends MySqlPreparedQueryHKT {\n\ttype: MySqlPreparedQuery<Assume<this['config'], MySqlPreparedQueryConfig>>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA2B;AAC3B,oBAAyC;AAEzC,iBAA0C;AAE1C,gBAA8B;AAuCvB,MAAe,mBAAuD;AAAA,EAC5E,QAAiB,wBAAU,IAAY;AAAA;AAAA,EAGvC;AAKD;AAQO,MAAe,aAKpB;AAAA,EAGD,YAAsB,SAAuB;AAAvB;AAAA,EAAwB;AAAA,EAF9C,QAAiB,wBAAU,IAAY;AAAA,EAYvC,QAAW,OAAwB;AAClC,WAAO,KAAK;AAAA,MACX,KAAK,QAAQ,WAAW,KAAK;AAAA,MAC7B;AAAA,IACD,EAAE,QAAQ;AAAA,EACX;AAAA,EAIA,MAAM,MAAMA,MAA2B;AACtC,UAAM,MAAM,MAAM,KAAK,QAA+BA,IAAG;AAEzD,WAAO;AAAA,MACN,IAAI,CAAC,EAAE,CAAC,EAAE,OAAO;AAAA,IAClB;AAAA,EACD;AAAA,EAOU,qBAAqB,QAAiD;AAC/E,UAAM,QAAkB,CAAC;AAEzB,QAAI,OAAO,gBAAgB;AAC1B,YAAM,KAAK,mBAAmB,OAAO,cAAc,EAAE;AAAA,IACtD;AAEA,WAAO,MAAM,SAAS,iCAAsB,eAAI,IAAI,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK;AAAA,EAC1E;AAAA,EAEU,uBAAuB,QAAiD;AACjF,UAAM,QAAkB,CAAC;AAEzB,QAAI,OAAO,wBAAwB;AAClC,YAAM,KAAK,0BAA0B;AAAA,IACtC;AAEA,QAAI,OAAO,YAAY;AACtB,YAAM,KAAK,OAAO,UAAU;AAAA,IAC7B;AAEA,WAAO,MAAM,SAAS,mCAAwB,eAAI,IAAI,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK;AAAA,EAC5E;AACD;AAEO,MAAe,yBAKZ,wBAAqE;AAAA,EAG9E,YACC,SACA,SACU,QACS,aACnB,MACC;AACD,UAAM,SAAS,SAAS,QAAQ,IAAI;AAJ1B;AACS;AAAA,EAIpB;AAAA,EAVA,QAA0B,wBAAU,IAAY;AAAA,EAYhD,WAAkB;AACjB,UAAM,IAAI,uCAAyB;AAAA,EACpC;AAMD;","names":["sql"]}
|
package/mysql-core/session.d.cts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type * as V1 from "../_relations.cjs";
|
|
2
1
|
import { entityKind } from "../entity.cjs";
|
|
3
|
-
import type {
|
|
2
|
+
import type { RelationalSchemaConfig, TablesRelationalConfig } from "../relations.cjs";
|
|
4
3
|
import { type Query, type SQL } from "../sql/sql.cjs";
|
|
5
4
|
import type { Assume, Equal } from "../utils.cjs";
|
|
6
5
|
import { MySqlDatabase } from "./db.cjs";
|
|
@@ -42,28 +41,26 @@ export interface MySqlTransactionConfig {
|
|
|
42
41
|
accessMode?: 'read only' | 'read write';
|
|
43
42
|
isolationLevel: 'read uncommitted' | 'read committed' | 'repeatable read' | 'serializable';
|
|
44
43
|
}
|
|
45
|
-
export declare abstract class MySqlSession<TQueryResult extends MySqlQueryResultHKT = MySqlQueryResultHKT, TPreparedQueryHKT extends PreparedQueryHKTBase = PreparedQueryHKTBase, TFullSchema extends Record<string, unknown> = Record<string, never>,
|
|
44
|
+
export declare abstract class MySqlSession<TQueryResult extends MySqlQueryResultHKT = MySqlQueryResultHKT, TPreparedQueryHKT extends PreparedQueryHKTBase = PreparedQueryHKTBase, TFullSchema extends Record<string, unknown> = Record<string, never>, TSchema extends TablesRelationalConfig = Record<string, never>> {
|
|
46
45
|
protected dialect: MySqlDialect;
|
|
47
46
|
static readonly [entityKind]: string;
|
|
48
47
|
constructor(dialect: MySqlDialect);
|
|
49
48
|
abstract prepareQuery<T extends MySqlPreparedQueryConfig, TPreparedQueryHKT extends MySqlPreparedQueryHKT>(query: Query, fields: SelectedFieldsOrdered | undefined, customResultMapper?: (rows: unknown[][]) => T['execute'], generatedIds?: Record<string, unknown>[], returningIds?: SelectedFieldsOrdered): PreparedQueryKind<TPreparedQueryHKT, T>;
|
|
50
|
-
abstract prepareRelationalQuery<T extends MySqlPreparedQueryConfig, TPreparedQueryHKT extends MySqlPreparedQueryHKT>(query: Query, fields: SelectedFieldsOrdered | undefined, customResultMapper: (rows: Record<string, unknown>[]) => T['execute'], generatedIds?: Record<string, unknown>[], returningIds?: SelectedFieldsOrdered): PreparedQueryKind<TPreparedQueryHKT, T>;
|
|
51
49
|
execute<T>(query: SQL): Promise<T>;
|
|
52
50
|
abstract all<T = unknown>(query: SQL): Promise<T[]>;
|
|
53
51
|
count(sql: SQL): Promise<number>;
|
|
54
|
-
abstract transaction<T>(transaction: (tx: MySqlTransaction<TQueryResult, TPreparedQueryHKT, TFullSchema,
|
|
52
|
+
abstract transaction<T>(transaction: (tx: MySqlTransaction<TQueryResult, TPreparedQueryHKT, TFullSchema, TSchema>) => Promise<T>, config?: MySqlTransactionConfig): Promise<T>;
|
|
55
53
|
protected getSetTransactionSQL(config: MySqlTransactionConfig): SQL | undefined;
|
|
56
54
|
protected getStartTransactionSQL(config: MySqlTransactionConfig): SQL | undefined;
|
|
57
55
|
}
|
|
58
|
-
export declare abstract class MySqlTransaction<TQueryResult extends MySqlQueryResultHKT, TPreparedQueryHKT extends PreparedQueryHKTBase, TFullSchema extends Record<string, unknown> = Record<string, never>,
|
|
59
|
-
protected
|
|
60
|
-
protected schema: V1.RelationalSchemaConfig<TSchema> | undefined;
|
|
56
|
+
export declare abstract class MySqlTransaction<TQueryResult extends MySqlQueryResultHKT, TPreparedQueryHKT extends PreparedQueryHKTBase, TFullSchema extends Record<string, unknown> = Record<string, never>, TSchema extends TablesRelationalConfig = Record<string, never>> extends MySqlDatabase<TQueryResult, TPreparedQueryHKT, TFullSchema, TSchema> {
|
|
57
|
+
protected schema: RelationalSchemaConfig<TSchema> | undefined;
|
|
61
58
|
protected readonly nestedIndex: number;
|
|
62
59
|
static readonly [entityKind]: string;
|
|
63
|
-
constructor(dialect: MySqlDialect, session: MySqlSession,
|
|
60
|
+
constructor(dialect: MySqlDialect, session: MySqlSession, schema: RelationalSchemaConfig<TSchema> | undefined, nestedIndex: number, mode: Mode);
|
|
64
61
|
rollback(): never;
|
|
65
62
|
/** Nested transactions (aka savepoints) only work with InnoDB engine. */
|
|
66
|
-
abstract transaction<T>(transaction: (tx: MySqlTransaction<TQueryResult, TPreparedQueryHKT, TFullSchema,
|
|
63
|
+
abstract transaction<T>(transaction: (tx: MySqlTransaction<TQueryResult, TPreparedQueryHKT, TFullSchema, TSchema>) => Promise<T>): Promise<T>;
|
|
67
64
|
}
|
|
68
65
|
export interface PreparedQueryHKTBase extends MySqlPreparedQueryHKT {
|
|
69
66
|
type: MySqlPreparedQuery<Assume<this['config'], MySqlPreparedQueryConfig>>;
|
package/mysql-core/session.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type * as V1 from "../_relations.js";
|
|
2
1
|
import { entityKind } from "../entity.js";
|
|
3
|
-
import type {
|
|
2
|
+
import type { RelationalSchemaConfig, TablesRelationalConfig } from "../relations.js";
|
|
4
3
|
import { type Query, type SQL } from "../sql/sql.js";
|
|
5
4
|
import type { Assume, Equal } from "../utils.js";
|
|
6
5
|
import { MySqlDatabase } from "./db.js";
|
|
@@ -42,28 +41,26 @@ export interface MySqlTransactionConfig {
|
|
|
42
41
|
accessMode?: 'read only' | 'read write';
|
|
43
42
|
isolationLevel: 'read uncommitted' | 'read committed' | 'repeatable read' | 'serializable';
|
|
44
43
|
}
|
|
45
|
-
export declare abstract class MySqlSession<TQueryResult extends MySqlQueryResultHKT = MySqlQueryResultHKT, TPreparedQueryHKT extends PreparedQueryHKTBase = PreparedQueryHKTBase, TFullSchema extends Record<string, unknown> = Record<string, never>,
|
|
44
|
+
export declare abstract class MySqlSession<TQueryResult extends MySqlQueryResultHKT = MySqlQueryResultHKT, TPreparedQueryHKT extends PreparedQueryHKTBase = PreparedQueryHKTBase, TFullSchema extends Record<string, unknown> = Record<string, never>, TSchema extends TablesRelationalConfig = Record<string, never>> {
|
|
46
45
|
protected dialect: MySqlDialect;
|
|
47
46
|
static readonly [entityKind]: string;
|
|
48
47
|
constructor(dialect: MySqlDialect);
|
|
49
48
|
abstract prepareQuery<T extends MySqlPreparedQueryConfig, TPreparedQueryHKT extends MySqlPreparedQueryHKT>(query: Query, fields: SelectedFieldsOrdered | undefined, customResultMapper?: (rows: unknown[][]) => T['execute'], generatedIds?: Record<string, unknown>[], returningIds?: SelectedFieldsOrdered): PreparedQueryKind<TPreparedQueryHKT, T>;
|
|
50
|
-
abstract prepareRelationalQuery<T extends MySqlPreparedQueryConfig, TPreparedQueryHKT extends MySqlPreparedQueryHKT>(query: Query, fields: SelectedFieldsOrdered | undefined, customResultMapper: (rows: Record<string, unknown>[]) => T['execute'], generatedIds?: Record<string, unknown>[], returningIds?: SelectedFieldsOrdered): PreparedQueryKind<TPreparedQueryHKT, T>;
|
|
51
49
|
execute<T>(query: SQL): Promise<T>;
|
|
52
50
|
abstract all<T = unknown>(query: SQL): Promise<T[]>;
|
|
53
51
|
count(sql: SQL): Promise<number>;
|
|
54
|
-
abstract transaction<T>(transaction: (tx: MySqlTransaction<TQueryResult, TPreparedQueryHKT, TFullSchema,
|
|
52
|
+
abstract transaction<T>(transaction: (tx: MySqlTransaction<TQueryResult, TPreparedQueryHKT, TFullSchema, TSchema>) => Promise<T>, config?: MySqlTransactionConfig): Promise<T>;
|
|
55
53
|
protected getSetTransactionSQL(config: MySqlTransactionConfig): SQL | undefined;
|
|
56
54
|
protected getStartTransactionSQL(config: MySqlTransactionConfig): SQL | undefined;
|
|
57
55
|
}
|
|
58
|
-
export declare abstract class MySqlTransaction<TQueryResult extends MySqlQueryResultHKT, TPreparedQueryHKT extends PreparedQueryHKTBase, TFullSchema extends Record<string, unknown> = Record<string, never>,
|
|
59
|
-
protected
|
|
60
|
-
protected schema: V1.RelationalSchemaConfig<TSchema> | undefined;
|
|
56
|
+
export declare abstract class MySqlTransaction<TQueryResult extends MySqlQueryResultHKT, TPreparedQueryHKT extends PreparedQueryHKTBase, TFullSchema extends Record<string, unknown> = Record<string, never>, TSchema extends TablesRelationalConfig = Record<string, never>> extends MySqlDatabase<TQueryResult, TPreparedQueryHKT, TFullSchema, TSchema> {
|
|
57
|
+
protected schema: RelationalSchemaConfig<TSchema> | undefined;
|
|
61
58
|
protected readonly nestedIndex: number;
|
|
62
59
|
static readonly [entityKind]: string;
|
|
63
|
-
constructor(dialect: MySqlDialect, session: MySqlSession,
|
|
60
|
+
constructor(dialect: MySqlDialect, session: MySqlSession, schema: RelationalSchemaConfig<TSchema> | undefined, nestedIndex: number, mode: Mode);
|
|
64
61
|
rollback(): never;
|
|
65
62
|
/** Nested transactions (aka savepoints) only work with InnoDB engine. */
|
|
66
|
-
abstract transaction<T>(transaction: (tx: MySqlTransaction<TQueryResult, TPreparedQueryHKT, TFullSchema,
|
|
63
|
+
abstract transaction<T>(transaction: (tx: MySqlTransaction<TQueryResult, TPreparedQueryHKT, TFullSchema, TSchema>) => Promise<T>): Promise<T>;
|
|
67
64
|
}
|
|
68
65
|
export interface PreparedQueryHKTBase extends MySqlPreparedQueryHKT {
|
|
69
66
|
type: MySqlPreparedQuery<Assume<this['config'], MySqlPreparedQueryConfig>>;
|
package/mysql-core/session.js
CHANGED
|
@@ -43,9 +43,8 @@ class MySqlSession {
|
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
class MySqlTransaction extends MySqlDatabase {
|
|
46
|
-
constructor(dialect, session,
|
|
47
|
-
super(dialect, session,
|
|
48
|
-
this.relations = relations;
|
|
46
|
+
constructor(dialect, session, schema, nestedIndex, mode) {
|
|
47
|
+
super(dialect, session, schema, mode);
|
|
49
48
|
this.schema = schema;
|
|
50
49
|
this.nestedIndex = nestedIndex;
|
|
51
50
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/mysql-core/session.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"sources":["../../src/mysql-core/session.ts"],"sourcesContent":["import { entityKind } from '~/entity.ts';\nimport { TransactionRollbackError } from '~/errors.ts';\nimport type { RelationalSchemaConfig, TablesRelationalConfig } from '~/relations.ts';\nimport { type Query, type SQL, sql } from '~/sql/sql.ts';\nimport type { Assume, Equal } from '~/utils.ts';\nimport { MySqlDatabase } from './db.ts';\nimport type { MySqlDialect } from './dialect.ts';\nimport type { SelectedFieldsOrdered } from './query-builders/select.types.ts';\n\nexport type Mode = 'default' | 'planetscale';\n\nexport interface MySqlQueryResultHKT {\n\treadonly $brand: 'MySqlQueryResultHKT';\n\treadonly row: unknown;\n\treadonly type: unknown;\n}\n\nexport interface AnyMySqlQueryResultHKT extends MySqlQueryResultHKT {\n\treadonly type: any;\n}\n\nexport type MySqlQueryResultKind<TKind extends MySqlQueryResultHKT, TRow> = (TKind & {\n\treadonly row: TRow;\n})['type'];\n\nexport interface MySqlPreparedQueryConfig {\n\texecute: unknown;\n\titerator: unknown;\n}\n\nexport interface MySqlPreparedQueryHKT {\n\treadonly $brand: 'MySqlPreparedQueryHKT';\n\treadonly config: unknown;\n\treadonly type: unknown;\n}\n\nexport type PreparedQueryKind<\n\tTKind extends MySqlPreparedQueryHKT,\n\tTConfig extends MySqlPreparedQueryConfig,\n\tTAssume extends boolean = false,\n> = Equal<TAssume, true> extends true\n\t? Assume<(TKind & { readonly config: TConfig })['type'], MySqlPreparedQuery<TConfig>>\n\t: (TKind & { readonly config: TConfig })['type'];\n\nexport abstract class MySqlPreparedQuery<T extends MySqlPreparedQueryConfig> {\n\tstatic readonly [entityKind]: string = 'MySqlPreparedQuery';\n\n\t/** @internal */\n\tjoinsNotNullableMap?: Record<string, boolean>;\n\n\tabstract execute(placeholderValues?: Record<string, unknown>): Promise<T['execute']>;\n\n\tabstract iterator(placeholderValues?: Record<string, unknown>): AsyncGenerator<T['iterator']>;\n}\n\nexport interface MySqlTransactionConfig {\n\twithConsistentSnapshot?: boolean;\n\taccessMode?: 'read only' | 'read write';\n\tisolationLevel: 'read uncommitted' | 'read committed' | 'repeatable read' | 'serializable';\n}\n\nexport abstract class MySqlSession<\n\tTQueryResult extends MySqlQueryResultHKT = MySqlQueryResultHKT,\n\tTPreparedQueryHKT extends PreparedQueryHKTBase = PreparedQueryHKTBase,\n\tTFullSchema extends Record<string, unknown> = Record<string, never>,\n\tTSchema extends TablesRelationalConfig = Record<string, never>,\n> {\n\tstatic readonly [entityKind]: string = 'MySqlSession';\n\n\tconstructor(protected dialect: MySqlDialect) {}\n\n\tabstract prepareQuery<T extends MySqlPreparedQueryConfig, TPreparedQueryHKT extends MySqlPreparedQueryHKT>(\n\t\tquery: Query,\n\t\tfields: SelectedFieldsOrdered | undefined,\n\t\tcustomResultMapper?: (rows: unknown[][]) => T['execute'],\n\t\tgeneratedIds?: Record<string, unknown>[],\n\t\treturningIds?: SelectedFieldsOrdered,\n\t): PreparedQueryKind<TPreparedQueryHKT, T>;\n\n\texecute<T>(query: SQL): Promise<T> {\n\t\treturn this.prepareQuery<MySqlPreparedQueryConfig & { execute: T }, PreparedQueryHKTBase>(\n\t\t\tthis.dialect.sqlToQuery(query),\n\t\t\tundefined,\n\t\t).execute();\n\t}\n\n\tabstract all<T = unknown>(query: SQL): Promise<T[]>;\n\n\tasync count(sql: SQL): Promise<number> {\n\t\tconst res = await this.execute<[[{ count: string }]]>(sql);\n\n\t\treturn Number(\n\t\t\tres[0][0]['count'],\n\t\t);\n\t}\n\n\tabstract transaction<T>(\n\t\ttransaction: (tx: MySqlTransaction<TQueryResult, TPreparedQueryHKT, TFullSchema, TSchema>) => Promise<T>,\n\t\tconfig?: MySqlTransactionConfig,\n\t): Promise<T>;\n\n\tprotected getSetTransactionSQL(config: MySqlTransactionConfig): SQL | undefined {\n\t\tconst parts: string[] = [];\n\n\t\tif (config.isolationLevel) {\n\t\t\tparts.push(`isolation level ${config.isolationLevel}`);\n\t\t}\n\n\t\treturn parts.length ? sql`set transaction ${sql.raw(parts.join(' '))}` : undefined;\n\t}\n\n\tprotected getStartTransactionSQL(config: MySqlTransactionConfig): SQL | undefined {\n\t\tconst parts: string[] = [];\n\n\t\tif (config.withConsistentSnapshot) {\n\t\t\tparts.push('with consistent snapshot');\n\t\t}\n\n\t\tif (config.accessMode) {\n\t\t\tparts.push(config.accessMode);\n\t\t}\n\n\t\treturn parts.length ? sql`start transaction ${sql.raw(parts.join(' '))}` : undefined;\n\t}\n}\n\nexport abstract class MySqlTransaction<\n\tTQueryResult extends MySqlQueryResultHKT,\n\tTPreparedQueryHKT extends PreparedQueryHKTBase,\n\tTFullSchema extends Record<string, unknown> = Record<string, never>,\n\tTSchema extends TablesRelationalConfig = Record<string, never>,\n> extends MySqlDatabase<TQueryResult, TPreparedQueryHKT, TFullSchema, TSchema> {\n\tstatic override readonly [entityKind]: string = 'MySqlTransaction';\n\n\tconstructor(\n\t\tdialect: MySqlDialect,\n\t\tsession: MySqlSession,\n\t\tprotected schema: RelationalSchemaConfig<TSchema> | undefined,\n\t\tprotected readonly nestedIndex: number,\n\t\tmode: Mode,\n\t) {\n\t\tsuper(dialect, session, schema, mode);\n\t}\n\n\trollback(): never {\n\t\tthrow new TransactionRollbackError();\n\t}\n\n\t/** Nested transactions (aka savepoints) only work with InnoDB engine. */\n\tabstract override transaction<T>(\n\t\ttransaction: (tx: MySqlTransaction<TQueryResult, TPreparedQueryHKT, TFullSchema, TSchema>) => Promise<T>,\n\t): Promise<T>;\n}\n\nexport interface PreparedQueryHKTBase extends MySqlPreparedQueryHKT {\n\ttype: MySqlPreparedQuery<Assume<this['config'], MySqlPreparedQueryConfig>>;\n}\n"],"mappings":"AAAA,SAAS,kBAAkB;AAC3B,SAAS,gCAAgC;AAEzC,SAA+B,WAAW;AAE1C,SAAS,qBAAqB;AAuCvB,MAAe,mBAAuD;AAAA,EAC5E,QAAiB,UAAU,IAAY;AAAA;AAAA,EAGvC;AAKD;AAQO,MAAe,aAKpB;AAAA,EAGD,YAAsB,SAAuB;AAAvB;AAAA,EAAwB;AAAA,EAF9C,QAAiB,UAAU,IAAY;AAAA,EAYvC,QAAW,OAAwB;AAClC,WAAO,KAAK;AAAA,MACX,KAAK,QAAQ,WAAW,KAAK;AAAA,MAC7B;AAAA,IACD,EAAE,QAAQ;AAAA,EACX;AAAA,EAIA,MAAM,MAAMA,MAA2B;AACtC,UAAM,MAAM,MAAM,KAAK,QAA+BA,IAAG;AAEzD,WAAO;AAAA,MACN,IAAI,CAAC,EAAE,CAAC,EAAE,OAAO;AAAA,IAClB;AAAA,EACD;AAAA,EAOU,qBAAqB,QAAiD;AAC/E,UAAM,QAAkB,CAAC;AAEzB,QAAI,OAAO,gBAAgB;AAC1B,YAAM,KAAK,mBAAmB,OAAO,cAAc,EAAE;AAAA,IACtD;AAEA,WAAO,MAAM,SAAS,sBAAsB,IAAI,IAAI,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK;AAAA,EAC1E;AAAA,EAEU,uBAAuB,QAAiD;AACjF,UAAM,QAAkB,CAAC;AAEzB,QAAI,OAAO,wBAAwB;AAClC,YAAM,KAAK,0BAA0B;AAAA,IACtC;AAEA,QAAI,OAAO,YAAY;AACtB,YAAM,KAAK,OAAO,UAAU;AAAA,IAC7B;AAEA,WAAO,MAAM,SAAS,wBAAwB,IAAI,IAAI,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK;AAAA,EAC5E;AACD;AAEO,MAAe,yBAKZ,cAAqE;AAAA,EAG9E,YACC,SACA,SACU,QACS,aACnB,MACC;AACD,UAAM,SAAS,SAAS,QAAQ,IAAI;AAJ1B;AACS;AAAA,EAIpB;AAAA,EAVA,QAA0B,UAAU,IAAY;AAAA,EAYhD,WAAkB;AACjB,UAAM,IAAI,yBAAyB;AAAA,EACpC;AAMD;","names":["sql"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/mysql-core/subquery.ts"],"sourcesContent":["import type { AddAliasToSelection } from '~/query-builders/select.types.ts';\nimport type { ColumnsSelection } from '~/sql/sql.ts';\nimport type { Subquery, WithSubquery } from '~/subquery.ts';\n\nexport type SubqueryWithSelection<\n\tTSelection extends ColumnsSelection,\n\tTAlias extends string,\n> =\n\t& Subquery<TAlias, AddAliasToSelection<TSelection, TAlias, 'mysql'>>\n\t& AddAliasToSelection<TSelection, TAlias, 'mysql'>;\n\nexport type WithSubqueryWithSelection<\n\tTSelection extends ColumnsSelection,\n\tTAlias extends string,\n> =\n\t& WithSubquery<TAlias, AddAliasToSelection<TSelection, TAlias, 'mysql'>>\n\t& AddAliasToSelection<TSelection, TAlias, 'mysql'>;\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/mysql-core/subquery.ts"],"sourcesContent":["import type { TypedQueryBuilder } from '~/query-builders/query-builder.ts';\nimport type { AddAliasToSelection } from '~/query-builders/select.types.ts';\nimport type { ColumnsSelection, SQL } from '~/sql/sql.ts';\nimport type { Subquery, WithSubquery, WithSubqueryWithoutSelection } from '~/subquery.ts';\nimport type { QueryBuilder } from './query-builders/query-builder.ts';\n\nexport type SubqueryWithSelection<\n\tTSelection extends ColumnsSelection,\n\tTAlias extends string,\n> =\n\t& Subquery<TAlias, AddAliasToSelection<TSelection, TAlias, 'mysql'>>\n\t& AddAliasToSelection<TSelection, TAlias, 'mysql'>;\n\nexport type WithSubqueryWithSelection<\n\tTSelection extends ColumnsSelection,\n\tTAlias extends string,\n> =\n\t& WithSubquery<TAlias, AddAliasToSelection<TSelection, TAlias, 'mysql'>>\n\t& AddAliasToSelection<TSelection, TAlias, 'mysql'>;\n\nexport interface WithBuilder {\n\t<TAlias extends string>(alias: TAlias): {\n\t\tas: {\n\t\t\t<TSelection extends ColumnsSelection>(\n\t\t\t\tqb: TypedQueryBuilder<TSelection> | ((qb: QueryBuilder) => TypedQueryBuilder<TSelection>),\n\t\t\t): WithSubqueryWithSelection<TSelection, TAlias>;\n\t\t\t(\n\t\t\t\tqb: TypedQueryBuilder<undefined> | ((qb: QueryBuilder) => TypedQueryBuilder<undefined>),\n\t\t\t): WithSubqueryWithoutSelection<TAlias>;\n\t\t};\n\t};\n\t<TAlias extends string, TSelection extends ColumnsSelection>(alias: TAlias, selection: TSelection): {\n\t\tas: (qb: SQL | ((qb: QueryBuilder) => SQL)) => WithSubqueryWithSelection<TSelection, TAlias>;\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|