drizzle-orm 0.38.3-7db411e → 0.38.3-8e428d1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/alias.cjs.map +1 -1
- package/alias.d.cts +3 -3
- package/alias.d.ts +3 -3
- package/alias.js.map +1 -1
- package/aws-data-api/pg/driver.cjs +5 -19
- package/aws-data-api/pg/driver.cjs.map +1 -1
- package/aws-data-api/pg/driver.d.cts +8 -9
- package/aws-data-api/pg/driver.d.ts +8 -9
- package/aws-data-api/pg/driver.js +8 -9
- package/aws-data-api/pg/driver.js.map +1 -1
- package/aws-data-api/pg/migrator.cjs.map +1 -1
- package/aws-data-api/pg/migrator.d.cts +1 -2
- package/aws-data-api/pg/migrator.d.ts +1 -2
- package/aws-data-api/pg/migrator.js.map +1 -1
- package/aws-data-api/pg/session.cjs +4 -67
- package/aws-data-api/pg/session.cjs.map +1 -1
- package/aws-data-api/pg/session.d.cts +8 -13
- package/aws-data-api/pg/session.d.ts +8 -13
- package/aws-data-api/pg/session.js +4 -67
- package/aws-data-api/pg/session.js.map +1 -1
- package/better-sqlite3/driver.cjs +5 -12
- package/better-sqlite3/driver.cjs.map +1 -1
- package/better-sqlite3/driver.d.cts +6 -7
- package/better-sqlite3/driver.d.ts +6 -7
- package/better-sqlite3/driver.js +8 -12
- package/better-sqlite3/driver.js.map +1 -1
- package/better-sqlite3/migrator.cjs.map +1 -1
- package/better-sqlite3/migrator.d.cts +1 -2
- package/better-sqlite3/migrator.d.ts +1 -2
- package/better-sqlite3/migrator.js.map +1 -1
- package/better-sqlite3/session.cjs +4 -49
- package/better-sqlite3/session.cjs.map +1 -1
- package/better-sqlite3/session.d.cts +8 -14
- package/better-sqlite3/session.d.ts +8 -14
- package/better-sqlite3/session.js +4 -49
- package/better-sqlite3/session.js.map +1 -1
- package/bun-sqlite/driver.cjs +5 -22
- package/bun-sqlite/driver.cjs.map +1 -1
- package/bun-sqlite/driver.d.cts +6 -7
- package/bun-sqlite/driver.d.ts +6 -7
- package/bun-sqlite/driver.js +8 -12
- package/bun-sqlite/driver.js.map +1 -1
- package/bun-sqlite/migrator.cjs.map +1 -1
- package/bun-sqlite/migrator.d.cts +1 -2
- package/bun-sqlite/migrator.d.ts +1 -2
- package/bun-sqlite/migrator.js.map +1 -1
- package/bun-sqlite/session.cjs +4 -49
- package/bun-sqlite/session.cjs.map +1 -1
- package/bun-sqlite/session.d.cts +8 -14
- package/bun-sqlite/session.d.ts +8 -14
- package/bun-sqlite/session.js +4 -49
- package/bun-sqlite/session.js.map +1 -1
- package/d1/driver.cjs +5 -22
- package/d1/driver.cjs.map +1 -1
- package/d1/driver.d.cts +2 -3
- package/d1/driver.d.ts +2 -3
- package/d1/driver.js +8 -12
- package/d1/driver.js.map +1 -1
- package/d1/migrator.cjs.map +1 -1
- package/d1/migrator.d.cts +1 -2
- package/d1/migrator.d.ts +1 -2
- package/d1/migrator.js.map +1 -1
- package/d1/session.cjs +6 -48
- package/d1/session.cjs.map +1 -1
- package/d1/session.d.cts +8 -15
- package/d1/session.d.ts +8 -15
- package/d1/session.js +6 -48
- package/d1/session.js.map +1 -1
- package/durable-sqlite/driver.cjs +5 -16
- package/durable-sqlite/driver.cjs.map +1 -1
- package/durable-sqlite/driver.d.cts +2 -3
- package/durable-sqlite/driver.d.ts +2 -3
- package/durable-sqlite/driver.js +8 -6
- package/durable-sqlite/driver.js.map +1 -1
- package/durable-sqlite/migrator.cjs.map +1 -1
- package/durable-sqlite/migrator.d.cts +1 -2
- package/durable-sqlite/migrator.d.ts +1 -2
- package/durable-sqlite/migrator.js.map +1 -1
- package/durable-sqlite/session.cjs +4 -46
- package/durable-sqlite/session.cjs.map +1 -1
- package/durable-sqlite/session.d.cts +8 -14
- package/durable-sqlite/session.d.ts +8 -14
- package/durable-sqlite/session.js +4 -46
- package/durable-sqlite/session.js.map +1 -1
- package/expo-sqlite/driver.cjs +5 -22
- package/expo-sqlite/driver.cjs.map +1 -1
- package/expo-sqlite/driver.d.cts +2 -3
- package/expo-sqlite/driver.d.ts +2 -3
- package/expo-sqlite/driver.js +8 -12
- package/expo-sqlite/driver.js.map +1 -1
- package/expo-sqlite/migrator.cjs.map +1 -1
- package/expo-sqlite/migrator.d.cts +2 -3
- package/expo-sqlite/migrator.d.ts +2 -3
- package/expo-sqlite/migrator.js.map +1 -1
- package/expo-sqlite/query.cjs +2 -13
- package/expo-sqlite/query.cjs.map +1 -1
- package/expo-sqlite/query.d.cts +1 -2
- package/expo-sqlite/query.d.ts +1 -2
- package/expo-sqlite/query.js +2 -3
- package/expo-sqlite/query.js.map +1 -1
- package/expo-sqlite/session.cjs +4 -47
- package/expo-sqlite/session.cjs.map +1 -1
- package/expo-sqlite/session.d.cts +8 -14
- package/expo-sqlite/session.d.ts +8 -14
- package/expo-sqlite/session.js +4 -47
- package/expo-sqlite/session.js.map +1 -1
- package/libsql/driver-core.cjs +5 -22
- package/libsql/driver-core.cjs.map +1 -1
- package/libsql/driver-core.d.cts +1 -2
- package/libsql/driver-core.d.ts +1 -2
- package/libsql/driver-core.js +8 -12
- package/libsql/driver-core.js.map +1 -1
- package/libsql/driver.cjs.map +1 -1
- package/libsql/driver.d.cts +5 -6
- package/libsql/driver.d.ts +5 -6
- package/libsql/driver.js.map +1 -1
- package/libsql/http/index.cjs.map +1 -1
- package/libsql/http/index.d.cts +5 -6
- package/libsql/http/index.d.ts +5 -6
- package/libsql/http/index.js.map +1 -1
- package/libsql/migrator.cjs.map +1 -1
- package/libsql/migrator.d.cts +1 -2
- package/libsql/migrator.d.ts +1 -2
- package/libsql/migrator.js.map +1 -1
- package/libsql/node/index.cjs.map +1 -1
- package/libsql/node/index.d.cts +5 -6
- package/libsql/node/index.d.ts +5 -6
- package/libsql/node/index.js.map +1 -1
- package/libsql/session.cjs +4 -60
- package/libsql/session.cjs.map +1 -1
- package/libsql/session.d.cts +9 -15
- package/libsql/session.d.ts +9 -15
- package/libsql/session.js +4 -60
- package/libsql/session.js.map +1 -1
- package/libsql/sqlite3/index.cjs.map +1 -1
- package/libsql/sqlite3/index.d.cts +5 -6
- package/libsql/sqlite3/index.d.ts +5 -6
- package/libsql/sqlite3/index.js.map +1 -1
- package/libsql/wasm/index.cjs.map +1 -1
- package/libsql/wasm/index.d.cts +5 -6
- package/libsql/wasm/index.d.ts +5 -6
- package/libsql/wasm/index.js.map +1 -1
- package/libsql/web/index.cjs.map +1 -1
- package/libsql/web/index.d.cts +5 -6
- package/libsql/web/index.d.ts +5 -6
- package/libsql/web/index.js.map +1 -1
- package/libsql/ws/index.cjs.map +1 -1
- package/libsql/ws/index.d.cts +5 -6
- package/libsql/ws/index.d.ts +5 -6
- package/libsql/ws/index.js.map +1 -1
- package/mysql-core/db.cjs +8 -29
- package/mysql-core/db.cjs.map +1 -1
- package/mysql-core/db.d.cts +8 -15
- package/mysql-core/db.d.ts +8 -15
- package/mysql-core/db.js +7 -28
- package/mysql-core/db.js.map +1 -1
- package/mysql-core/dialect.cjs +15 -176
- package/mysql-core/dialect.cjs.map +1 -1
- package/mysql-core/dialect.d.cts +13 -31
- package/mysql-core/dialect.d.ts +13 -31
- package/mysql-core/dialect.js +21 -173
- package/mysql-core/dialect.js.map +1 -1
- package/mysql-core/query-builders/count.cjs.map +1 -1
- package/mysql-core/query-builders/count.d.cts +1 -1
- package/mysql-core/query-builders/count.d.ts +1 -1
- package/mysql-core/query-builders/count.js.map +1 -1
- package/mysql-core/query-builders/query.cjs +31 -18
- package/mysql-core/query-builders/query.cjs.map +1 -1
- package/mysql-core/query-builders/query.d.cts +10 -8
- package/mysql-core/query-builders/query.d.ts +10 -8
- package/mysql-core/query-builders/query.js +31 -18
- package/mysql-core/query-builders/query.js.map +1 -1
- package/mysql-core/session.cjs +2 -3
- package/mysql-core/session.cjs.map +1 -1
- package/mysql-core/session.d.cts +7 -10
- package/mysql-core/session.d.ts +7 -10
- package/mysql-core/session.js +2 -3
- package/mysql-core/session.js.map +1 -1
- package/mysql-proxy/driver.cjs +5 -22
- package/mysql-proxy/driver.cjs.map +1 -1
- package/mysql-proxy/driver.d.cts +2 -3
- package/mysql-proxy/driver.d.ts +2 -3
- package/mysql-proxy/driver.js +8 -12
- package/mysql-proxy/driver.js.map +1 -1
- package/mysql-proxy/migrator.cjs.map +1 -1
- package/mysql-proxy/migrator.d.cts +1 -2
- package/mysql-proxy/migrator.d.ts +1 -2
- package/mysql-proxy/migrator.js.map +1 -1
- package/mysql-proxy/session.cjs +2 -47
- package/mysql-proxy/session.cjs.map +1 -1
- package/mysql-proxy/session.d.cts +8 -13
- package/mysql-proxy/session.d.ts +8 -13
- package/mysql-proxy/session.js +2 -47
- package/mysql-proxy/session.js.map +1 -1
- package/mysql2/driver.cjs +7 -24
- package/mysql2/driver.cjs.map +1 -1
- package/mysql2/driver.d.cts +9 -10
- package/mysql2/driver.d.ts +9 -10
- package/mysql2/driver.js +10 -14
- package/mysql2/driver.js.map +1 -1
- package/mysql2/migrator.cjs.map +1 -1
- package/mysql2/migrator.d.cts +1 -2
- package/mysql2/migrator.d.ts +1 -2
- package/mysql2/migrator.js.map +1 -1
- package/mysql2/session.cjs +2 -51
- package/mysql2/session.cjs.map +1 -1
- package/mysql2/session.d.cts +8 -13
- package/mysql2/session.d.ts +8 -13
- package/mysql2/session.js +2 -51
- package/mysql2/session.js.map +1 -1
- package/neon-http/driver.cjs +7 -21
- package/neon-http/driver.cjs.map +1 -1
- package/neon-http/driver.d.cts +9 -10
- package/neon-http/driver.d.ts +9 -10
- package/neon-http/driver.js +7 -11
- package/neon-http/driver.js.map +1 -1
- package/neon-http/migrator.cjs.map +1 -1
- package/neon-http/migrator.d.cts +1 -2
- package/neon-http/migrator.d.ts +1 -2
- package/neon-http/migrator.js.map +1 -1
- package/neon-http/session.cjs +2 -32
- package/neon-http/session.cjs.map +1 -1
- package/neon-http/session.d.cts +8 -13
- package/neon-http/session.d.ts +8 -13
- package/neon-http/session.js +2 -32
- package/neon-http/session.js.map +1 -1
- package/neon-serverless/driver.cjs +7 -18
- package/neon-serverless/driver.cjs.map +1 -1
- package/neon-serverless/driver.d.cts +8 -9
- package/neon-serverless/driver.d.ts +8 -9
- package/neon-serverless/driver.js +10 -8
- package/neon-serverless/driver.js.map +1 -1
- package/neon-serverless/migrator.cjs.map +1 -1
- package/neon-serverless/migrator.d.cts +1 -2
- package/neon-serverless/migrator.d.ts +1 -2
- package/neon-serverless/migrator.js.map +1 -1
- package/neon-serverless/session.cjs +5 -40
- package/neon-serverless/session.cjs.map +1 -1
- package/neon-serverless/session.d.cts +8 -13
- package/neon-serverless/session.d.ts +8 -13
- package/neon-serverless/session.js +5 -40
- package/neon-serverless/session.js.map +1 -1
- package/node-postgres/driver.cjs +7 -13
- package/node-postgres/driver.cjs.map +1 -1
- package/node-postgres/driver.d.cts +8 -9
- package/node-postgres/driver.d.ts +8 -9
- package/node-postgres/driver.js +10 -13
- package/node-postgres/driver.js.map +1 -1
- package/node-postgres/migrator.cjs.map +1 -1
- package/node-postgres/migrator.d.cts +1 -2
- package/node-postgres/migrator.d.ts +1 -2
- package/node-postgres/migrator.js.map +1 -1
- package/node-postgres/session.cjs +4 -45
- package/node-postgres/session.cjs.map +1 -1
- package/node-postgres/session.d.cts +8 -13
- package/node-postgres/session.d.ts +8 -13
- package/node-postgres/session.js +4 -45
- package/node-postgres/session.js.map +1 -1
- package/op-sqlite/driver.cjs +5 -22
- package/op-sqlite/driver.cjs.map +1 -1
- package/op-sqlite/driver.d.cts +2 -3
- package/op-sqlite/driver.d.ts +2 -3
- package/op-sqlite/driver.js +8 -12
- package/op-sqlite/driver.js.map +1 -1
- package/op-sqlite/migrator.cjs.map +1 -1
- package/op-sqlite/migrator.d.cts +2 -3
- package/op-sqlite/migrator.d.ts +2 -3
- package/op-sqlite/migrator.js.map +1 -1
- package/op-sqlite/session.cjs +4 -47
- package/op-sqlite/session.cjs.map +1 -1
- package/op-sqlite/session.d.cts +8 -14
- package/op-sqlite/session.d.ts +8 -14
- package/op-sqlite/session.js +4 -47
- package/op-sqlite/session.js.map +1 -1
- package/package.json +63 -99
- package/pg-core/db.cjs +7 -31
- package/pg-core/db.cjs.map +1 -1
- package/pg-core/db.d.cts +9 -16
- package/pg-core/db.d.ts +9 -16
- package/pg-core/db.js +6 -30
- package/pg-core/db.js.map +1 -1
- package/pg-core/dialect.cjs +488 -152
- package/pg-core/dialect.cjs.map +1 -1
- package/pg-core/dialect.d.cts +7 -23
- package/pg-core/dialect.d.ts +7 -23
- package/pg-core/dialect.js +494 -149
- package/pg-core/dialect.js.map +1 -1
- package/pg-core/query-builders/count.cjs.map +1 -1
- package/pg-core/query-builders/count.d.cts +1 -1
- package/pg-core/query-builders/count.d.ts +1 -1
- package/pg-core/query-builders/count.js.map +1 -1
- package/pg-core/query-builders/query.cjs +18 -15
- package/pg-core/query-builders/query.cjs.map +1 -1
- package/pg-core/query-builders/query.d.cts +6 -6
- package/pg-core/query-builders/query.d.ts +6 -6
- package/pg-core/query-builders/query.js +18 -15
- package/pg-core/query-builders/query.js.map +1 -1
- package/pg-core/session.cjs +2 -3
- package/pg-core/session.cjs.map +1 -1
- package/pg-core/session.d.cts +6 -9
- package/pg-core/session.d.ts +6 -9
- package/pg-core/session.js +2 -3
- package/pg-core/session.js.map +1 -1
- package/pg-proxy/driver.cjs +5 -21
- package/pg-proxy/driver.cjs.map +1 -1
- package/pg-proxy/driver.d.cts +2 -3
- package/pg-proxy/driver.d.ts +2 -3
- package/pg-proxy/driver.js +8 -11
- package/pg-proxy/driver.js.map +1 -1
- package/pg-proxy/migrator.cjs.map +1 -1
- package/pg-proxy/migrator.d.cts +1 -2
- package/pg-proxy/migrator.d.ts +1 -2
- package/pg-proxy/migrator.js.map +1 -1
- package/pg-proxy/session.cjs +2 -37
- package/pg-proxy/session.cjs.map +1 -1
- package/pg-proxy/session.d.cts +8 -13
- package/pg-proxy/session.d.ts +8 -13
- package/pg-proxy/session.js +2 -37
- package/pg-proxy/session.js.map +1 -1
- package/pglite/driver.cjs +7 -23
- package/pglite/driver.cjs.map +1 -1
- package/pglite/driver.d.cts +8 -9
- package/pglite/driver.d.ts +8 -9
- package/pglite/driver.js +10 -13
- package/pglite/driver.js.map +1 -1
- package/pglite/migrator.cjs.map +1 -1
- package/pglite/migrator.d.cts +1 -2
- package/pglite/migrator.d.ts +1 -2
- package/pglite/migrator.js.map +1 -1
- package/pglite/session.cjs +3 -34
- package/pglite/session.cjs.map +1 -1
- package/pglite/session.d.cts +8 -13
- package/pglite/session.d.ts +8 -13
- package/pglite/session.js +3 -34
- package/pglite/session.js.map +1 -1
- package/planetscale-serverless/driver.cjs +5 -22
- package/planetscale-serverless/driver.cjs.map +1 -1
- package/planetscale-serverless/driver.d.cts +6 -7
- package/planetscale-serverless/driver.d.ts +6 -7
- package/planetscale-serverless/driver.js +8 -12
- package/planetscale-serverless/driver.js.map +1 -1
- package/planetscale-serverless/migrator.cjs.map +1 -1
- package/planetscale-serverless/migrator.d.cts +1 -2
- package/planetscale-serverless/migrator.d.ts +1 -2
- package/planetscale-serverless/migrator.js.map +1 -1
- package/planetscale-serverless/session.cjs +5 -68
- package/planetscale-serverless/session.cjs.map +1 -1
- package/planetscale-serverless/session.d.cts +9 -14
- package/planetscale-serverless/session.d.ts +9 -14
- package/planetscale-serverless/session.js +5 -68
- package/planetscale-serverless/session.js.map +1 -1
- package/postgres-js/driver.cjs +5 -6
- package/postgres-js/driver.cjs.map +1 -1
- package/postgres-js/driver.d.cts +6 -7
- package/postgres-js/driver.d.ts +6 -7
- package/postgres-js/driver.js +8 -6
- package/postgres-js/driver.js.map +1 -1
- package/postgres-js/migrator.cjs.map +1 -1
- package/postgres-js/migrator.d.cts +1 -2
- package/postgres-js/migrator.d.ts +1 -2
- package/postgres-js/migrator.js.map +1 -1
- package/postgres-js/session.cjs +6 -51
- package/postgres-js/session.cjs.map +1 -1
- package/postgres-js/session.d.cts +9 -15
- package/postgres-js/session.d.ts +9 -15
- package/postgres-js/session.js +6 -51
- package/postgres-js/session.js.map +1 -1
- package/prisma/mysql/driver.cjs +1 -1
- package/prisma/mysql/driver.cjs.map +1 -1
- package/prisma/mysql/driver.js +1 -1
- package/prisma/mysql/driver.js.map +1 -1
- package/prisma/mysql/session.cjs +0 -3
- package/prisma/mysql/session.cjs.map +1 -1
- package/prisma/mysql/session.d.cts +1 -3
- package/prisma/mysql/session.d.ts +1 -3
- package/prisma/mysql/session.js +0 -3
- package/prisma/mysql/session.js.map +1 -1
- package/prisma/pg/driver.cjs +1 -1
- package/prisma/pg/driver.cjs.map +1 -1
- package/prisma/pg/driver.js +1 -1
- package/prisma/pg/driver.js.map +1 -1
- package/prisma/pg/session.cjs +0 -3
- package/prisma/pg/session.cjs.map +1 -1
- package/prisma/pg/session.d.cts +1 -3
- package/prisma/pg/session.d.ts +1 -3
- package/prisma/pg/session.js +0 -3
- package/prisma/pg/session.js.map +1 -1
- package/prisma/sqlite/driver.cjs +1 -1
- package/prisma/sqlite/driver.cjs.map +1 -1
- package/prisma/sqlite/driver.js +1 -1
- package/prisma/sqlite/driver.js.map +1 -1
- package/prisma/sqlite/session.cjs +0 -3
- package/prisma/sqlite/session.cjs.map +1 -1
- package/prisma/sqlite/session.d.cts +2 -4
- package/prisma/sqlite/session.d.ts +2 -4
- package/prisma/sqlite/session.js +0 -3
- package/prisma/sqlite/session.js.map +1 -1
- package/relations.cjs +246 -477
- package/relations.cjs.map +1 -1
- package/relations.d.cts +131 -263
- package/relations.d.ts +131 -263
- package/relations.js +241 -466
- package/relations.js.map +1 -1
- package/singlestore/driver.cjs +1 -1
- package/singlestore/driver.cjs.map +1 -1
- package/singlestore/driver.d.cts +1 -1
- package/singlestore/driver.d.ts +1 -1
- package/singlestore/driver.js +3 -3
- package/singlestore/driver.js.map +1 -1
- package/singlestore/session.cjs.map +1 -1
- package/singlestore/session.d.cts +4 -4
- package/singlestore/session.d.ts +4 -4
- package/singlestore/session.js.map +1 -1
- package/singlestore-core/columns/all.cjs +2 -0
- package/singlestore-core/columns/all.cjs.map +1 -1
- package/singlestore-core/columns/all.d.cts +2 -0
- package/singlestore-core/columns/all.d.ts +2 -0
- package/singlestore-core/columns/all.js +2 -0
- package/singlestore-core/columns/all.js.map +1 -1
- package/singlestore-core/columns/index.cjs +2 -0
- package/singlestore-core/columns/index.cjs.map +1 -1
- package/singlestore-core/columns/index.d.cts +1 -0
- package/singlestore-core/columns/index.d.ts +1 -0
- package/singlestore-core/columns/index.js +1 -0
- package/singlestore-core/columns/index.js.map +1 -1
- package/singlestore-core/columns/vector.cjs +72 -0
- package/singlestore-core/columns/vector.cjs.map +1 -0
- package/singlestore-core/columns/vector.d.cts +32 -0
- package/singlestore-core/columns/vector.d.ts +32 -0
- package/singlestore-core/columns/vector.js +46 -0
- package/singlestore-core/columns/vector.js.map +1 -0
- package/singlestore-core/db.cjs.map +1 -1
- package/singlestore-core/db.d.cts +3 -3
- package/singlestore-core/db.d.ts +3 -3
- package/singlestore-core/db.js.map +1 -1
- package/singlestore-core/dialect.cjs +6 -16
- package/singlestore-core/dialect.cjs.map +1 -1
- package/singlestore-core/dialect.d.cts +6 -6
- package/singlestore-core/dialect.d.ts +6 -6
- package/singlestore-core/dialect.js +12 -6
- package/singlestore-core/dialect.js.map +1 -1
- package/singlestore-core/expressions.cjs +10 -0
- package/singlestore-core/expressions.cjs.map +1 -1
- package/singlestore-core/expressions.d.cts +2 -0
- package/singlestore-core/expressions.d.ts +2 -0
- package/singlestore-core/expressions.js +8 -0
- package/singlestore-core/expressions.js.map +1 -1
- package/singlestore-core/query-builders/query.cjs +2 -12
- package/singlestore-core/query-builders/query.cjs.map +1 -1
- package/singlestore-core/query-builders/query.d.cts +6 -6
- package/singlestore-core/query-builders/query.d.ts +6 -6
- package/singlestore-core/query-builders/query.js +4 -2
- package/singlestore-core/query-builders/query.js.map +1 -1
- package/singlestore-core/session.cjs.map +1 -1
- package/singlestore-core/session.d.cts +5 -5
- package/singlestore-core/session.d.ts +5 -5
- package/singlestore-core/session.js.map +1 -1
- package/singlestore-proxy/driver.cjs +1 -1
- package/singlestore-proxy/driver.cjs.map +1 -1
- package/singlestore-proxy/driver.js +3 -3
- package/singlestore-proxy/driver.js.map +1 -1
- package/singlestore-proxy/session.cjs.map +1 -1
- package/singlestore-proxy/session.d.cts +4 -4
- package/singlestore-proxy/session.d.ts +4 -4
- package/singlestore-proxy/session.js.map +1 -1
- package/sql/sql.cjs.map +1 -1
- package/sql/sql.d.cts +8 -8
- package/sql/sql.d.ts +8 -8
- package/sql/sql.js.map +1 -1
- package/sql-js/driver.cjs +5 -16
- package/sql-js/driver.cjs.map +1 -1
- package/sql-js/driver.d.cts +2 -3
- package/sql-js/driver.d.ts +2 -3
- package/sql-js/driver.js +8 -6
- package/sql-js/driver.js.map +1 -1
- package/sql-js/migrator.cjs.map +1 -1
- package/sql-js/migrator.d.cts +1 -2
- package/sql-js/migrator.d.ts +1 -2
- package/sql-js/migrator.js.map +1 -1
- package/sql-js/session.cjs +4 -58
- package/sql-js/session.cjs.map +1 -1
- package/sql-js/session.d.cts +8 -14
- package/sql-js/session.d.ts +8 -14
- package/sql-js/session.js +4 -58
- package/sql-js/session.js.map +1 -1
- package/sqlite-core/db.cjs +14 -36
- package/sqlite-core/db.cjs.map +1 -1
- package/sqlite-core/db.d.cts +8 -15
- package/sqlite-core/db.d.ts +8 -15
- package/sqlite-core/db.js +13 -35
- package/sqlite-core/db.js.map +1 -1
- package/sqlite-core/dialect.cjs +7 -171
- package/sqlite-core/dialect.cjs.map +1 -1
- package/sqlite-core/dialect.d.cts +9 -27
- package/sqlite-core/dialect.d.ts +9 -27
- package/sqlite-core/dialect.js +13 -168
- package/sqlite-core/dialect.js.map +1 -1
- package/sqlite-core/query-builders/count.cjs.map +1 -1
- package/sqlite-core/query-builders/count.d.cts +1 -1
- package/sqlite-core/query-builders/count.d.ts +1 -1
- package/sqlite-core/query-builders/count.js.map +1 -1
- package/sqlite-core/query-builders/delete.cjs.map +1 -1
- package/sqlite-core/query-builders/delete.d.cts +1 -1
- package/sqlite-core/query-builders/delete.d.ts +1 -1
- package/sqlite-core/query-builders/delete.js.map +1 -1
- package/sqlite-core/query-builders/insert.cjs.map +1 -1
- package/sqlite-core/query-builders/insert.d.cts +3 -3
- package/sqlite-core/query-builders/insert.d.ts +3 -3
- package/sqlite-core/query-builders/insert.js.map +1 -1
- package/sqlite-core/query-builders/query.cjs +29 -32
- package/sqlite-core/query-builders/query.cjs.map +1 -1
- package/sqlite-core/query-builders/query.d.cts +16 -15
- package/sqlite-core/query-builders/query.d.ts +16 -15
- package/sqlite-core/query-builders/query.js +29 -32
- package/sqlite-core/query-builders/query.js.map +1 -1
- package/sqlite-core/query-builders/select.cjs.map +1 -1
- package/sqlite-core/query-builders/select.d.cts +3 -3
- package/sqlite-core/query-builders/select.d.ts +3 -3
- package/sqlite-core/query-builders/select.js.map +1 -1
- package/sqlite-core/query-builders/update.cjs.map +1 -1
- package/sqlite-core/query-builders/update.d.cts +3 -3
- package/sqlite-core/query-builders/update.d.ts +3 -3
- package/sqlite-core/query-builders/update.js.map +1 -1
- package/sqlite-core/session.cjs +2 -6
- package/sqlite-core/session.cjs.map +1 -1
- package/sqlite-core/session.d.cts +6 -14
- package/sqlite-core/session.d.ts +6 -14
- package/sqlite-core/session.js +2 -6
- package/sqlite-core/session.js.map +1 -1
- package/sqlite-proxy/driver.cjs +5 -22
- package/sqlite-proxy/driver.cjs.map +1 -1
- package/sqlite-proxy/driver.d.cts +3 -4
- package/sqlite-proxy/driver.d.ts +3 -4
- package/sqlite-proxy/driver.js +5 -12
- package/sqlite-proxy/driver.js.map +1 -1
- package/sqlite-proxy/migrator.cjs.map +1 -1
- package/sqlite-proxy/migrator.d.cts +1 -2
- package/sqlite-proxy/migrator.d.ts +1 -2
- package/sqlite-proxy/migrator.js.map +1 -1
- package/sqlite-proxy/session.cjs +4 -47
- package/sqlite-proxy/session.cjs.map +1 -1
- package/sqlite-proxy/session.d.cts +8 -14
- package/sqlite-proxy/session.d.ts +8 -14
- package/sqlite-proxy/session.js +4 -47
- package/sqlite-proxy/session.js.map +1 -1
- package/table.cjs.map +1 -1
- package/table.d.cts +1 -1
- package/table.d.ts +1 -1
- package/table.js.map +1 -1
- package/tidb-serverless/driver.cjs +5 -22
- package/tidb-serverless/driver.cjs.map +1 -1
- package/tidb-serverless/driver.d.cts +6 -7
- package/tidb-serverless/driver.d.ts +6 -7
- package/tidb-serverless/driver.js +8 -12
- package/tidb-serverless/driver.js.map +1 -1
- package/tidb-serverless/migrator.cjs.map +1 -1
- package/tidb-serverless/migrator.d.cts +1 -2
- package/tidb-serverless/migrator.d.ts +1 -2
- package/tidb-serverless/migrator.js.map +1 -1
- package/tidb-serverless/session.cjs +5 -62
- package/tidb-serverless/session.cjs.map +1 -1
- package/tidb-serverless/session.d.cts +9 -14
- package/tidb-serverless/session.d.ts +9 -14
- package/tidb-serverless/session.js +5 -62
- package/tidb-serverless/session.js.map +1 -1
- package/utils.cjs +2 -2
- package/utils.cjs.map +1 -1
- package/utils.d.cts +1 -3
- package/utils.d.ts +1 -3
- package/utils.js +2 -2
- package/utils.js.map +1 -1
- package/vercel-postgres/driver.cjs +7 -23
- package/vercel-postgres/driver.cjs.map +1 -1
- package/vercel-postgres/driver.d.cts +8 -9
- package/vercel-postgres/driver.d.ts +8 -9
- package/vercel-postgres/driver.js +10 -13
- package/vercel-postgres/driver.js.map +1 -1
- package/vercel-postgres/migrator.cjs.map +1 -1
- package/vercel-postgres/migrator.d.cts +1 -2
- package/vercel-postgres/migrator.d.ts +1 -2
- package/vercel-postgres/migrator.js.map +1 -1
- package/vercel-postgres/session.cjs +4 -34
- package/vercel-postgres/session.cjs.map +1 -1
- package/vercel-postgres/session.d.cts +8 -13
- package/vercel-postgres/session.d.ts +8 -13
- package/vercel-postgres/session.js +4 -34
- package/vercel-postgres/session.js.map +1 -1
- package/version.cjs +1 -1
- package/version.d.cts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/xata-http/driver.cjs +5 -17
- package/xata-http/driver.cjs.map +1 -1
- package/xata-http/driver.d.cts +4 -5
- package/xata-http/driver.d.ts +4 -5
- package/xata-http/driver.js +5 -7
- package/xata-http/driver.js.map +1 -1
- package/xata-http/migrator.cjs.map +1 -1
- package/xata-http/migrator.d.cts +1 -2
- package/xata-http/migrator.d.ts +1 -2
- package/xata-http/migrator.js.map +1 -1
- package/xata-http/session.cjs +2 -30
- package/xata-http/session.cjs.map +1 -1
- package/xata-http/session.d.cts +8 -13
- package/xata-http/session.d.ts +8 -13
- package/xata-http/session.js +2 -30
- package/xata-http/session.js.map +1 -1
- package/_relations.cjs +0 -328
- package/_relations.cjs.map +0 -1
- package/_relations.d.cts +0 -215
- package/_relations.d.ts +0 -215
- package/_relations.js +0 -316
- package/_relations.js.map +0 -1
- package/mysql-core/query-builders/_query.cjs +0 -149
- package/mysql-core/query-builders/_query.cjs.map +0 -1
- package/mysql-core/query-builders/_query.d.cts +0 -44
- package/mysql-core/query-builders/_query.d.ts +0 -44
- package/mysql-core/query-builders/_query.js +0 -114
- package/mysql-core/query-builders/_query.js.map +0 -1
- package/pg-core/query-builders/_query.cjs +0 -155
- package/pg-core/query-builders/_query.cjs.map +0 -1
- package/pg-core/query-builders/_query.d.cts +0 -47
- package/pg-core/query-builders/_query.d.ts +0 -47
- package/pg-core/query-builders/_query.js +0 -120
- package/pg-core/query-builders/_query.js.map +0 -1
- package/sqlite-core/query-builders/_query.cjs +0 -187
- package/sqlite-core/query-builders/_query.cjs.map +0 -1
- package/sqlite-core/query-builders/_query.d.cts +0 -55
- package/sqlite-core/query-builders/_query.d.ts +0 -55
- package/sqlite-core/query-builders/_query.js +0 -151
- package/sqlite-core/query-builders/_query.js.map +0 -1
package/pg-core/dialect.cjs
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,21 +15,12 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
var dialect_exports = {};
|
|
30
20
|
__export(dialect_exports, {
|
|
31
21
|
PgDialect: () => PgDialect
|
|
32
22
|
});
|
|
33
23
|
module.exports = __toCommonJS(dialect_exports);
|
|
34
|
-
var V1 = __toESM(require("../_relations.cjs"), 1);
|
|
35
24
|
var import_alias = require("../alias.cjs");
|
|
36
25
|
var import_casing = require("../casing.cjs");
|
|
37
26
|
var import_column = require("../column.cjs");
|
|
@@ -437,8 +426,488 @@ class PgDialect {
|
|
|
437
426
|
invokeSource
|
|
438
427
|
});
|
|
439
428
|
}
|
|
440
|
-
|
|
441
|
-
|
|
429
|
+
// buildRelationalQueryWithPK({
|
|
430
|
+
// fullSchema,
|
|
431
|
+
// schema,
|
|
432
|
+
// tableNamesMap,
|
|
433
|
+
// table,
|
|
434
|
+
// tableConfig,
|
|
435
|
+
// queryConfig: config,
|
|
436
|
+
// tableAlias,
|
|
437
|
+
// isRoot = false,
|
|
438
|
+
// joinOn,
|
|
439
|
+
// }: {
|
|
440
|
+
// fullSchema: Record<string, unknown>;
|
|
441
|
+
// schema: TablesRelationalConfig;
|
|
442
|
+
// tableNamesMap: Record<string, string>;
|
|
443
|
+
// table: PgTable;
|
|
444
|
+
// tableConfig: TableRelationalConfig;
|
|
445
|
+
// queryConfig: true | DBQueryConfig<'many', true>;
|
|
446
|
+
// tableAlias: string;
|
|
447
|
+
// isRoot?: boolean;
|
|
448
|
+
// joinOn?: SQL;
|
|
449
|
+
// }): BuildRelationalQueryResult<PgTable, PgColumn> {
|
|
450
|
+
// // For { "<relation>": true }, return a table with selection of all columns
|
|
451
|
+
// if (config === true) {
|
|
452
|
+
// const selectionEntries = Object.entries(tableConfig.columns);
|
|
453
|
+
// const selection: BuildRelationalQueryResult<PgTable, PgColumn>['selection'] = selectionEntries.map((
|
|
454
|
+
// [key, value],
|
|
455
|
+
// ) => ({
|
|
456
|
+
// dbKey: value.name,
|
|
457
|
+
// tsKey: key,
|
|
458
|
+
// field: value as PgColumn,
|
|
459
|
+
// relationTableTsKey: undefined,
|
|
460
|
+
// isJson: false,
|
|
461
|
+
// selection: [],
|
|
462
|
+
// }));
|
|
463
|
+
// return {
|
|
464
|
+
// tableTsKey: tableConfig.tsName,
|
|
465
|
+
// sql: table,
|
|
466
|
+
// selection,
|
|
467
|
+
// };
|
|
468
|
+
// }
|
|
469
|
+
// // let selection: BuildRelationalQueryResult<PgTable, PgColumn>['selection'] = [];
|
|
470
|
+
// // let selectionForBuild = selection;
|
|
471
|
+
// const aliasedColumns = Object.fromEntries(
|
|
472
|
+
// Object.entries(tableConfig.columns).map(([key, value]) => [key, aliasedTableColumn(value, tableAlias)]),
|
|
473
|
+
// );
|
|
474
|
+
// const aliasedRelations = Object.fromEntries(
|
|
475
|
+
// Object.entries(tableConfig.relations).map(([key, value]) => [key, aliasedRelation(value, tableAlias)]),
|
|
476
|
+
// );
|
|
477
|
+
// const aliasedFields = Object.assign({}, aliasedColumns, aliasedRelations);
|
|
478
|
+
// let where, hasUserDefinedWhere;
|
|
479
|
+
// if (config.where) {
|
|
480
|
+
// const whereSql = typeof config.where === 'function' ? config.where(aliasedFields, operators) : config.where;
|
|
481
|
+
// where = whereSql && mapColumnsInSQLToAlias(whereSql, tableAlias);
|
|
482
|
+
// hasUserDefinedWhere = !!where;
|
|
483
|
+
// }
|
|
484
|
+
// where = and(joinOn, where);
|
|
485
|
+
// // const fieldsSelection: { tsKey: string; value: PgColumn | SQL.Aliased; isExtra?: boolean }[] = [];
|
|
486
|
+
// let joins: Join[] = [];
|
|
487
|
+
// let selectedColumns: string[] = [];
|
|
488
|
+
// // Figure out which columns to select
|
|
489
|
+
// if (config.columns) {
|
|
490
|
+
// let isIncludeMode = false;
|
|
491
|
+
// for (const [field, value] of Object.entries(config.columns)) {
|
|
492
|
+
// if (value === undefined) {
|
|
493
|
+
// continue;
|
|
494
|
+
// }
|
|
495
|
+
// if (field in tableConfig.columns) {
|
|
496
|
+
// if (!isIncludeMode && value === true) {
|
|
497
|
+
// isIncludeMode = true;
|
|
498
|
+
// }
|
|
499
|
+
// selectedColumns.push(field);
|
|
500
|
+
// }
|
|
501
|
+
// }
|
|
502
|
+
// if (selectedColumns.length > 0) {
|
|
503
|
+
// selectedColumns = isIncludeMode
|
|
504
|
+
// ? selectedColumns.filter((c) => config.columns?.[c] === true)
|
|
505
|
+
// : Object.keys(tableConfig.columns).filter((key) => !selectedColumns.includes(key));
|
|
506
|
+
// }
|
|
507
|
+
// } else {
|
|
508
|
+
// // Select all columns if selection is not specified
|
|
509
|
+
// selectedColumns = Object.keys(tableConfig.columns);
|
|
510
|
+
// }
|
|
511
|
+
// // for (const field of selectedColumns) {
|
|
512
|
+
// // const column = tableConfig.columns[field]! as PgColumn;
|
|
513
|
+
// // fieldsSelection.push({ tsKey: field, value: column });
|
|
514
|
+
// // }
|
|
515
|
+
// let initiallySelectedRelations: {
|
|
516
|
+
// tsKey: string;
|
|
517
|
+
// queryConfig: true | DBQueryConfig<'many', false>;
|
|
518
|
+
// relation: Relation;
|
|
519
|
+
// }[] = [];
|
|
520
|
+
// // let selectedRelations: BuildRelationalQueryResult<PgTable, PgColumn>['selection'] = [];
|
|
521
|
+
// // Figure out which relations to select
|
|
522
|
+
// if (config.with) {
|
|
523
|
+
// initiallySelectedRelations = Object.entries(config.with)
|
|
524
|
+
// .filter((entry): entry is [typeof entry[0], NonNullable<typeof entry[1]>] => !!entry[1])
|
|
525
|
+
// .map(([tsKey, queryConfig]) => ({ tsKey, queryConfig, relation: tableConfig.relations[tsKey]! }));
|
|
526
|
+
// }
|
|
527
|
+
// const manyRelations = initiallySelectedRelations.filter((r) =>
|
|
528
|
+
// is(r.relation, Many)
|
|
529
|
+
// && (schema[tableNamesMap[r.relation.referencedTable[Table.Symbol.Name]]!]?.primaryKey.length ?? 0) > 0
|
|
530
|
+
// );
|
|
531
|
+
// // If this is the last Many relation (or there are no Many relations), we are on the innermost subquery level
|
|
532
|
+
// const isInnermostQuery = manyRelations.length < 2;
|
|
533
|
+
// const selectedExtras: {
|
|
534
|
+
// tsKey: string;
|
|
535
|
+
// value: SQL.Aliased;
|
|
536
|
+
// }[] = [];
|
|
537
|
+
// // Figure out which extras to select
|
|
538
|
+
// if (isInnermostQuery && config.extras) {
|
|
539
|
+
// const extras = typeof config.extras === 'function'
|
|
540
|
+
// ? config.extras(aliasedFields, { sql })
|
|
541
|
+
// : config.extras;
|
|
542
|
+
// for (const [tsKey, value] of Object.entries(extras)) {
|
|
543
|
+
// selectedExtras.push({
|
|
544
|
+
// tsKey,
|
|
545
|
+
// value: mapColumnsInAliasedSQLToAlias(value, tableAlias),
|
|
546
|
+
// });
|
|
547
|
+
// }
|
|
548
|
+
// }
|
|
549
|
+
// // Transform `fieldsSelection` into `selection`
|
|
550
|
+
// // `fieldsSelection` shouldn't be used after this point
|
|
551
|
+
// // for (const { tsKey, value, isExtra } of fieldsSelection) {
|
|
552
|
+
// // selection.push({
|
|
553
|
+
// // dbKey: is(value, SQL.Aliased) ? value.fieldAlias : tableConfig.columns[tsKey]!.name,
|
|
554
|
+
// // tsKey,
|
|
555
|
+
// // field: is(value, Column) ? aliasedTableColumn(value, tableAlias) : value,
|
|
556
|
+
// // relationTableTsKey: undefined,
|
|
557
|
+
// // isJson: false,
|
|
558
|
+
// // isExtra,
|
|
559
|
+
// // selection: [],
|
|
560
|
+
// // });
|
|
561
|
+
// // }
|
|
562
|
+
// let orderByOrig = typeof config.orderBy === 'function'
|
|
563
|
+
// ? config.orderBy(aliasedFields, orderByOperators)
|
|
564
|
+
// : config.orderBy ?? [];
|
|
565
|
+
// if (!Array.isArray(orderByOrig)) {
|
|
566
|
+
// orderByOrig = [orderByOrig];
|
|
567
|
+
// }
|
|
568
|
+
// const orderBy = orderByOrig.map((orderByValue) => {
|
|
569
|
+
// if (is(orderByValue, Column)) {
|
|
570
|
+
// return aliasedTableColumn(orderByValue, tableAlias) as PgColumn;
|
|
571
|
+
// }
|
|
572
|
+
// return mapColumnsInSQLToAlias(orderByValue, tableAlias);
|
|
573
|
+
// });
|
|
574
|
+
// const limit = isInnermostQuery ? config.limit : undefined;
|
|
575
|
+
// const offset = isInnermostQuery ? config.offset : undefined;
|
|
576
|
+
// // For non-root queries without additional config except columns, return a table with selection
|
|
577
|
+
// if (
|
|
578
|
+
// !isRoot
|
|
579
|
+
// && initiallySelectedRelations.length === 0
|
|
580
|
+
// && selectedExtras.length === 0
|
|
581
|
+
// && !where
|
|
582
|
+
// && orderBy.length === 0
|
|
583
|
+
// && limit === undefined
|
|
584
|
+
// && offset === undefined
|
|
585
|
+
// ) {
|
|
586
|
+
// return {
|
|
587
|
+
// tableTsKey: tableConfig.tsName,
|
|
588
|
+
// sql: table,
|
|
589
|
+
// selection: selectedColumns.map((key) => ({
|
|
590
|
+
// dbKey: tableConfig.columns[key]!.name,
|
|
591
|
+
// tsKey: key,
|
|
592
|
+
// field: tableConfig.columns[key] as PgColumn,
|
|
593
|
+
// relationTableTsKey: undefined,
|
|
594
|
+
// isJson: false,
|
|
595
|
+
// selection: [],
|
|
596
|
+
// })),
|
|
597
|
+
// };
|
|
598
|
+
// }
|
|
599
|
+
// const selectedRelationsWithoutPK:
|
|
600
|
+
// // Process all relations without primary keys, because they need to be joined differently and will all be on the same query level
|
|
601
|
+
// for (
|
|
602
|
+
// const {
|
|
603
|
+
// tsKey: selectedRelationTsKey,
|
|
604
|
+
// queryConfig: selectedRelationConfigValue,
|
|
605
|
+
// relation,
|
|
606
|
+
// } of initiallySelectedRelations
|
|
607
|
+
// ) {
|
|
608
|
+
// const normalizedRelation = normalizeRelation(schema, tableNamesMap, relation);
|
|
609
|
+
// const relationTableName = relation.referencedTable[Table.Symbol.Name];
|
|
610
|
+
// const relationTableTsName = tableNamesMap[relationTableName]!;
|
|
611
|
+
// const relationTable = schema[relationTableTsName]!;
|
|
612
|
+
// if (relationTable.primaryKey.length > 0) {
|
|
613
|
+
// continue;
|
|
614
|
+
// }
|
|
615
|
+
// const relationTableAlias = `${tableAlias}_${selectedRelationTsKey}`;
|
|
616
|
+
// const joinOn = and(
|
|
617
|
+
// ...normalizedRelation.fields.map((field, i) =>
|
|
618
|
+
// eq(
|
|
619
|
+
// aliasedTableColumn(normalizedRelation.references[i]!, relationTableAlias),
|
|
620
|
+
// aliasedTableColumn(field, tableAlias),
|
|
621
|
+
// )
|
|
622
|
+
// ),
|
|
623
|
+
// );
|
|
624
|
+
// const builtRelation = this.buildRelationalQueryWithoutPK({
|
|
625
|
+
// fullSchema,
|
|
626
|
+
// schema,
|
|
627
|
+
// tableNamesMap,
|
|
628
|
+
// table: fullSchema[relationTableTsName] as PgTable,
|
|
629
|
+
// tableConfig: schema[relationTableTsName]!,
|
|
630
|
+
// queryConfig: selectedRelationConfigValue,
|
|
631
|
+
// tableAlias: relationTableAlias,
|
|
632
|
+
// joinOn,
|
|
633
|
+
// nestedQueryRelation: relation,
|
|
634
|
+
// });
|
|
635
|
+
// const field = sql`${sql.identifier(relationTableAlias)}.${sql.identifier('data')}`.as(selectedRelationTsKey);
|
|
636
|
+
// joins.push({
|
|
637
|
+
// on: sql`true`,
|
|
638
|
+
// table: new Subquery(builtRelation.sql as SQL, {}, relationTableAlias),
|
|
639
|
+
// alias: relationTableAlias,
|
|
640
|
+
// joinType: 'left',
|
|
641
|
+
// lateral: true,
|
|
642
|
+
// });
|
|
643
|
+
// selectedRelations.push({
|
|
644
|
+
// dbKey: selectedRelationTsKey,
|
|
645
|
+
// tsKey: selectedRelationTsKey,
|
|
646
|
+
// field,
|
|
647
|
+
// relationTableTsKey: relationTableTsName,
|
|
648
|
+
// isJson: true,
|
|
649
|
+
// selection: builtRelation.selection,
|
|
650
|
+
// });
|
|
651
|
+
// }
|
|
652
|
+
// const oneRelations = initiallySelectedRelations.filter((r): r is typeof r & { relation: One } =>
|
|
653
|
+
// is(r.relation, One)
|
|
654
|
+
// );
|
|
655
|
+
// // Process all One relations with PKs, because they can all be joined on the same level
|
|
656
|
+
// for (
|
|
657
|
+
// const {
|
|
658
|
+
// tsKey: selectedRelationTsKey,
|
|
659
|
+
// queryConfig: selectedRelationConfigValue,
|
|
660
|
+
// relation,
|
|
661
|
+
// } of oneRelations
|
|
662
|
+
// ) {
|
|
663
|
+
// const normalizedRelation = normalizeRelation(schema, tableNamesMap, relation);
|
|
664
|
+
// const relationTableName = relation.referencedTable[Table.Symbol.Name];
|
|
665
|
+
// const relationTableTsName = tableNamesMap[relationTableName]!;
|
|
666
|
+
// const relationTableAlias = `${tableAlias}_${selectedRelationTsKey}`;
|
|
667
|
+
// const relationTable = schema[relationTableTsName]!;
|
|
668
|
+
// if (relationTable.primaryKey.length === 0) {
|
|
669
|
+
// continue;
|
|
670
|
+
// }
|
|
671
|
+
// const joinOn = and(
|
|
672
|
+
// ...normalizedRelation.fields.map((field, i) =>
|
|
673
|
+
// eq(
|
|
674
|
+
// aliasedTableColumn(normalizedRelation.references[i]!, relationTableAlias),
|
|
675
|
+
// aliasedTableColumn(field, tableAlias),
|
|
676
|
+
// )
|
|
677
|
+
// ),
|
|
678
|
+
// );
|
|
679
|
+
// const builtRelation = this.buildRelationalQueryWithPK({
|
|
680
|
+
// fullSchema,
|
|
681
|
+
// schema,
|
|
682
|
+
// tableNamesMap,
|
|
683
|
+
// table: fullSchema[relationTableTsName] as PgTable,
|
|
684
|
+
// tableConfig: schema[relationTableTsName]!,
|
|
685
|
+
// queryConfig: selectedRelationConfigValue,
|
|
686
|
+
// tableAlias: relationTableAlias,
|
|
687
|
+
// joinOn,
|
|
688
|
+
// });
|
|
689
|
+
// const field = sql`case when ${sql.identifier(relationTableAlias)} is null then null else json_build_array(${
|
|
690
|
+
// sql.join(
|
|
691
|
+
// builtRelation.selection.map(({ field }) =>
|
|
692
|
+
// is(field, SQL.Aliased)
|
|
693
|
+
// ? sql`${sql.identifier(relationTableAlias)}.${sql.identifier(field.fieldAlias)}`
|
|
694
|
+
// : is(field, Column)
|
|
695
|
+
// ? aliasedTableColumn(field, relationTableAlias)
|
|
696
|
+
// : field
|
|
697
|
+
// ),
|
|
698
|
+
// sql`, `,
|
|
699
|
+
// )
|
|
700
|
+
// }) end`.as(selectedRelationTsKey);
|
|
701
|
+
// const isLateralJoin = is(builtRelation.sql, SQL);
|
|
702
|
+
// joins.push({
|
|
703
|
+
// on: isLateralJoin ? sql`true` : joinOn,
|
|
704
|
+
// table: is(builtRelation.sql, SQL)
|
|
705
|
+
// ? new Subquery(builtRelation.sql, {}, relationTableAlias)
|
|
706
|
+
// : aliasedTable(builtRelation.sql, relationTableAlias),
|
|
707
|
+
// alias: relationTableAlias,
|
|
708
|
+
// joinType: 'left',
|
|
709
|
+
// lateral: is(builtRelation.sql, SQL),
|
|
710
|
+
// });
|
|
711
|
+
// selectedRelations.push({
|
|
712
|
+
// dbKey: selectedRelationTsKey,
|
|
713
|
+
// tsKey: selectedRelationTsKey,
|
|
714
|
+
// field,
|
|
715
|
+
// relationTableTsKey: relationTableTsName,
|
|
716
|
+
// isJson: true,
|
|
717
|
+
// selection: builtRelation.selection,
|
|
718
|
+
// });
|
|
719
|
+
// }
|
|
720
|
+
// let distinct: PgSelectConfig['distinct'];
|
|
721
|
+
// let tableFrom: PgTable | Subquery = table;
|
|
722
|
+
// // Process first Many relation - each one requires a nested subquery
|
|
723
|
+
// const manyRelation = manyRelations[0];
|
|
724
|
+
// if (manyRelation) {
|
|
725
|
+
// const {
|
|
726
|
+
// tsKey: selectedRelationTsKey,
|
|
727
|
+
// queryConfig: selectedRelationQueryConfig,
|
|
728
|
+
// relation,
|
|
729
|
+
// } = manyRelation;
|
|
730
|
+
// distinct = {
|
|
731
|
+
// on: tableConfig.primaryKey.map((c) => aliasedTableColumn(c as PgColumn, tableAlias)),
|
|
732
|
+
// };
|
|
733
|
+
// const normalizedRelation = normalizeRelation(schema, tableNamesMap, relation);
|
|
734
|
+
// const relationTableName = relation.referencedTable[Table.Symbol.Name];
|
|
735
|
+
// const relationTableTsName = tableNamesMap[relationTableName]!;
|
|
736
|
+
// const relationTableAlias = `${tableAlias}_${selectedRelationTsKey}`;
|
|
737
|
+
// const joinOn = and(
|
|
738
|
+
// ...normalizedRelation.fields.map((field, i) =>
|
|
739
|
+
// eq(
|
|
740
|
+
// aliasedTableColumn(normalizedRelation.references[i]!, relationTableAlias),
|
|
741
|
+
// aliasedTableColumn(field, tableAlias),
|
|
742
|
+
// )
|
|
743
|
+
// ),
|
|
744
|
+
// );
|
|
745
|
+
// const builtRelationJoin = this.buildRelationalQueryWithPK({
|
|
746
|
+
// fullSchema,
|
|
747
|
+
// schema,
|
|
748
|
+
// tableNamesMap,
|
|
749
|
+
// table: fullSchema[relationTableTsName] as PgTable,
|
|
750
|
+
// tableConfig: schema[relationTableTsName]!,
|
|
751
|
+
// queryConfig: selectedRelationQueryConfig,
|
|
752
|
+
// tableAlias: relationTableAlias,
|
|
753
|
+
// joinOn,
|
|
754
|
+
// });
|
|
755
|
+
// const builtRelationSelectionField = sql`case when ${
|
|
756
|
+
// sql.identifier(relationTableAlias)
|
|
757
|
+
// } is null then '[]' else json_agg(json_build_array(${
|
|
758
|
+
// sql.join(
|
|
759
|
+
// builtRelationJoin.selection.map(({ field }) =>
|
|
760
|
+
// is(field, SQL.Aliased)
|
|
761
|
+
// ? sql`${sql.identifier(relationTableAlias)}.${sql.identifier(field.fieldAlias)}`
|
|
762
|
+
// : is(field, Column)
|
|
763
|
+
// ? aliasedTableColumn(field, relationTableAlias)
|
|
764
|
+
// : field
|
|
765
|
+
// ),
|
|
766
|
+
// sql`, `,
|
|
767
|
+
// )
|
|
768
|
+
// })) over (partition by ${sql.join(distinct.on, sql`, `)}) end`.as(selectedRelationTsKey);
|
|
769
|
+
// const isLateralJoin = is(builtRelationJoin.sql, SQL);
|
|
770
|
+
// joins.push({
|
|
771
|
+
// on: isLateralJoin ? sql`true` : joinOn,
|
|
772
|
+
// table: isLateralJoin
|
|
773
|
+
// ? new Subquery(builtRelationJoin.sql as SQL, {}, relationTableAlias)
|
|
774
|
+
// : aliasedTable(builtRelationJoin.sql as PgTable, relationTableAlias),
|
|
775
|
+
// alias: relationTableAlias,
|
|
776
|
+
// joinType: 'left',
|
|
777
|
+
// lateral: isLateralJoin,
|
|
778
|
+
// });
|
|
779
|
+
// // Build the "from" subquery with the remaining Many relations
|
|
780
|
+
// const builtTableFrom = this.buildRelationalQueryWithPK({
|
|
781
|
+
// fullSchema,
|
|
782
|
+
// schema,
|
|
783
|
+
// tableNamesMap,
|
|
784
|
+
// table,
|
|
785
|
+
// tableConfig,
|
|
786
|
+
// queryConfig: {
|
|
787
|
+
// ...config,
|
|
788
|
+
// where: undefined,
|
|
789
|
+
// orderBy: undefined,
|
|
790
|
+
// limit: undefined,
|
|
791
|
+
// offset: undefined,
|
|
792
|
+
// with: manyRelations.slice(1).reduce<NonNullable<typeof config['with']>>(
|
|
793
|
+
// (result, { tsKey, queryConfig: configValue }) => {
|
|
794
|
+
// result[tsKey] = configValue;
|
|
795
|
+
// return result;
|
|
796
|
+
// },
|
|
797
|
+
// {},
|
|
798
|
+
// ),
|
|
799
|
+
// },
|
|
800
|
+
// tableAlias,
|
|
801
|
+
// });
|
|
802
|
+
// selectedRelations.push({
|
|
803
|
+
// dbKey: selectedRelationTsKey,
|
|
804
|
+
// tsKey: selectedRelationTsKey,
|
|
805
|
+
// field: builtRelationSelectionField,
|
|
806
|
+
// relationTableTsKey: relationTableTsName,
|
|
807
|
+
// isJson: true,
|
|
808
|
+
// selection: builtRelationJoin.selection,
|
|
809
|
+
// });
|
|
810
|
+
// // selection = builtTableFrom.selection.map((item) =>
|
|
811
|
+
// // is(item.field, SQL.Aliased)
|
|
812
|
+
// // ? { ...item, field: sql`${sql.identifier(tableAlias)}.${sql.identifier(item.field.fieldAlias)}` }
|
|
813
|
+
// // : item
|
|
814
|
+
// // );
|
|
815
|
+
// // selectionForBuild = [{
|
|
816
|
+
// // dbKey: '*',
|
|
817
|
+
// // tsKey: '*',
|
|
818
|
+
// // field: sql`${sql.identifier(tableAlias)}.*`,
|
|
819
|
+
// // selection: [],
|
|
820
|
+
// // isJson: false,
|
|
821
|
+
// // relationTableTsKey: undefined,
|
|
822
|
+
// // }];
|
|
823
|
+
// // const newSelectionItem: (typeof selection)[number] = {
|
|
824
|
+
// // dbKey: selectedRelationTsKey,
|
|
825
|
+
// // tsKey: selectedRelationTsKey,
|
|
826
|
+
// // field,
|
|
827
|
+
// // relationTableTsKey: relationTableTsName,
|
|
828
|
+
// // isJson: true,
|
|
829
|
+
// // selection: builtRelationJoin.selection,
|
|
830
|
+
// // };
|
|
831
|
+
// // selection.push(newSelectionItem);
|
|
832
|
+
// // selectionForBuild.push(newSelectionItem);
|
|
833
|
+
// tableFrom = is(builtTableFrom.sql, PgTable)
|
|
834
|
+
// ? builtTableFrom.sql
|
|
835
|
+
// : new Subquery(builtTableFrom.sql, {}, tableAlias);
|
|
836
|
+
// }
|
|
837
|
+
// if (selectedColumns.length === 0 && selectedRelations.length === 0 && selectedExtras.length === 0) {
|
|
838
|
+
// throw new DrizzleError(`No fields selected for table "${tableConfig.tsName}" ("${tableAlias}")`);
|
|
839
|
+
// }
|
|
840
|
+
// let selection: BuildRelationalQueryResult<PgTable, PgColumn>['selection'];
|
|
841
|
+
// function prepareSelectedColumns() {
|
|
842
|
+
// return selectedColumns.map((key) => ({
|
|
843
|
+
// dbKey: tableConfig.columns[key]!.name,
|
|
844
|
+
// tsKey: key,
|
|
845
|
+
// field: tableConfig.columns[key] as PgColumn,
|
|
846
|
+
// relationTableTsKey: undefined,
|
|
847
|
+
// isJson: false,
|
|
848
|
+
// selection: [],
|
|
849
|
+
// }));
|
|
850
|
+
// }
|
|
851
|
+
// function prepareSelectedExtras() {
|
|
852
|
+
// return selectedExtras.map((item) => ({
|
|
853
|
+
// dbKey: item.value.fieldAlias,
|
|
854
|
+
// tsKey: item.tsKey,
|
|
855
|
+
// field: item.value,
|
|
856
|
+
// relationTableTsKey: undefined,
|
|
857
|
+
// isJson: false,
|
|
858
|
+
// selection: [],
|
|
859
|
+
// }));
|
|
860
|
+
// }
|
|
861
|
+
// if (isRoot) {
|
|
862
|
+
// selection = [
|
|
863
|
+
// ...prepareSelectedColumns(),
|
|
864
|
+
// ...prepareSelectedExtras(),
|
|
865
|
+
// ];
|
|
866
|
+
// }
|
|
867
|
+
// if (hasUserDefinedWhere || orderBy.length > 0) {
|
|
868
|
+
// tableFrom = new Subquery(
|
|
869
|
+
// this.buildSelectQuery({
|
|
870
|
+
// table: is(tableFrom, PgTable) ? aliasedTable(tableFrom, tableAlias) : tableFrom,
|
|
871
|
+
// fields: {},
|
|
872
|
+
// fieldsFlat: selectionForBuild.map(({ field }) => ({
|
|
873
|
+
// path: [],
|
|
874
|
+
// field: is(field, Column) ? aliasedTableColumn(field, tableAlias) : field,
|
|
875
|
+
// })),
|
|
876
|
+
// joins,
|
|
877
|
+
// distinct,
|
|
878
|
+
// }),
|
|
879
|
+
// {},
|
|
880
|
+
// tableAlias,
|
|
881
|
+
// );
|
|
882
|
+
// selectionForBuild = selection.map((item) =>
|
|
883
|
+
// is(item.field, SQL.Aliased)
|
|
884
|
+
// ? { ...item, field: sql`${sql.identifier(tableAlias)}.${sql.identifier(item.field.fieldAlias)}` }
|
|
885
|
+
// : item
|
|
886
|
+
// );
|
|
887
|
+
// joins = [];
|
|
888
|
+
// distinct = undefined;
|
|
889
|
+
// }
|
|
890
|
+
// const result = this.buildSelectQuery({
|
|
891
|
+
// table: is(tableFrom, PgTable) ? aliasedTable(tableFrom, tableAlias) : tableFrom,
|
|
892
|
+
// fields: {},
|
|
893
|
+
// fieldsFlat: selectionForBuild.map(({ field }) => ({
|
|
894
|
+
// path: [],
|
|
895
|
+
// field: is(field, Column) ? aliasedTableColumn(field, tableAlias) : field,
|
|
896
|
+
// })),
|
|
897
|
+
// where,
|
|
898
|
+
// limit,
|
|
899
|
+
// offset,
|
|
900
|
+
// joins,
|
|
901
|
+
// orderBy,
|
|
902
|
+
// distinct,
|
|
903
|
+
// });
|
|
904
|
+
// return {
|
|
905
|
+
// tableTsKey: tableConfig.tsName,
|
|
906
|
+
// sql: result,
|
|
907
|
+
// selection,
|
|
908
|
+
// };
|
|
909
|
+
// }
|
|
910
|
+
buildRelationalQueryWithoutPK({
|
|
442
911
|
fullSchema,
|
|
443
912
|
schema,
|
|
444
913
|
tableNamesMap,
|
|
@@ -467,7 +936,7 @@ class PgDialect {
|
|
|
467
936
|
Object.entries(tableConfig.columns).map(([key, value]) => [key, (0, import_alias.aliasedTableColumn)(value, tableAlias)])
|
|
468
937
|
);
|
|
469
938
|
if (config.where) {
|
|
470
|
-
const whereSql = typeof config.where === "function" ? config.where(aliasedColumns,
|
|
939
|
+
const whereSql = typeof config.where === "function" ? config.where(aliasedColumns, (0, import_relations.getOperators)()) : config.where;
|
|
471
940
|
where = whereSql && (0, import_alias.mapColumnsInSQLToAlias)(whereSql, tableAlias);
|
|
472
941
|
}
|
|
473
942
|
const fieldsSelection = [];
|
|
@@ -519,7 +988,7 @@ class PgDialect {
|
|
|
519
988
|
selection: []
|
|
520
989
|
});
|
|
521
990
|
}
|
|
522
|
-
let orderByOrig = typeof config.orderBy === "function" ? config.orderBy(aliasedColumns,
|
|
991
|
+
let orderByOrig = typeof config.orderBy === "function" ? config.orderBy(aliasedColumns, (0, import_relations.getOrderByOperators)()) : config.orderBy ?? [];
|
|
523
992
|
if (!Array.isArray(orderByOrig)) {
|
|
524
993
|
orderByOrig = [orderByOrig];
|
|
525
994
|
}
|
|
@@ -536,7 +1005,7 @@ class PgDialect {
|
|
|
536
1005
|
queryConfig: selectedRelationConfigValue,
|
|
537
1006
|
relation
|
|
538
1007
|
} of selectedRelations) {
|
|
539
|
-
const normalizedRelation =
|
|
1008
|
+
const normalizedRelation = (0, import_relations.normalizeRelation)(schema, tableNamesMap, relation);
|
|
540
1009
|
const relationTableName = (0, import_table2.getTableUniqueName)(relation.referencedTable);
|
|
541
1010
|
const relationTableTsName = tableNamesMap[relationTableName];
|
|
542
1011
|
const relationTableAlias = `${tableAlias}_${selectedRelationTsKey}`;
|
|
@@ -548,13 +1017,13 @@ class PgDialect {
|
|
|
548
1017
|
)
|
|
549
1018
|
)
|
|
550
1019
|
);
|
|
551
|
-
const builtRelation = this.
|
|
1020
|
+
const builtRelation = this.buildRelationalQueryWithoutPK({
|
|
552
1021
|
fullSchema,
|
|
553
1022
|
schema,
|
|
554
1023
|
tableNamesMap,
|
|
555
1024
|
table: fullSchema[relationTableTsName],
|
|
556
1025
|
tableConfig: schema[relationTableTsName],
|
|
557
|
-
queryConfig: (0, import_entity.is)(relation,
|
|
1026
|
+
queryConfig: (0, import_entity.is)(relation, import_relations.One) ? selectedRelationConfigValue === true ? { limit: 1 } : { ...selectedRelationConfigValue, limit: 1 } : selectedRelationConfigValue,
|
|
558
1027
|
tableAlias: relationTableAlias,
|
|
559
1028
|
joinOn: joinOn2,
|
|
560
1029
|
nestedQueryRelation: relation
|
|
@@ -589,7 +1058,7 @@ class PgDialect {
|
|
|
589
1058
|
),
|
|
590
1059
|
import_sql2.sql`, `
|
|
591
1060
|
)})`;
|
|
592
|
-
if ((0, import_entity.is)(nestedQueryRelation,
|
|
1061
|
+
if ((0, import_entity.is)(nestedQueryRelation, import_relations.Many)) {
|
|
593
1062
|
field = import_sql2.sql`coalesce(json_agg(${field}${orderBy.length > 0 ? import_sql2.sql` order by ${import_sql2.sql.join(orderBy, import_sql2.sql`, `)}` : void 0}), '[]'::json)`;
|
|
594
1063
|
}
|
|
595
1064
|
const nestedSelection = [{
|
|
@@ -658,139 +1127,6 @@ class PgDialect {
|
|
|
658
1127
|
selection
|
|
659
1128
|
};
|
|
660
1129
|
}
|
|
661
|
-
unwrapAllColumns = (table, selection) => {
|
|
662
|
-
return import_sql2.sql.join(
|
|
663
|
-
Object.entries(table[import_table2.Columns]).map(([k, v]) => {
|
|
664
|
-
selection.push({
|
|
665
|
-
key: k,
|
|
666
|
-
field: v
|
|
667
|
-
});
|
|
668
|
-
return import_sql2.sql`${v} as ${import_sql2.sql.identifier(k)}`;
|
|
669
|
-
}),
|
|
670
|
-
import_sql2.sql`, `
|
|
671
|
-
);
|
|
672
|
-
};
|
|
673
|
-
buildColumns = (table, tableConfig, selection, config) => config?.columns ? (() => {
|
|
674
|
-
const entries = Object.entries(config.columns);
|
|
675
|
-
const columnIdentifiers = [];
|
|
676
|
-
let colSelectionMode;
|
|
677
|
-
for (const [k, v] of entries) {
|
|
678
|
-
if (v === void 0)
|
|
679
|
-
continue;
|
|
680
|
-
colSelectionMode = colSelectionMode || v;
|
|
681
|
-
if (v) {
|
|
682
|
-
columnIdentifiers.push(
|
|
683
|
-
import_sql2.sql`${table[import_table2.Columns][k]} as ${import_sql2.sql.identifier(k)}`
|
|
684
|
-
);
|
|
685
|
-
selection.push({
|
|
686
|
-
key: k,
|
|
687
|
-
field: table[import_table2.Columns][k]
|
|
688
|
-
});
|
|
689
|
-
}
|
|
690
|
-
}
|
|
691
|
-
if (colSelectionMode === false) {
|
|
692
|
-
for (const [k, v] of Object.entries(table[import_table2.Columns])) {
|
|
693
|
-
if (config.columns[k] === false)
|
|
694
|
-
continue;
|
|
695
|
-
columnIdentifiers.push(import_sql2.sql`${v} as ${import_sql2.sql.identifier(k)}`);
|
|
696
|
-
selection.push({
|
|
697
|
-
key: k,
|
|
698
|
-
field: v
|
|
699
|
-
});
|
|
700
|
-
}
|
|
701
|
-
}
|
|
702
|
-
return columnIdentifiers.length ? import_sql2.sql.join(columnIdentifiers, import_sql2.sql`, `) : void 0;
|
|
703
|
-
})() : this.unwrapAllColumns(table, selection);
|
|
704
|
-
buildRelationalQuery({
|
|
705
|
-
tables,
|
|
706
|
-
schema,
|
|
707
|
-
tableNamesMap,
|
|
708
|
-
table,
|
|
709
|
-
tableConfig,
|
|
710
|
-
queryConfig: config,
|
|
711
|
-
relationWhere,
|
|
712
|
-
mode,
|
|
713
|
-
errorPath,
|
|
714
|
-
depth
|
|
715
|
-
}) {
|
|
716
|
-
const selection = [];
|
|
717
|
-
const isSingle = mode === "first";
|
|
718
|
-
const params = config === true ? void 0 : config;
|
|
719
|
-
const currentPath = errorPath ?? "";
|
|
720
|
-
const currentDepth = depth ?? 0;
|
|
721
|
-
const limit = isSingle ? 1 : params?.limit;
|
|
722
|
-
const offset = params?.offset;
|
|
723
|
-
const where = params?.where && relationWhere ? (0, import_sql.and)((0, import_relations.relationsFilterToSQL)(table, params.where), relationWhere) : params?.where ? (0, import_relations.relationsFilterToSQL)(table, params.where) : relationWhere;
|
|
724
|
-
const order = params?.orderBy ? (0, import_relations.relationsOrderToSQL)(table, params.orderBy) : void 0;
|
|
725
|
-
const columns = this.buildColumns(table, tableConfig, selection, params);
|
|
726
|
-
const extras = params?.extras ? (0, import_relations.relationExtrasToSQL)(table, params.extras) : void 0;
|
|
727
|
-
if (extras)
|
|
728
|
-
selection.push(...extras.selection);
|
|
729
|
-
const selectionArr = columns ? [columns] : [];
|
|
730
|
-
const joins = params ? (() => {
|
|
731
|
-
const { with: joins2 } = params;
|
|
732
|
-
if (!joins2)
|
|
733
|
-
return;
|
|
734
|
-
const withEntries = Object.entries(joins2).filter(([_, v]) => v);
|
|
735
|
-
if (!withEntries.length)
|
|
736
|
-
return;
|
|
737
|
-
return import_sql2.sql.join(
|
|
738
|
-
withEntries.map(([k, join]) => {
|
|
739
|
-
if ((0, import_entity.is)(tableConfig.relations[k], import_relations.AggregatedField)) {
|
|
740
|
-
const relation2 = tableConfig.relations[k];
|
|
741
|
-
relation2.onTable(table);
|
|
742
|
-
const query2 = relation2.getSQL();
|
|
743
|
-
selection.push({
|
|
744
|
-
key: k,
|
|
745
|
-
field: relation2
|
|
746
|
-
});
|
|
747
|
-
selectionArr.push(import_sql2.sql`${import_sql2.sql.identifier(k)}.${import_sql2.sql.identifier("r")} as ${import_sql2.sql.identifier(k)}`);
|
|
748
|
-
return import_sql2.sql`left join lateral(${query2}) as ${import_sql2.sql.identifier(k)} on true`;
|
|
749
|
-
}
|
|
750
|
-
const relation = tableConfig.relations[k];
|
|
751
|
-
const isSingle2 = (0, import_entity.is)(relation, import_relations.One);
|
|
752
|
-
const targetTable = (0, import_alias.aliasedTable)(relation.targetTable, `d${currentDepth + 1}`);
|
|
753
|
-
const relationFilter = (0, import_relations.relationToSQL)(relation, table, targetTable);
|
|
754
|
-
selectionArr.push(
|
|
755
|
-
isSingle2 ? import_sql2.sql`${import_sql2.sql.identifier(k)}.${import_sql2.sql.identifier("r")} as ${import_sql2.sql.identifier(k)}` : import_sql2.sql`coalesce(${import_sql2.sql.identifier(k)}.${import_sql2.sql.identifier("r")}, '[]') as ${import_sql2.sql.identifier(k)}`
|
|
756
|
-
);
|
|
757
|
-
const innerQuery = this.buildRelationalQuery({
|
|
758
|
-
table: targetTable,
|
|
759
|
-
mode: isSingle2 ? "first" : "many",
|
|
760
|
-
schema,
|
|
761
|
-
queryConfig: join,
|
|
762
|
-
tableConfig: schema[tableNamesMap[(0, import_table2.getTableUniqueName)(relation.targetTable)]],
|
|
763
|
-
tableNamesMap,
|
|
764
|
-
tables,
|
|
765
|
-
relationWhere: relationFilter,
|
|
766
|
-
errorPath: `${currentPath.length ? `${currentPath}.` : ""}${k}`,
|
|
767
|
-
depth: currentDepth + 1
|
|
768
|
-
});
|
|
769
|
-
selection.push({
|
|
770
|
-
field: targetTable,
|
|
771
|
-
key: k,
|
|
772
|
-
selection: innerQuery.selection,
|
|
773
|
-
isArray: !isSingle2
|
|
774
|
-
});
|
|
775
|
-
return import_sql2.sql`left join lateral(select ${isSingle2 ? import_sql2.sql`row_to_json(${import_sql2.sql.identifier("t")}.*) ${import_sql2.sql.identifier("r")}` : import_sql2.sql`json_agg(row_to_json(${import_sql2.sql.identifier("t")}.*)) ${import_sql2.sql.identifier("r")}`} from (${innerQuery.sql}) as ${import_sql2.sql.identifier("t")}) as ${import_sql2.sql.identifier(k)} on true`;
|
|
776
|
-
}),
|
|
777
|
-
import_sql2.sql` `
|
|
778
|
-
);
|
|
779
|
-
})() : void 0;
|
|
780
|
-
if (extras?.sql)
|
|
781
|
-
selectionArr.push(extras.sql);
|
|
782
|
-
if (!selectionArr.length) {
|
|
783
|
-
throw new import_errors.DrizzleError({
|
|
784
|
-
message: `No fields selected for table "${tableConfig.tsName}"${currentPath ? ` ("${currentPath}")` : ""}`
|
|
785
|
-
});
|
|
786
|
-
}
|
|
787
|
-
const selectionSet = import_sql2.sql.join(selectionArr.filter((e) => e !== void 0), import_sql2.sql`, `);
|
|
788
|
-
const query = import_sql2.sql`select ${selectionSet} from ${table[import_table2.IsAlias] ? import_sql2.sql`${import_sql2.sql`${import_sql2.sql.identifier(table[import_table2.Schema] ?? "")}.`.if(table[import_table2.Schema])}${import_sql2.sql.identifier(table[import_table2.OriginalName])} as ${table}` : table}${import_sql2.sql` ${joins}`.if(joins)}${import_sql2.sql` where ${where}`.if(where)}${import_sql2.sql` order by ${order}`.if(order)}${import_sql2.sql` limit ${limit}`.if(limit !== void 0)}${import_sql2.sql` offset ${offset}`.if(offset !== void 0)}`;
|
|
789
|
-
return {
|
|
790
|
-
sql: query,
|
|
791
|
-
selection
|
|
792
|
-
};
|
|
793
|
-
}
|
|
794
1130
|
}
|
|
795
1131
|
// Annotate the CommonJS export names for ESM import in node:
|
|
796
1132
|
0 && (module.exports = {
|