drizzle-orm 0.36.4-7fe6033 → 0.36.4-dbf7383
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 +10 -11
- package/aws-data-api/pg/driver.d.ts +10 -11
- 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 +8 -9
- package/better-sqlite3/driver.d.ts +8 -9
- 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-sqlite/driver.cjs +22 -5
- package/bun-sqlite/driver.cjs.map +1 -1
- package/bun-sqlite/driver.d.cts +8 -9
- package/bun-sqlite/driver.d.ts +8 -9
- 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/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 +48 -6
- 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 +48 -6
- package/d1/session.js.map +1 -1
- package/expo-sqlite/driver.cjs +22 -5
- package/expo-sqlite/driver.cjs.map +1 -1
- package/expo-sqlite/driver.d.cts +3 -2
- package/expo-sqlite/driver.d.ts +3 -2
- package/expo-sqlite/driver.js +12 -8
- package/expo-sqlite/driver.js.map +1 -1
- package/expo-sqlite/migrator.cjs.map +1 -1
- package/expo-sqlite/migrator.d.cts +3 -2
- package/expo-sqlite/migrator.d.ts +3 -2
- package/expo-sqlite/migrator.js.map +1 -1
- package/expo-sqlite/query.cjs +13 -2
- package/expo-sqlite/query.cjs.map +1 -1
- package/expo-sqlite/query.d.cts +2 -1
- package/expo-sqlite/query.d.ts +2 -1
- package/expo-sqlite/query.js +3 -2
- package/expo-sqlite/query.js.map +1 -1
- package/expo-sqlite/session.cjs +47 -4
- package/expo-sqlite/session.cjs.map +1 -1
- package/expo-sqlite/session.d.cts +14 -8
- package/expo-sqlite/session.d.ts +14 -8
- package/expo-sqlite/session.js +47 -4
- package/expo-sqlite/session.js.map +1 -1
- package/libsql/driver-core.cjs +22 -5
- package/libsql/driver-core.cjs.map +1 -1
- package/libsql/driver-core.d.cts +2 -1
- package/libsql/driver-core.d.ts +2 -1
- package/libsql/driver-core.js +12 -8
- package/libsql/driver-core.js.map +1 -1
- package/libsql/driver.cjs.map +1 -1
- package/libsql/driver.d.cts +7 -8
- package/libsql/driver.d.ts +7 -8
- package/libsql/driver.js.map +1 -1
- package/libsql/http/index.cjs.map +1 -1
- package/libsql/http/index.d.cts +7 -8
- package/libsql/http/index.d.ts +7 -8
- 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 +7 -8
- package/libsql/node/index.d.ts +7 -8
- package/libsql/node/index.js.map +1 -1
- package/libsql/session.cjs +60 -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 +60 -4
- package/libsql/session.js.map +1 -1
- package/libsql/sqlite3/index.cjs.map +1 -1
- package/libsql/sqlite3/index.d.cts +7 -8
- package/libsql/sqlite3/index.d.ts +7 -8
- package/libsql/sqlite3/index.js.map +1 -1
- package/libsql/wasm/index.cjs.map +1 -1
- package/libsql/wasm/index.d.cts +7 -8
- package/libsql/wasm/index.d.ts +7 -8
- package/libsql/wasm/index.js.map +1 -1
- package/libsql/web/index.cjs.map +1 -1
- package/libsql/web/index.d.cts +7 -8
- package/libsql/web/index.d.ts +7 -8
- package/libsql/web/index.js.map +1 -1
- package/libsql/ws/index.cjs.map +1 -1
- package/libsql/ws/index.d.cts +7 -8
- package/libsql/ws/index.d.ts +7 -8
- package/libsql/ws/index.js.map +1 -1
- package/mysql-core/db.cjs +29 -8
- 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 +28 -7
- package/mysql-core/db.js.map +1 -1
- package/mysql-core/dialect.cjs +170 -15
- package/mysql-core/dialect.cjs.map +1 -1
- package/mysql-core/dialect.d.cts +29 -13
- package/mysql-core/dialect.d.ts +29 -13
- package/mysql-core/dialect.js +167 -21
- 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 +47 -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 +47 -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 +11 -12
- package/mysql2/driver.d.ts +11 -12
- 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 +51 -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 +51 -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 +11 -12
- package/neon-http/driver.d.ts +11 -12
- 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 +10 -11
- package/neon-serverless/driver.d.ts +10 -11
- package/neon-serverless/driver.js +8 -10
- package/neon-serverless/driver.js.map +1 -1
- package/neon-serverless/migrator.cjs.map +1 -1
- package/neon-serverless/migrator.d.cts +2 -1
- package/neon-serverless/migrator.d.ts +2 -1
- package/neon-serverless/migrator.js.map +1 -1
- package/neon-serverless/session.cjs +40 -5
- package/neon-serverless/session.cjs.map +1 -1
- package/neon-serverless/session.d.cts +13 -8
- package/neon-serverless/session.d.ts +13 -8
- package/neon-serverless/session.js +40 -5
- package/neon-serverless/session.js.map +1 -1
- package/node-postgres/driver.cjs +13 -7
- package/node-postgres/driver.cjs.map +1 -1
- package/node-postgres/driver.d.cts +10 -11
- package/node-postgres/driver.d.ts +10 -11
- package/node-postgres/driver.js +13 -10
- package/node-postgres/driver.js.map +1 -1
- package/node-postgres/migrator.cjs.map +1 -1
- package/node-postgres/migrator.d.cts +2 -1
- package/node-postgres/migrator.d.ts +2 -1
- package/node-postgres/migrator.js.map +1 -1
- package/node-postgres/session.cjs +45 -4
- package/node-postgres/session.cjs.map +1 -1
- package/node-postgres/session.d.cts +13 -8
- package/node-postgres/session.d.ts +13 -8
- package/node-postgres/session.js +45 -4
- package/node-postgres/session.js.map +1 -1
- package/op-sqlite/driver.cjs +22 -5
- package/op-sqlite/driver.cjs.map +1 -1
- package/op-sqlite/driver.d.cts +3 -2
- package/op-sqlite/driver.d.ts +3 -2
- package/op-sqlite/driver.js +12 -8
- package/op-sqlite/driver.js.map +1 -1
- package/op-sqlite/migrator.cjs.map +1 -1
- package/op-sqlite/migrator.d.cts +3 -2
- package/op-sqlite/migrator.d.ts +3 -2
- package/op-sqlite/migrator.js.map +1 -1
- package/op-sqlite/session.cjs +47 -4
- package/op-sqlite/session.cjs.map +1 -1
- package/op-sqlite/session.d.cts +14 -8
- package/op-sqlite/session.d.ts +14 -8
- package/op-sqlite/session.js +47 -4
- package/op-sqlite/session.js.map +1 -1
- package/package.json +99 -51
- package/pg-core/db.cjs +31 -7
- 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 +30 -6
- package/pg-core/db.js.map +1 -1
- package/pg-core/dialect.cjs +146 -488
- package/pg-core/dialect.cjs.map +1 -1
- package/pg-core/dialect.d.cts +21 -7
- package/pg-core/dialect.d.ts +21 -7
- package/pg-core/dialect.js +143 -494
- 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 +10 -11
- package/pglite/driver.d.ts +10 -11
- package/pglite/driver.js +13 -10
- package/pglite/driver.js.map +1 -1
- package/pglite/migrator.cjs.map +1 -1
- package/pglite/migrator.d.cts +2 -1
- package/pglite/migrator.d.ts +2 -1
- package/pglite/migrator.js.map +1 -1
- package/pglite/session.cjs +34 -3
- package/pglite/session.cjs.map +1 -1
- package/pglite/session.d.cts +13 -8
- package/pglite/session.d.ts +13 -8
- package/pglite/session.js +34 -3
- package/pglite/session.js.map +1 -1
- package/planetscale-serverless/driver.cjs +22 -5
- package/planetscale-serverless/driver.cjs.map +1 -1
- package/planetscale-serverless/driver.d.cts +8 -9
- package/planetscale-serverless/driver.d.ts +8 -9
- 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 +68 -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 +68 -5
- package/planetscale-serverless/session.js.map +1 -1
- package/postgres-js/driver.cjs +12 -6
- package/postgres-js/driver.cjs.map +1 -1
- package/postgres-js/driver.d.cts +8 -9
- package/postgres-js/driver.d.ts +8 -9
- package/postgres-js/driver.js +12 -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 +468 -245
- package/relations.cjs.map +1 -1
- package/relations.d.cts +260 -124
- package/relations.d.ts +260 -124
- package/relations.js +455 -238
- package/relations.js.map +1 -1
- package/sql/sql.cjs.map +1 -1
- package/sql/sql.d.cts +4 -4
- package/sql/sql.d.ts +4 -4
- 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 +58 -4
- package/sql-js/session.cjs.map +1 -1
- package/sql-js/session.d.cts +14 -8
- package/sql-js/session.d.ts +14 -8
- package/sql-js/session.js +58 -4
- package/sql-js/session.js.map +1 -1
- package/sqlite-core/db.cjs +35 -14
- package/sqlite-core/db.cjs.map +1 -1
- package/sqlite-core/db.d.cts +15 -8
- package/sqlite-core/db.d.ts +15 -8
- package/sqlite-core/db.js +34 -13
- package/sqlite-core/db.js.map +1 -1
- package/sqlite-core/dialect.cjs +164 -7
- package/sqlite-core/dialect.cjs.map +1 -1
- package/sqlite-core/dialect.d.cts +25 -9
- package/sqlite-core/dialect.d.ts +25 -9
- package/sqlite-core/dialect.js +161 -13
- 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 +30 -48
- package/sqlite-core/query-builders/query.cjs.map +1 -1
- package/sqlite-core/query-builders/query.d.cts +14 -16
- package/sqlite-core/query-builders/query.d.ts +14 -16
- package/sqlite-core/query-builders/query.js +30 -48
- 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 +14 -6
- package/sqlite-core/session.d.ts +14 -6
- package/sqlite-core/session.js +6 -2
- package/sqlite-core/session.js.map +1 -1
- package/sqlite-proxy/driver.cjs +22 -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 +12 -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 +47 -4
- 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 +47 -4
- package/sqlite-proxy/session.js.map +1 -1
- package/table.cjs.map +1 -1
- package/table.d.cts +1 -1
- package/table.d.ts +1 -1
- package/table.js.map +1 -1
- package/tidb-serverless/driver.cjs +22 -5
- package/tidb-serverless/driver.cjs.map +1 -1
- package/tidb-serverless/driver.d.cts +8 -9
- package/tidb-serverless/driver.d.ts +8 -9
- 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 +11 -13
- package/vercel-postgres/driver.d.ts +11 -13
- package/vercel-postgres/driver.js +13 -10
- package/vercel-postgres/driver.js.map +1 -1
- package/vercel-postgres/migrator.cjs.map +1 -1
- package/vercel-postgres/migrator.d.cts +2 -1
- package/vercel-postgres/migrator.d.ts +2 -1
- package/vercel-postgres/migrator.js.map +1 -1
- package/vercel-postgres/session.cjs +34 -4
- package/vercel-postgres/session.cjs.map +1 -1
- package/vercel-postgres/session.d.cts +13 -8
- package/vercel-postgres/session.d.ts +13 -8
- package/vercel-postgres/session.js +34 -4
- package/vercel-postgres/session.js.map +1 -1
- package/version.cjs +1 -1
- package/version.d.cts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/xata-http/driver.cjs +17 -5
- package/xata-http/driver.cjs.map +1 -1
- package/xata-http/driver.d.cts +5 -4
- package/xata-http/driver.d.ts +5 -4
- package/xata-http/driver.js +7 -5
- package/xata-http/driver.js.map +1 -1
- package/xata-http/migrator.cjs.map +1 -1
- package/xata-http/migrator.d.cts +2 -1
- package/xata-http/migrator.d.ts +2 -1
- package/xata-http/migrator.js.map +1 -1
- package/xata-http/session.cjs +30 -2
- package/xata-http/session.cjs.map +1 -1
- package/xata-http/session.d.cts +13 -8
- package/xata-http/session.d.ts +13 -8
- package/xata-http/session.js +30 -2
- package/xata-http/session.js.map +1 -1
package/mysql-core/dialect.d.cts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import * as V1 from "../_relations.cjs";
|
|
1
2
|
import { entityKind } from "../entity.cjs";
|
|
2
3
|
import type { MigrationConfig, MigrationMeta } from "../migrator.cjs";
|
|
3
|
-
import {
|
|
4
|
+
import type { BuildRelationalQueryResult, DBQueryConfig, TableRelationalConfig, TablesRelationalConfig } from "../relations.cjs";
|
|
4
5
|
import { SQL } from "../sql/sql.cjs";
|
|
5
6
|
import type { QueryWithTypings } from "../sql/sql.cjs";
|
|
6
7
|
import { type Casing, type UpdateSet } from "../utils.cjs";
|
|
@@ -50,26 +51,41 @@ export declare class MySqlDialect {
|
|
|
50
51
|
generatedIds: Record<string, unknown>[];
|
|
51
52
|
};
|
|
52
53
|
sqlToQuery(sql: SQL, invokeSource?: 'indexes' | undefined): QueryWithTypings;
|
|
53
|
-
|
|
54
|
+
/** @deprecated */
|
|
55
|
+
_buildRelationalQuery({ fullSchema, schema, tableNamesMap, table, tableConfig, queryConfig: config, tableAlias, nestedQueryRelation, joinOn, }: {
|
|
54
56
|
fullSchema: Record<string, unknown>;
|
|
55
|
-
schema: TablesRelationalConfig;
|
|
57
|
+
schema: V1.TablesRelationalConfig;
|
|
56
58
|
tableNamesMap: Record<string, string>;
|
|
57
59
|
table: MySqlTable;
|
|
58
|
-
tableConfig: TableRelationalConfig;
|
|
59
|
-
queryConfig: true | DBQueryConfig<'many', true>;
|
|
60
|
+
tableConfig: V1.TableRelationalConfig;
|
|
61
|
+
queryConfig: true | V1.DBQueryConfig<'many', true>;
|
|
60
62
|
tableAlias: string;
|
|
61
|
-
nestedQueryRelation?: Relation;
|
|
63
|
+
nestedQueryRelation?: V1.Relation;
|
|
62
64
|
joinOn?: SQL;
|
|
63
|
-
}): BuildRelationalQueryResult<MySqlTable, MySqlColumn>;
|
|
64
|
-
|
|
65
|
+
}): V1.BuildRelationalQueryResult<MySqlTable, MySqlColumn>;
|
|
66
|
+
/** @deprecated */
|
|
67
|
+
_buildRelationalQueryWithoutLateralSubqueries({ fullSchema, schema, tableNamesMap, table, tableConfig, queryConfig: config, tableAlias, nestedQueryRelation, joinOn, }: {
|
|
65
68
|
fullSchema: Record<string, unknown>;
|
|
66
|
-
schema: TablesRelationalConfig;
|
|
69
|
+
schema: V1.TablesRelationalConfig;
|
|
67
70
|
tableNamesMap: Record<string, string>;
|
|
68
71
|
table: MySqlTable;
|
|
69
|
-
tableConfig: TableRelationalConfig;
|
|
70
|
-
queryConfig: true | DBQueryConfig<'many', true>;
|
|
72
|
+
tableConfig: V1.TableRelationalConfig;
|
|
73
|
+
queryConfig: true | V1.DBQueryConfig<'many', true>;
|
|
71
74
|
tableAlias: string;
|
|
72
|
-
nestedQueryRelation?: Relation;
|
|
75
|
+
nestedQueryRelation?: V1.Relation;
|
|
73
76
|
joinOn?: SQL;
|
|
74
|
-
}): BuildRelationalQueryResult<MySqlTable, MySqlColumn>;
|
|
77
|
+
}): V1.BuildRelationalQueryResult<MySqlTable, MySqlColumn>;
|
|
78
|
+
private unwrapAllColumns;
|
|
79
|
+
private getSelectedTableColumns;
|
|
80
|
+
private buildColumns;
|
|
81
|
+
buildRelationalQuery({ tables, schema, tableNamesMap, table, tableConfig, queryConfig: config, relationWhere, mode, }: {
|
|
82
|
+
tables: Record<string, MySqlTable>;
|
|
83
|
+
schema: TablesRelationalConfig;
|
|
84
|
+
tableNamesMap: Record<string, string>;
|
|
85
|
+
table: MySqlTable;
|
|
86
|
+
tableConfig: TableRelationalConfig;
|
|
87
|
+
queryConfig?: DBQueryConfig<'many'> | true;
|
|
88
|
+
relationWhere?: SQL;
|
|
89
|
+
mode: 'first' | 'many';
|
|
90
|
+
}): BuildRelationalQueryResult;
|
|
75
91
|
}
|
package/mysql-core/dialect.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import * as V1 from "../_relations.js";
|
|
1
2
|
import { entityKind } from "../entity.js";
|
|
2
3
|
import type { MigrationConfig, MigrationMeta } from "../migrator.js";
|
|
3
|
-
import {
|
|
4
|
+
import type { BuildRelationalQueryResult, DBQueryConfig, TableRelationalConfig, TablesRelationalConfig } from "../relations.js";
|
|
4
5
|
import { SQL } from "../sql/sql.js";
|
|
5
6
|
import type { QueryWithTypings } from "../sql/sql.js";
|
|
6
7
|
import { type Casing, type UpdateSet } from "../utils.js";
|
|
@@ -50,26 +51,41 @@ export declare class MySqlDialect {
|
|
|
50
51
|
generatedIds: Record<string, unknown>[];
|
|
51
52
|
};
|
|
52
53
|
sqlToQuery(sql: SQL, invokeSource?: 'indexes' | undefined): QueryWithTypings;
|
|
53
|
-
|
|
54
|
+
/** @deprecated */
|
|
55
|
+
_buildRelationalQuery({ fullSchema, schema, tableNamesMap, table, tableConfig, queryConfig: config, tableAlias, nestedQueryRelation, joinOn, }: {
|
|
54
56
|
fullSchema: Record<string, unknown>;
|
|
55
|
-
schema: TablesRelationalConfig;
|
|
57
|
+
schema: V1.TablesRelationalConfig;
|
|
56
58
|
tableNamesMap: Record<string, string>;
|
|
57
59
|
table: MySqlTable;
|
|
58
|
-
tableConfig: TableRelationalConfig;
|
|
59
|
-
queryConfig: true | DBQueryConfig<'many', true>;
|
|
60
|
+
tableConfig: V1.TableRelationalConfig;
|
|
61
|
+
queryConfig: true | V1.DBQueryConfig<'many', true>;
|
|
60
62
|
tableAlias: string;
|
|
61
|
-
nestedQueryRelation?: Relation;
|
|
63
|
+
nestedQueryRelation?: V1.Relation;
|
|
62
64
|
joinOn?: SQL;
|
|
63
|
-
}): BuildRelationalQueryResult<MySqlTable, MySqlColumn>;
|
|
64
|
-
|
|
65
|
+
}): V1.BuildRelationalQueryResult<MySqlTable, MySqlColumn>;
|
|
66
|
+
/** @deprecated */
|
|
67
|
+
_buildRelationalQueryWithoutLateralSubqueries({ fullSchema, schema, tableNamesMap, table, tableConfig, queryConfig: config, tableAlias, nestedQueryRelation, joinOn, }: {
|
|
65
68
|
fullSchema: Record<string, unknown>;
|
|
66
|
-
schema: TablesRelationalConfig;
|
|
69
|
+
schema: V1.TablesRelationalConfig;
|
|
67
70
|
tableNamesMap: Record<string, string>;
|
|
68
71
|
table: MySqlTable;
|
|
69
|
-
tableConfig: TableRelationalConfig;
|
|
70
|
-
queryConfig: true | DBQueryConfig<'many', true>;
|
|
72
|
+
tableConfig: V1.TableRelationalConfig;
|
|
73
|
+
queryConfig: true | V1.DBQueryConfig<'many', true>;
|
|
71
74
|
tableAlias: string;
|
|
72
|
-
nestedQueryRelation?: Relation;
|
|
75
|
+
nestedQueryRelation?: V1.Relation;
|
|
73
76
|
joinOn?: SQL;
|
|
74
|
-
}): BuildRelationalQueryResult<MySqlTable, MySqlColumn>;
|
|
77
|
+
}): V1.BuildRelationalQueryResult<MySqlTable, MySqlColumn>;
|
|
78
|
+
private unwrapAllColumns;
|
|
79
|
+
private getSelectedTableColumns;
|
|
80
|
+
private buildColumns;
|
|
81
|
+
buildRelationalQuery({ tables, schema, tableNamesMap, table, tableConfig, queryConfig: config, relationWhere, mode, }: {
|
|
82
|
+
tables: Record<string, MySqlTable>;
|
|
83
|
+
schema: TablesRelationalConfig;
|
|
84
|
+
tableNamesMap: Record<string, string>;
|
|
85
|
+
table: MySqlTable;
|
|
86
|
+
tableConfig: TableRelationalConfig;
|
|
87
|
+
queryConfig?: DBQueryConfig<'many'> | true;
|
|
88
|
+
relationWhere?: SQL;
|
|
89
|
+
mode: 'first' | 'many';
|
|
90
|
+
}): BuildRelationalQueryResult;
|
|
75
91
|
}
|
package/mysql-core/dialect.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as V1 from "../_relations.js";
|
|
1
2
|
import { aliasedTable, aliasedTableColumn, mapColumnsInAliasedSQLToAlias, mapColumnsInSQLToAlias } from "../alias.js";
|
|
2
3
|
import { CasingCache } from "../casing.js";
|
|
3
4
|
import { Column } from "../column.js";
|
|
@@ -5,15 +6,16 @@ import { entityKind, is } from "../entity.js";
|
|
|
5
6
|
import { DrizzleError } from "../errors.js";
|
|
6
7
|
import { and, eq } from "../expressions.js";
|
|
7
8
|
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
AggregatedField,
|
|
10
|
+
One,
|
|
11
|
+
relationExtrasToSQL,
|
|
12
|
+
relationFilterToSQL,
|
|
13
|
+
relationsOrderToSQL,
|
|
14
|
+
relationToSQL
|
|
13
15
|
} from "../relations.js";
|
|
14
16
|
import { Param, SQL, sql, View } from "../sql/sql.js";
|
|
15
17
|
import { Subquery } from "../subquery.js";
|
|
16
|
-
import { getTableName, getTableUniqueName, Table } from "../table.js";
|
|
18
|
+
import { Columns, getTableName, getTableUniqueName, Table } from "../table.js";
|
|
17
19
|
import { orderSelectedFields } from "../utils.js";
|
|
18
20
|
import { ViewBaseConfig } from "../view-common.js";
|
|
19
21
|
import { MySqlColumn } from "./columns/common.js";
|
|
@@ -369,7 +371,8 @@ class MySqlDialect {
|
|
|
369
371
|
invokeSource
|
|
370
372
|
});
|
|
371
373
|
}
|
|
372
|
-
|
|
374
|
+
/** @deprecated */
|
|
375
|
+
_buildRelationalQuery({
|
|
373
376
|
fullSchema,
|
|
374
377
|
schema,
|
|
375
378
|
tableNamesMap,
|
|
@@ -398,7 +401,7 @@ class MySqlDialect {
|
|
|
398
401
|
Object.entries(tableConfig.columns).map(([key, value]) => [key, aliasedTableColumn(value, tableAlias)])
|
|
399
402
|
);
|
|
400
403
|
if (config.where) {
|
|
401
|
-
const whereSql = typeof config.where === "function" ? config.where(aliasedColumns, getOperators()) : config.where;
|
|
404
|
+
const whereSql = typeof config.where === "function" ? config.where(aliasedColumns, V1.getOperators()) : config.where;
|
|
402
405
|
where = whereSql && mapColumnsInSQLToAlias(whereSql, tableAlias);
|
|
403
406
|
}
|
|
404
407
|
const fieldsSelection = [];
|
|
@@ -450,7 +453,7 @@ class MySqlDialect {
|
|
|
450
453
|
selection: []
|
|
451
454
|
});
|
|
452
455
|
}
|
|
453
|
-
let orderByOrig = typeof config.orderBy === "function" ? config.orderBy(aliasedColumns, getOrderByOperators()) : config.orderBy ?? [];
|
|
456
|
+
let orderByOrig = typeof config.orderBy === "function" ? config.orderBy(aliasedColumns, V1.getOrderByOperators()) : config.orderBy ?? [];
|
|
454
457
|
if (!Array.isArray(orderByOrig)) {
|
|
455
458
|
orderByOrig = [orderByOrig];
|
|
456
459
|
}
|
|
@@ -467,7 +470,7 @@ class MySqlDialect {
|
|
|
467
470
|
queryConfig: selectedRelationConfigValue,
|
|
468
471
|
relation
|
|
469
472
|
} of selectedRelations) {
|
|
470
|
-
const normalizedRelation = normalizeRelation(schema, tableNamesMap, relation);
|
|
473
|
+
const normalizedRelation = V1.normalizeRelation(schema, tableNamesMap, relation);
|
|
471
474
|
const relationTableName = getTableUniqueName(relation.referencedTable);
|
|
472
475
|
const relationTableTsName = tableNamesMap[relationTableName];
|
|
473
476
|
const relationTableAlias = `${tableAlias}_${selectedRelationTsKey}`;
|
|
@@ -479,13 +482,13 @@ class MySqlDialect {
|
|
|
479
482
|
)
|
|
480
483
|
)
|
|
481
484
|
);
|
|
482
|
-
const builtRelation = this.
|
|
485
|
+
const builtRelation = this._buildRelationalQuery({
|
|
483
486
|
fullSchema,
|
|
484
487
|
schema,
|
|
485
488
|
tableNamesMap,
|
|
486
489
|
table: fullSchema[relationTableTsName],
|
|
487
490
|
tableConfig: schema[relationTableTsName],
|
|
488
|
-
queryConfig: is(relation, One) ? selectedRelationConfigValue === true ? { limit: 1 } : { ...selectedRelationConfigValue, limit: 1 } : selectedRelationConfigValue,
|
|
491
|
+
queryConfig: is(relation, V1.One) ? selectedRelationConfigValue === true ? { limit: 1 } : { ...selectedRelationConfigValue, limit: 1 } : selectedRelationConfigValue,
|
|
489
492
|
tableAlias: relationTableAlias,
|
|
490
493
|
joinOn: joinOn2,
|
|
491
494
|
nestedQueryRelation: relation
|
|
@@ -520,7 +523,7 @@ class MySqlDialect {
|
|
|
520
523
|
),
|
|
521
524
|
sql`, `
|
|
522
525
|
)})`;
|
|
523
|
-
if (is(nestedQueryRelation, Many)) {
|
|
526
|
+
if (is(nestedQueryRelation, V1.Many)) {
|
|
524
527
|
field = sql`coalesce(json_arrayagg(${field}), json_array())`;
|
|
525
528
|
}
|
|
526
529
|
const nestedSelection = [{
|
|
@@ -594,7 +597,8 @@ class MySqlDialect {
|
|
|
594
597
|
selection
|
|
595
598
|
};
|
|
596
599
|
}
|
|
597
|
-
|
|
600
|
+
/** @deprecated */
|
|
601
|
+
_buildRelationalQueryWithoutLateralSubqueries({
|
|
598
602
|
fullSchema,
|
|
599
603
|
schema,
|
|
600
604
|
tableNamesMap,
|
|
@@ -622,7 +626,7 @@ class MySqlDialect {
|
|
|
622
626
|
Object.entries(tableConfig.columns).map(([key, value]) => [key, aliasedTableColumn(value, tableAlias)])
|
|
623
627
|
);
|
|
624
628
|
if (config.where) {
|
|
625
|
-
const whereSql = typeof config.where === "function" ? config.where(aliasedColumns, getOperators()) : config.where;
|
|
629
|
+
const whereSql = typeof config.where === "function" ? config.where(aliasedColumns, V1.getOperators()) : config.where;
|
|
626
630
|
where = whereSql && mapColumnsInSQLToAlias(whereSql, tableAlias);
|
|
627
631
|
}
|
|
628
632
|
const fieldsSelection = [];
|
|
@@ -674,7 +678,7 @@ class MySqlDialect {
|
|
|
674
678
|
selection: []
|
|
675
679
|
});
|
|
676
680
|
}
|
|
677
|
-
let orderByOrig = typeof config.orderBy === "function" ? config.orderBy(aliasedColumns, getOrderByOperators()) : config.orderBy ?? [];
|
|
681
|
+
let orderByOrig = typeof config.orderBy === "function" ? config.orderBy(aliasedColumns, V1.getOrderByOperators()) : config.orderBy ?? [];
|
|
678
682
|
if (!Array.isArray(orderByOrig)) {
|
|
679
683
|
orderByOrig = [orderByOrig];
|
|
680
684
|
}
|
|
@@ -691,7 +695,7 @@ class MySqlDialect {
|
|
|
691
695
|
queryConfig: selectedRelationConfigValue,
|
|
692
696
|
relation
|
|
693
697
|
} of selectedRelations) {
|
|
694
|
-
const normalizedRelation = normalizeRelation(schema, tableNamesMap, relation);
|
|
698
|
+
const normalizedRelation = V1.normalizeRelation(schema, tableNamesMap, relation);
|
|
695
699
|
const relationTableName = getTableUniqueName(relation.referencedTable);
|
|
696
700
|
const relationTableTsName = tableNamesMap[relationTableName];
|
|
697
701
|
const relationTableAlias = `${tableAlias}_${selectedRelationTsKey}`;
|
|
@@ -703,19 +707,19 @@ class MySqlDialect {
|
|
|
703
707
|
)
|
|
704
708
|
)
|
|
705
709
|
);
|
|
706
|
-
const builtRelation = this.
|
|
710
|
+
const builtRelation = this._buildRelationalQueryWithoutLateralSubqueries({
|
|
707
711
|
fullSchema,
|
|
708
712
|
schema,
|
|
709
713
|
tableNamesMap,
|
|
710
714
|
table: fullSchema[relationTableTsName],
|
|
711
715
|
tableConfig: schema[relationTableTsName],
|
|
712
|
-
queryConfig: is(relation, One) ? selectedRelationConfigValue === true ? { limit: 1 } : { ...selectedRelationConfigValue, limit: 1 } : selectedRelationConfigValue,
|
|
716
|
+
queryConfig: is(relation, V1.One) ? selectedRelationConfigValue === true ? { limit: 1 } : { ...selectedRelationConfigValue, limit: 1 } : selectedRelationConfigValue,
|
|
713
717
|
tableAlias: relationTableAlias,
|
|
714
718
|
joinOn: joinOn2,
|
|
715
719
|
nestedQueryRelation: relation
|
|
716
720
|
});
|
|
717
721
|
let fieldSql = sql`(${builtRelation.sql})`;
|
|
718
|
-
if (is(relation, Many)) {
|
|
722
|
+
if (is(relation, V1.Many)) {
|
|
719
723
|
fieldSql = sql`coalesce(${fieldSql}, json_array())`;
|
|
720
724
|
}
|
|
721
725
|
const field = fieldSql.as(selectedRelationTsKey);
|
|
@@ -743,7 +747,7 @@ class MySqlDialect {
|
|
|
743
747
|
),
|
|
744
748
|
sql`, `
|
|
745
749
|
)})`;
|
|
746
|
-
if (is(nestedQueryRelation, Many)) {
|
|
750
|
+
if (is(nestedQueryRelation, V1.Many)) {
|
|
747
751
|
field = sql`json_arrayagg(${field})`;
|
|
748
752
|
}
|
|
749
753
|
const nestedSelection = [{
|
|
@@ -815,6 +819,148 @@ class MySqlDialect {
|
|
|
815
819
|
selection
|
|
816
820
|
};
|
|
817
821
|
}
|
|
822
|
+
unwrapAllColumns = (table, selection) => {
|
|
823
|
+
return sql.join(
|
|
824
|
+
Object.entries(table[Columns]).map(([k, v]) => {
|
|
825
|
+
selection.push({
|
|
826
|
+
key: k,
|
|
827
|
+
field: v
|
|
828
|
+
});
|
|
829
|
+
return sql`${v} as ${sql.identifier(k)}`;
|
|
830
|
+
}),
|
|
831
|
+
sql`, `
|
|
832
|
+
);
|
|
833
|
+
};
|
|
834
|
+
getSelectedTableColumns = (table, columns) => {
|
|
835
|
+
const selectedColumns = [];
|
|
836
|
+
if (!columns) {
|
|
837
|
+
for (const [k, v] of Object.entries(table[Columns])) {
|
|
838
|
+
selectedColumns.push({
|
|
839
|
+
column: v,
|
|
840
|
+
tsName: k
|
|
841
|
+
});
|
|
842
|
+
}
|
|
843
|
+
return selectedColumns;
|
|
844
|
+
}
|
|
845
|
+
const entries = Object.entries(columns);
|
|
846
|
+
let colSelectionMode;
|
|
847
|
+
for (const [k, v] of entries) {
|
|
848
|
+
if (colSelectionMode === void 0)
|
|
849
|
+
colSelectionMode = v;
|
|
850
|
+
else if (v !== void 0 && colSelectionMode !== v) {
|
|
851
|
+
throw new Error("Columns cannot be both true and false at the same time");
|
|
852
|
+
}
|
|
853
|
+
if (v) {
|
|
854
|
+
selectedColumns.push({
|
|
855
|
+
column: table[Columns][k],
|
|
856
|
+
tsName: k
|
|
857
|
+
});
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
if (colSelectionMode === false) {
|
|
861
|
+
for (const [k, v] of Object.entries(table[Columns])) {
|
|
862
|
+
if (columns[k] === false)
|
|
863
|
+
continue;
|
|
864
|
+
selectedColumns.push({
|
|
865
|
+
column: v,
|
|
866
|
+
tsName: k
|
|
867
|
+
});
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
return selectedColumns;
|
|
871
|
+
};
|
|
872
|
+
buildColumns = (table, selection, params) => params?.columns ? (() => {
|
|
873
|
+
const columnIdentifiers = [];
|
|
874
|
+
const selectedColumns = this.getSelectedTableColumns(table, params?.columns);
|
|
875
|
+
for (const column of selectedColumns) {
|
|
876
|
+
columnIdentifiers.push(
|
|
877
|
+
sql`${table[column.tsName]} as ${sql.identifier(column.tsName)}`
|
|
878
|
+
);
|
|
879
|
+
}
|
|
880
|
+
return columnIdentifiers.length ? sql.join(columnIdentifiers, sql`, `) : this.unwrapAllColumns(table, selection);
|
|
881
|
+
})() : (() => {
|
|
882
|
+
const columnIdentifiers = [this.unwrapAllColumns(table, selection)];
|
|
883
|
+
return sql.join(columnIdentifiers, sql`, `);
|
|
884
|
+
})();
|
|
885
|
+
buildRelationalQuery({
|
|
886
|
+
tables,
|
|
887
|
+
schema,
|
|
888
|
+
tableNamesMap,
|
|
889
|
+
table,
|
|
890
|
+
tableConfig,
|
|
891
|
+
queryConfig: config,
|
|
892
|
+
relationWhere,
|
|
893
|
+
mode
|
|
894
|
+
}) {
|
|
895
|
+
const selection = [];
|
|
896
|
+
const isSingle = mode === "first";
|
|
897
|
+
const params = config === true ? void 0 : config;
|
|
898
|
+
const limit = isSingle ? 1 : params?.limit;
|
|
899
|
+
const offset = params?.offset;
|
|
900
|
+
const columns = this.buildColumns(table, selection, params);
|
|
901
|
+
const where = params?.where && relationWhere ? and(relationFilterToSQL(table, params.where), relationWhere) : params?.where ? relationFilterToSQL(table, params.where) : relationWhere;
|
|
902
|
+
const order = params?.orderBy ? relationsOrderToSQL(table, params.orderBy) : void 0;
|
|
903
|
+
const extras = params?.extras ? relationExtrasToSQL(table, params.extras) : void 0;
|
|
904
|
+
if (extras)
|
|
905
|
+
selection.push(...extras.selection);
|
|
906
|
+
const selectionArr = [columns];
|
|
907
|
+
const joins = params ? (() => {
|
|
908
|
+
const { with: joins2 } = params;
|
|
909
|
+
if (!joins2)
|
|
910
|
+
return;
|
|
911
|
+
const withEntries = Object.entries(joins2).filter(([_, v]) => v);
|
|
912
|
+
if (!withEntries.length)
|
|
913
|
+
return;
|
|
914
|
+
return sql.join(
|
|
915
|
+
withEntries.map(([k, join]) => {
|
|
916
|
+
selectionArr.push(sql`${sql.identifier(k)}.${sql.identifier("r")} as ${sql.identifier(k)}`);
|
|
917
|
+
if (is(tableConfig.relations[k], AggregatedField)) {
|
|
918
|
+
const relation2 = tableConfig.relations[k];
|
|
919
|
+
relation2.onTable(table);
|
|
920
|
+
const query2 = relation2.getSQL();
|
|
921
|
+
selection.push({
|
|
922
|
+
key: k,
|
|
923
|
+
field: relation2
|
|
924
|
+
});
|
|
925
|
+
return sql`, lateral(${query2}) as ${sql.identifier(k)}`;
|
|
926
|
+
}
|
|
927
|
+
const relation = tableConfig.relations[k];
|
|
928
|
+
const isSingle2 = is(relation, One);
|
|
929
|
+
const targetTable = relation.targetTable;
|
|
930
|
+
const relationFilter = relationToSQL(relation);
|
|
931
|
+
const innerQuery = this.buildRelationalQuery({
|
|
932
|
+
table: targetTable,
|
|
933
|
+
mode: isSingle2 ? "first" : "many",
|
|
934
|
+
schema,
|
|
935
|
+
queryConfig: join,
|
|
936
|
+
tableConfig: schema[tableNamesMap[getTableUniqueName(targetTable)]],
|
|
937
|
+
tableNamesMap,
|
|
938
|
+
tables,
|
|
939
|
+
relationWhere: relationFilter
|
|
940
|
+
});
|
|
941
|
+
selection.push({
|
|
942
|
+
field: targetTable,
|
|
943
|
+
key: k,
|
|
944
|
+
selection: innerQuery.selection,
|
|
945
|
+
isArray: !isSingle2
|
|
946
|
+
});
|
|
947
|
+
const jsonColumns = sql.join(
|
|
948
|
+
innerQuery.selection.map((s) => sql`${sql.raw(this.escapeString(s.key))}, ${sql.identifier(s.key)}`),
|
|
949
|
+
sql`, `
|
|
950
|
+
);
|
|
951
|
+
return sql`, lateral(select ${isSingle2 ? sql`json_object(${jsonColumns}) as ${sql.identifier("r")}` : sql`coalesce(json_arrayagg(json_object(${jsonColumns})), json_array()) as ${sql.identifier("r")}`} from (${innerQuery.sql}) as ${sql.identifier("t")}) as ${sql.identifier(k)}`;
|
|
952
|
+
})
|
|
953
|
+
);
|
|
954
|
+
})() : void 0;
|
|
955
|
+
if (extras?.sql)
|
|
956
|
+
selectionArr.push(extras.sql);
|
|
957
|
+
const selectionSet = sql.join(selectionArr, sql`, `);
|
|
958
|
+
const query = sql`select ${selectionSet} from ${table}${sql`${joins}`.if(joins)}${sql` where ${where}`.if(where)}${sql` order by ${order}`.if(order)}${sql` limit ${limit}`.if(limit !== void 0)}${sql` offset ${offset}`.if(offset !== void 0)}`;
|
|
959
|
+
return {
|
|
960
|
+
sql: query,
|
|
961
|
+
selection
|
|
962
|
+
};
|
|
963
|
+
}
|
|
818
964
|
}
|
|
819
965
|
export {
|
|
820
966
|
MySqlDialect
|