drizzle-orm 0.43.1 → 0.44.0
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/aws-data-api/pg/driver.cjs +5 -1
- package/aws-data-api/pg/driver.cjs.map +1 -1
- package/aws-data-api/pg/driver.d.cts +1 -0
- package/aws-data-api/pg/driver.d.ts +1 -0
- package/aws-data-api/pg/driver.js +5 -1
- package/aws-data-api/pg/driver.js.map +1 -1
- package/aws-data-api/pg/session.cjs +15 -4
- package/aws-data-api/pg/session.cjs.map +1 -1
- package/aws-data-api/pg/session.d.cts +13 -2
- package/aws-data-api/pg/session.d.ts +13 -2
- package/aws-data-api/pg/session.js +15 -4
- package/aws-data-api/pg/session.js.map +1 -1
- package/better-sqlite3/driver.cjs +1 -2
- package/better-sqlite3/driver.cjs.map +1 -1
- package/better-sqlite3/driver.js +1 -2
- package/better-sqlite3/driver.js.map +1 -1
- package/better-sqlite3/session.cjs +9 -3
- package/better-sqlite3/session.cjs.map +1 -1
- package/better-sqlite3/session.d.cts +12 -2
- package/better-sqlite3/session.d.ts +12 -2
- package/better-sqlite3/session.js +9 -3
- package/better-sqlite3/session.js.map +1 -1
- package/bun-sql/driver.cjs +6 -3
- package/bun-sql/driver.cjs.map +1 -1
- package/bun-sql/driver.js +6 -3
- package/bun-sql/driver.js.map +1 -1
- package/bun-sql/session.cjs +21 -9
- package/bun-sql/session.cjs.map +1 -1
- package/bun-sql/session.d.cts +12 -2
- package/bun-sql/session.d.ts +12 -2
- package/bun-sql/session.js +21 -9
- package/bun-sql/session.js.map +1 -1
- package/bun-sqlite/driver.cjs +1 -2
- package/bun-sqlite/driver.cjs.map +1 -1
- package/bun-sqlite/driver.js +1 -2
- package/bun-sqlite/driver.js.map +1 -1
- package/cache/core/cache.cjs +58 -0
- package/cache/core/cache.cjs.map +1 -0
- package/cache/core/cache.d.cts +36 -0
- package/cache/core/cache.d.ts +36 -0
- package/cache/core/cache.js +32 -0
- package/cache/core/cache.js.map +1 -0
- package/cache/core/index.cjs +23 -0
- package/cache/core/index.cjs.map +1 -0
- package/cache/core/index.d.cts +1 -0
- package/cache/core/index.d.ts +1 -0
- package/cache/core/index.js +2 -0
- package/cache/core/index.js.map +1 -0
- package/cache/core/types.cjs +17 -0
- package/cache/core/types.cjs.map +1 -0
- package/cache/core/types.d.cts +33 -0
- package/cache/core/types.d.ts +33 -0
- package/cache/core/types.js +1 -0
- package/cache/core/types.js.map +1 -0
- package/cache/upstash/cache.cjs +195 -0
- package/cache/upstash/cache.cjs.map +1 -0
- package/cache/upstash/cache.d.cts +59 -0
- package/cache/upstash/cache.d.ts +59 -0
- package/cache/upstash/cache.js +170 -0
- package/cache/upstash/cache.js.map +1 -0
- package/cache/upstash/index.cjs +23 -0
- package/cache/upstash/index.cjs.map +1 -0
- package/cache/upstash/index.d.cts +1 -0
- package/cache/upstash/index.d.ts +1 -0
- package/cache/upstash/index.js +2 -0
- package/cache/upstash/index.js.map +1 -0
- package/casing.cjs +1 -2
- package/casing.cjs.map +1 -1
- package/casing.js +1 -2
- package/casing.js.map +1 -1
- package/column-builder.cjs +1 -2
- package/column-builder.cjs.map +1 -1
- package/column-builder.js +1 -2
- package/column-builder.js.map +1 -1
- package/d1/driver.cjs +5 -1
- package/d1/driver.cjs.map +1 -1
- package/d1/driver.js +5 -1
- package/d1/driver.js.map +1 -1
- package/d1/session.cjs +23 -9
- package/d1/session.cjs.map +1 -1
- package/d1/session.d.cts +12 -2
- package/d1/session.d.ts +12 -2
- package/d1/session.js +23 -9
- package/d1/session.js.map +1 -1
- package/durable-sqlite/session.cjs +1 -1
- package/durable-sqlite/session.cjs.map +1 -1
- package/durable-sqlite/session.js +1 -1
- package/durable-sqlite/session.js.map +1 -1
- package/errors/index.cjs +39 -0
- package/errors/index.cjs.map +1 -0
- package/errors/index.d.cts +6 -0
- package/errors/index.d.ts +6 -0
- package/errors/index.js +15 -0
- package/errors/index.js.map +1 -0
- package/gel/driver.cjs +10 -4
- package/gel/driver.cjs.map +1 -1
- package/gel/driver.d.cts +2 -0
- package/gel/driver.d.ts +2 -0
- package/gel/driver.js +10 -4
- package/gel/driver.js.map +1 -1
- package/gel/session.cjs +25 -10
- package/gel/session.cjs.map +1 -1
- package/gel/session.d.cts +12 -2
- package/gel/session.d.ts +12 -2
- package/gel/session.js +25 -10
- package/gel/session.js.map +1 -1
- package/gel-core/db.cjs +3 -0
- package/gel-core/db.cjs.map +1 -1
- package/gel-core/db.d.cts +4 -0
- package/gel-core/db.d.ts +4 -0
- package/gel-core/db.js +3 -0
- package/gel-core/db.js.map +1 -1
- package/gel-core/dialect.cjs +1 -2
- package/gel-core/dialect.cjs.map +1 -1
- package/gel-core/dialect.js +1 -2
- package/gel-core/dialect.js.map +1 -1
- package/gel-core/query-builders/delete.cjs +5 -1
- package/gel-core/query-builders/delete.cjs.map +1 -1
- package/gel-core/query-builders/delete.js +5 -1
- package/gel-core/query-builders/delete.js.map +1 -1
- package/gel-core/query-builders/insert.cjs +5 -1
- package/gel-core/query-builders/insert.cjs.map +1 -1
- package/gel-core/query-builders/insert.js +5 -1
- package/gel-core/query-builders/insert.js.map +1 -1
- package/gel-core/query-builders/select.cjs +26 -4
- package/gel-core/query-builders/select.cjs.map +1 -1
- package/gel-core/query-builders/select.d.cts +9 -0
- package/gel-core/query-builders/select.d.ts +9 -0
- package/gel-core/query-builders/select.js +26 -4
- package/gel-core/query-builders/select.js.map +1 -1
- package/gel-core/query-builders/update.cjs +5 -1
- package/gel-core/query-builders/update.cjs.map +1 -1
- package/gel-core/query-builders/update.js +5 -1
- package/gel-core/query-builders/update.js.map +1 -1
- package/gel-core/session.cjs +78 -1
- package/gel-core/session.cjs.map +1 -1
- package/gel-core/session.d.cts +13 -2
- package/gel-core/session.d.ts +13 -2
- package/gel-core/session.js +79 -2
- package/gel-core/session.js.map +1 -1
- package/gel-core/utils.cjs +16 -0
- package/gel-core/utils.cjs.map +1 -1
- package/gel-core/utils.d.cts +8 -4
- package/gel-core/utils.d.ts +8 -4
- package/gel-core/utils.js +15 -0
- package/gel-core/utils.js.map +1 -1
- package/index.cjs +16 -16
- package/index.cjs.map +1 -1
- package/libsql/driver-core.cjs +5 -1
- package/libsql/driver-core.cjs.map +1 -1
- package/libsql/driver-core.js +5 -1
- package/libsql/driver-core.js.map +1 -1
- package/libsql/driver.cjs +1 -2
- package/libsql/driver.cjs.map +1 -1
- package/libsql/driver.js +1 -2
- package/libsql/driver.js.map +1 -1
- package/libsql/http/index.cjs +1 -2
- package/libsql/http/index.cjs.map +1 -1
- package/libsql/http/index.js +1 -2
- package/libsql/http/index.js.map +1 -1
- package/libsql/node/index.cjs +1 -2
- package/libsql/node/index.cjs.map +1 -1
- package/libsql/node/index.js +1 -2
- package/libsql/node/index.js.map +1 -1
- package/libsql/session.cjs +27 -13
- package/libsql/session.cjs.map +1 -1
- package/libsql/session.d.cts +12 -2
- package/libsql/session.d.ts +12 -2
- package/libsql/session.js +27 -13
- package/libsql/session.js.map +1 -1
- package/libsql/sqlite3/index.cjs +1 -2
- package/libsql/sqlite3/index.cjs.map +1 -1
- package/libsql/sqlite3/index.js +1 -2
- package/libsql/sqlite3/index.js.map +1 -1
- package/libsql/wasm/index.cjs +1 -2
- package/libsql/wasm/index.cjs.map +1 -1
- package/libsql/wasm/index.js +1 -2
- package/libsql/wasm/index.js.map +1 -1
- package/libsql/web/index.cjs +1 -2
- package/libsql/web/index.cjs.map +1 -1
- package/libsql/web/index.js +1 -2
- package/libsql/web/index.js.map +1 -1
- package/libsql/ws/index.cjs +1 -2
- package/libsql/ws/index.cjs.map +1 -1
- package/libsql/ws/index.js +1 -2
- package/libsql/ws/index.js.map +1 -1
- package/mysql-core/columns/binary.cjs +2 -4
- package/mysql-core/columns/binary.cjs.map +1 -1
- package/mysql-core/columns/binary.js +2 -4
- package/mysql-core/columns/binary.js.map +1 -1
- package/mysql-core/columns/decimal.cjs +2 -4
- package/mysql-core/columns/decimal.cjs.map +1 -1
- package/mysql-core/columns/decimal.js +2 -4
- package/mysql-core/columns/decimal.js.map +1 -1
- package/mysql-core/columns/varbinary.cjs +2 -4
- package/mysql-core/columns/varbinary.cjs.map +1 -1
- package/mysql-core/columns/varbinary.js +2 -4
- package/mysql-core/columns/varbinary.js.map +1 -1
- package/mysql-core/db.cjs +3 -0
- package/mysql-core/db.cjs.map +1 -1
- package/mysql-core/db.d.cts +4 -0
- package/mysql-core/db.d.ts +4 -0
- package/mysql-core/db.js +3 -0
- package/mysql-core/db.js.map +1 -1
- package/mysql-core/dialect.cjs +1 -2
- package/mysql-core/dialect.cjs.map +1 -1
- package/mysql-core/dialect.js +1 -2
- package/mysql-core/dialect.js.map +1 -1
- package/mysql-core/query-builders/delete.cjs +9 -1
- package/mysql-core/query-builders/delete.cjs.map +1 -1
- package/mysql-core/query-builders/delete.js +9 -1
- package/mysql-core/query-builders/delete.js.map +1 -1
- package/mysql-core/query-builders/insert.cjs +8 -1
- package/mysql-core/query-builders/insert.cjs.map +1 -1
- package/mysql-core/query-builders/insert.d.cts +2 -0
- package/mysql-core/query-builders/insert.d.ts +2 -0
- package/mysql-core/query-builders/insert.js +8 -1
- package/mysql-core/query-builders/insert.js.map +1 -1
- package/mysql-core/query-builders/select.cjs +24 -3
- package/mysql-core/query-builders/select.cjs.map +1 -1
- package/mysql-core/query-builders/select.d.cts +9 -0
- package/mysql-core/query-builders/select.d.ts +9 -0
- package/mysql-core/query-builders/select.js +25 -4
- package/mysql-core/query-builders/select.js.map +1 -1
- package/mysql-core/query-builders/update.cjs +11 -1
- package/mysql-core/query-builders/update.cjs.map +1 -1
- package/mysql-core/query-builders/update.d.cts +2 -0
- package/mysql-core/query-builders/update.d.ts +2 -0
- package/mysql-core/query-builders/update.js +11 -1
- package/mysql-core/query-builders/update.js.map +1 -1
- package/mysql-core/session.cjs +79 -0
- package/mysql-core/session.cjs.map +1 -1
- package/mysql-core/session.d.cts +14 -1
- package/mysql-core/session.d.ts +14 -1
- package/mysql-core/session.js +80 -1
- package/mysql-core/session.js.map +1 -1
- package/mysql-core/utils.cjs +16 -0
- package/mysql-core/utils.cjs.map +1 -1
- package/mysql-core/utils.d.cts +6 -2
- package/mysql-core/utils.d.ts +6 -2
- package/mysql-core/utils.js +15 -0
- package/mysql-core/utils.js.map +1 -1
- package/mysql-proxy/session.cjs +15 -5
- package/mysql-proxy/session.cjs.map +1 -1
- package/mysql-proxy/session.d.cts +12 -2
- package/mysql-proxy/session.d.ts +12 -2
- package/mysql-proxy/session.js +15 -5
- package/mysql-proxy/session.js.map +1 -1
- package/mysql2/driver.cjs +11 -4
- package/mysql2/driver.cjs.map +1 -1
- package/mysql2/driver.d.cts +2 -0
- package/mysql2/driver.d.ts +2 -0
- package/mysql2/driver.js +11 -4
- package/mysql2/driver.js.map +1 -1
- package/mysql2/session.cjs +15 -5
- package/mysql2/session.cjs.map +1 -1
- package/mysql2/session.d.cts +12 -2
- package/mysql2/session.d.ts +12 -2
- package/mysql2/session.js +15 -5
- package/mysql2/session.js.map +1 -1
- package/neon-http/driver.cjs +13 -10
- package/neon-http/driver.cjs.map +1 -1
- package/neon-http/driver.d.cts +2 -0
- package/neon-http/driver.d.ts +2 -0
- package/neon-http/driver.js +13 -10
- package/neon-http/driver.js.map +1 -1
- package/neon-http/session.cjs +25 -15
- package/neon-http/session.cjs.map +1 -1
- package/neon-http/session.d.cts +12 -2
- package/neon-http/session.d.ts +12 -2
- package/neon-http/session.js +25 -15
- package/neon-http/session.js.map +1 -1
- package/neon-serverless/driver.cjs +10 -4
- package/neon-serverless/driver.cjs.map +1 -1
- package/neon-serverless/driver.d.cts +2 -0
- package/neon-serverless/driver.d.ts +2 -0
- package/neon-serverless/driver.js +10 -4
- package/neon-serverless/driver.js.map +1 -1
- package/neon-serverless/session.cjs +21 -7
- package/neon-serverless/session.cjs.map +1 -1
- package/neon-serverless/session.d.cts +12 -2
- package/neon-serverless/session.d.ts +12 -2
- package/neon-serverless/session.js +21 -7
- package/neon-serverless/session.js.map +1 -1
- package/node-postgres/driver.cjs +10 -4
- package/node-postgres/driver.cjs.map +1 -1
- package/node-postgres/driver.d.cts +2 -0
- package/node-postgres/driver.d.ts +2 -0
- package/node-postgres/driver.js +10 -4
- package/node-postgres/driver.js.map +1 -1
- package/node-postgres/session.cjs +19 -6
- package/node-postgres/session.cjs.map +1 -1
- package/node-postgres/session.d.cts +13 -2
- package/node-postgres/session.d.ts +13 -2
- package/node-postgres/session.js +19 -6
- package/node-postgres/session.js.map +1 -1
- package/op-sqlite/driver.cjs +5 -1
- package/op-sqlite/driver.cjs.map +1 -1
- package/op-sqlite/driver.js +5 -1
- package/op-sqlite/driver.js.map +1 -1
- package/op-sqlite/session.cjs +23 -9
- package/op-sqlite/session.cjs.map +1 -1
- package/op-sqlite/session.d.cts +12 -2
- package/op-sqlite/session.d.ts +12 -2
- package/op-sqlite/session.js +23 -9
- package/op-sqlite/session.js.map +1 -1
- package/package.json +77 -12
- package/pg-core/columns/common.cjs +1 -2
- package/pg-core/columns/common.cjs.map +1 -1
- package/pg-core/columns/common.js +1 -2
- package/pg-core/columns/common.js.map +1 -1
- package/pg-core/columns/numeric.cjs +2 -4
- package/pg-core/columns/numeric.cjs.map +1 -1
- package/pg-core/columns/numeric.js +2 -4
- package/pg-core/columns/numeric.js.map +1 -1
- package/pg-core/db.cjs +3 -0
- package/pg-core/db.cjs.map +1 -1
- package/pg-core/db.d.cts +4 -0
- package/pg-core/db.d.ts +4 -0
- package/pg-core/db.js +3 -0
- package/pg-core/db.js.map +1 -1
- package/pg-core/dialect.cjs +1 -2
- package/pg-core/dialect.cjs.map +1 -1
- package/pg-core/dialect.js +1 -2
- package/pg-core/dialect.js.map +1 -1
- package/pg-core/query-builders/delete.cjs +6 -1
- package/pg-core/query-builders/delete.cjs.map +1 -1
- package/pg-core/query-builders/delete.d.cts +3 -1
- package/pg-core/query-builders/delete.d.ts +3 -1
- package/pg-core/query-builders/delete.js +6 -1
- package/pg-core/query-builders/delete.js.map +1 -1
- package/pg-core/query-builders/insert.cjs +6 -1
- package/pg-core/query-builders/insert.cjs.map +1 -1
- package/pg-core/query-builders/insert.d.cts +2 -0
- package/pg-core/query-builders/insert.d.ts +2 -0
- package/pg-core/query-builders/insert.js +6 -1
- package/pg-core/query-builders/insert.js.map +1 -1
- package/pg-core/query-builders/select.cjs +28 -5
- package/pg-core/query-builders/select.cjs.map +1 -1
- package/pg-core/query-builders/select.d.cts +15 -6
- package/pg-core/query-builders/select.d.ts +15 -6
- package/pg-core/query-builders/select.js +28 -5
- package/pg-core/query-builders/select.js.map +1 -1
- package/pg-core/query-builders/update.cjs +6 -1
- package/pg-core/query-builders/update.cjs.map +1 -1
- package/pg-core/query-builders/update.d.cts +4 -2
- package/pg-core/query-builders/update.d.ts +4 -2
- package/pg-core/query-builders/update.js +6 -1
- package/pg-core/query-builders/update.js.map +1 -1
- package/pg-core/session.cjs +78 -1
- package/pg-core/session.cjs.map +1 -1
- package/pg-core/session.d.cts +13 -2
- package/pg-core/session.d.ts +13 -2
- package/pg-core/session.js +79 -2
- package/pg-core/session.js.map +1 -1
- package/pg-core/utils.cjs +16 -0
- package/pg-core/utils.cjs.map +1 -1
- package/pg-core/utils.d.cts +8 -4
- package/pg-core/utils.d.ts +8 -4
- package/pg-core/utils.js +16 -1
- package/pg-core/utils.js.map +1 -1
- package/pg-proxy/driver.cjs +7 -2
- package/pg-proxy/driver.cjs.map +1 -1
- package/pg-proxy/driver.js +7 -2
- package/pg-proxy/driver.js.map +1 -1
- package/pg-proxy/session.cjs +15 -5
- package/pg-proxy/session.cjs.map +1 -1
- package/pg-proxy/session.d.cts +12 -2
- package/pg-proxy/session.d.ts +12 -2
- package/pg-proxy/session.js +15 -5
- package/pg-proxy/session.js.map +1 -1
- package/pglite/driver.cjs +10 -4
- package/pglite/driver.cjs.map +1 -1
- package/pglite/driver.d.cts +2 -0
- package/pglite/driver.d.ts +2 -0
- package/pglite/driver.js +10 -4
- package/pglite/driver.js.map +1 -1
- package/pglite/session.cjs +19 -7
- package/pglite/session.cjs.map +1 -1
- package/pglite/session.d.cts +12 -2
- package/pglite/session.d.ts +12 -2
- package/pglite/session.js +19 -7
- package/pglite/session.js.map +1 -1
- package/planetscale-serverless/driver.cjs +6 -3
- package/planetscale-serverless/driver.cjs.map +1 -1
- package/planetscale-serverless/driver.d.cts +1 -0
- package/planetscale-serverless/driver.d.ts +1 -0
- package/planetscale-serverless/driver.js +6 -3
- package/planetscale-serverless/driver.js.map +1 -1
- package/planetscale-serverless/session.cjs +15 -5
- package/planetscale-serverless/session.cjs.map +1 -1
- package/planetscale-serverless/session.d.cts +12 -2
- package/planetscale-serverless/session.d.ts +12 -2
- package/planetscale-serverless/session.js +15 -5
- package/planetscale-serverless/session.js.map +1 -1
- package/postgres-js/driver.cjs +6 -3
- package/postgres-js/driver.cjs.map +1 -1
- package/postgres-js/driver.js +6 -3
- package/postgres-js/driver.js.map +1 -1
- package/postgres-js/session.cjs +18 -6
- package/postgres-js/session.cjs.map +1 -1
- package/postgres-js/session.d.cts +12 -2
- package/postgres-js/session.d.ts +12 -2
- package/postgres-js/session.js +18 -6
- package/postgres-js/session.js.map +1 -1
- package/prisma/mysql/session.cjs +1 -1
- package/prisma/mysql/session.cjs.map +1 -1
- package/prisma/mysql/session.js +1 -1
- package/prisma/mysql/session.js.map +1 -1
- package/prisma/pg/session.cjs +1 -1
- package/prisma/pg/session.cjs.map +1 -1
- package/prisma/pg/session.js +1 -1
- package/prisma/pg/session.js.map +1 -1
- package/query-builders/query-builder.cjs.map +1 -1
- package/query-builders/query-builder.d.cts +2 -1
- package/query-builders/query-builder.d.ts +2 -1
- package/query-builders/query-builder.js.map +1 -1
- package/singlestore/driver.cjs +13 -4
- package/singlestore/driver.cjs.map +1 -1
- package/singlestore/driver.d.cts +2 -0
- package/singlestore/driver.d.ts +2 -0
- package/singlestore/driver.js +13 -4
- package/singlestore/driver.js.map +1 -1
- package/singlestore/session.cjs +15 -5
- package/singlestore/session.cjs.map +1 -1
- package/singlestore/session.d.cts +12 -2
- package/singlestore/session.d.ts +12 -2
- package/singlestore/session.js +15 -5
- package/singlestore/session.js.map +1 -1
- package/singlestore-core/columns/binary.cjs +2 -4
- package/singlestore-core/columns/binary.cjs.map +1 -1
- package/singlestore-core/columns/binary.js +2 -4
- package/singlestore-core/columns/binary.js.map +1 -1
- package/singlestore-core/columns/decimal.cjs +2 -4
- package/singlestore-core/columns/decimal.cjs.map +1 -1
- package/singlestore-core/columns/decimal.js +2 -4
- package/singlestore-core/columns/decimal.js.map +1 -1
- package/singlestore-core/columns/varbinary.cjs +2 -4
- package/singlestore-core/columns/varbinary.cjs.map +1 -1
- package/singlestore-core/columns/varbinary.js +2 -4
- package/singlestore-core/columns/varbinary.js.map +1 -1
- package/singlestore-core/db.cjs +3 -0
- package/singlestore-core/db.cjs.map +1 -1
- package/singlestore-core/db.d.cts +4 -0
- package/singlestore-core/db.d.ts +4 -0
- package/singlestore-core/db.js +3 -0
- package/singlestore-core/db.js.map +1 -1
- package/singlestore-core/dialect.cjs +1 -2
- package/singlestore-core/dialect.cjs.map +1 -1
- package/singlestore-core/dialect.js +1 -2
- package/singlestore-core/dialect.js.map +1 -1
- package/singlestore-core/query-builders/delete.cjs +9 -1
- package/singlestore-core/query-builders/delete.cjs.map +1 -1
- package/singlestore-core/query-builders/delete.js +9 -1
- package/singlestore-core/query-builders/delete.js.map +1 -1
- package/singlestore-core/query-builders/insert.cjs +6 -1
- package/singlestore-core/query-builders/insert.cjs.map +1 -1
- package/singlestore-core/query-builders/insert.js +6 -1
- package/singlestore-core/query-builders/insert.js.map +1 -1
- package/singlestore-core/query-builders/select.cjs +25 -3
- package/singlestore-core/query-builders/select.cjs.map +1 -1
- package/singlestore-core/query-builders/select.d.cts +9 -0
- package/singlestore-core/query-builders/select.d.ts +9 -0
- package/singlestore-core/query-builders/select.js +25 -3
- package/singlestore-core/query-builders/select.js.map +1 -1
- package/singlestore-core/query-builders/update.cjs +9 -1
- package/singlestore-core/query-builders/update.cjs.map +1 -1
- package/singlestore-core/query-builders/update.js +9 -1
- package/singlestore-core/query-builders/update.js.map +1 -1
- package/singlestore-core/session.cjs +79 -0
- package/singlestore-core/session.cjs.map +1 -1
- package/singlestore-core/session.d.cts +13 -1
- package/singlestore-core/session.d.ts +13 -1
- package/singlestore-core/session.js +80 -1
- package/singlestore-core/session.js.map +1 -1
- package/singlestore-core/utils.cjs +16 -0
- package/singlestore-core/utils.cjs.map +1 -1
- package/singlestore-core/utils.d.cts +3 -0
- package/singlestore-core/utils.d.ts +3 -0
- package/singlestore-core/utils.js +15 -0
- package/singlestore-core/utils.js.map +1 -1
- package/sql/sql.cjs +10 -0
- package/sql/sql.cjs.map +1 -1
- package/sql/sql.js +10 -0
- package/sql/sql.js.map +1 -1
- package/sqlite-core/columns/numeric.cjs +2 -4
- package/sqlite-core/columns/numeric.cjs.map +1 -1
- package/sqlite-core/columns/numeric.js +2 -4
- package/sqlite-core/columns/numeric.js.map +1 -1
- package/sqlite-core/db.cjs +3 -0
- package/sqlite-core/db.cjs.map +1 -1
- package/sqlite-core/db.d.cts +4 -0
- package/sqlite-core/db.d.ts +4 -0
- package/sqlite-core/db.js +3 -0
- package/sqlite-core/db.js.map +1 -1
- package/sqlite-core/dialect.cjs +1 -2
- package/sqlite-core/dialect.cjs.map +1 -1
- package/sqlite-core/dialect.js +1 -2
- package/sqlite-core/dialect.js.map +1 -1
- package/sqlite-core/query-builders/delete.cjs +7 -1
- package/sqlite-core/query-builders/delete.cjs.map +1 -1
- package/sqlite-core/query-builders/delete.js +7 -1
- package/sqlite-core/query-builders/delete.js.map +1 -1
- package/sqlite-core/query-builders/insert.cjs +9 -5
- package/sqlite-core/query-builders/insert.cjs.map +1 -1
- package/sqlite-core/query-builders/insert.js +9 -5
- package/sqlite-core/query-builders/insert.js.map +1 -1
- package/sqlite-core/query-builders/select.cjs +28 -3
- package/sqlite-core/query-builders/select.cjs.map +1 -1
- package/sqlite-core/query-builders/select.d.cts +9 -0
- package/sqlite-core/query-builders/select.d.ts +9 -0
- package/sqlite-core/query-builders/select.js +28 -3
- package/sqlite-core/query-builders/select.js.map +1 -1
- package/sqlite-core/query-builders/update.cjs +7 -1
- package/sqlite-core/query-builders/update.cjs.map +1 -1
- package/sqlite-core/query-builders/update.js +7 -1
- package/sqlite-core/query-builders/update.js.map +1 -1
- package/sqlite-core/session.cjs +88 -3
- package/sqlite-core/session.cjs.map +1 -1
- package/sqlite-core/session.d.cts +18 -4
- package/sqlite-core/session.d.ts +18 -4
- package/sqlite-core/session.js +89 -4
- package/sqlite-core/session.js.map +1 -1
- package/sqlite-core/utils.cjs +16 -0
- package/sqlite-core/utils.cjs.map +1 -1
- package/sqlite-core/utils.d.cts +6 -2
- package/sqlite-core/utils.d.ts +6 -2
- package/sqlite-core/utils.js +15 -0
- package/sqlite-core/utils.js.map +1 -1
- package/sqlite-proxy/driver.cjs +9 -2
- package/sqlite-proxy/driver.cjs.map +1 -1
- package/sqlite-proxy/driver.js +9 -2
- package/sqlite-proxy/driver.js.map +1 -1
- package/sqlite-proxy/session.cjs +22 -8
- package/sqlite-proxy/session.cjs.map +1 -1
- package/sqlite-proxy/session.d.cts +12 -2
- package/sqlite-proxy/session.d.ts +12 -2
- package/sqlite-proxy/session.js +22 -8
- package/sqlite-proxy/session.js.map +1 -1
- package/subquery.cjs +4 -3
- package/subquery.cjs.map +1 -1
- package/subquery.d.cts +2 -1
- package/subquery.d.ts +2 -1
- package/subquery.js +4 -3
- package/subquery.js.map +1 -1
- package/tidb-serverless/driver.cjs +6 -3
- package/tidb-serverless/driver.cjs.map +1 -1
- package/tidb-serverless/driver.d.cts +1 -0
- package/tidb-serverless/driver.d.ts +1 -0
- package/tidb-serverless/driver.js +6 -3
- package/tidb-serverless/driver.js.map +1 -1
- package/tidb-serverless/session.cjs +15 -5
- package/tidb-serverless/session.cjs.map +1 -1
- package/tidb-serverless/session.d.cts +12 -2
- package/tidb-serverless/session.d.ts +12 -2
- package/tidb-serverless/session.js +15 -5
- package/tidb-serverless/session.js.map +1 -1
- package/utils.cjs +10 -20
- package/utils.cjs.map +1 -1
- package/utils.d.cts +2 -0
- package/utils.d.ts +2 -0
- package/utils.js +10 -20
- package/utils.js.map +1 -1
- package/vercel-postgres/driver.cjs +9 -2
- package/vercel-postgres/driver.cjs.map +1 -1
- package/vercel-postgres/driver.d.cts +2 -0
- package/vercel-postgres/driver.d.ts +2 -0
- package/vercel-postgres/driver.js +9 -2
- package/vercel-postgres/driver.js.map +1 -1
- package/vercel-postgres/session.cjs +21 -7
- package/vercel-postgres/session.cjs.map +1 -1
- package/vercel-postgres/session.d.cts +12 -2
- package/vercel-postgres/session.d.ts +12 -2
- package/vercel-postgres/session.js +21 -7
- 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 +7 -2
- package/xata-http/driver.cjs.map +1 -1
- package/xata-http/driver.d.cts +2 -0
- package/xata-http/driver.d.ts +2 -0
- package/xata-http/driver.js +7 -2
- package/xata-http/driver.js.map +1 -1
- package/xata-http/session.cjs +22 -9
- package/xata-http/session.cjs.map +1 -1
- package/xata-http/session.d.cts +12 -2
- package/xata-http/session.d.ts +12 -2
- package/xata-http/session.js +22 -9
- package/xata-http/session.js.map +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { CacheConfig, WithCacheConfig } from "../../cache/core/types.js";
|
|
1
2
|
import { entityKind } from "../../entity.js";
|
|
2
3
|
import type { GelColumn } from "../columns/index.js";
|
|
3
4
|
import type { GelDialect } from "../dialect.js";
|
|
@@ -52,6 +53,7 @@ export declare abstract class GelSelectQueryBuilderBase<THKT extends GelSelectHK
|
|
|
52
53
|
readonly excludedMethods: TExcludedMethods;
|
|
53
54
|
readonly result: TResult;
|
|
54
55
|
readonly selectedFields: TSelectedFields;
|
|
56
|
+
readonly config: GelSelectConfig;
|
|
55
57
|
};
|
|
56
58
|
protected config: GelSelectConfig;
|
|
57
59
|
protected joinsNotNullableMap: Record<string, boolean>;
|
|
@@ -59,6 +61,8 @@ export declare abstract class GelSelectQueryBuilderBase<THKT extends GelSelectHK
|
|
|
59
61
|
private isPartialSelect;
|
|
60
62
|
protected session: GelSession | undefined;
|
|
61
63
|
protected dialect: GelDialect;
|
|
64
|
+
protected cacheConfig?: WithCacheConfig;
|
|
65
|
+
protected usedTables: Set<string>;
|
|
62
66
|
constructor({ table, fields, isPartialSelect, session, dialect, withList, distinct }: {
|
|
63
67
|
table: GelSelectConfig['table'];
|
|
64
68
|
fields: GelSelectConfig['fields'];
|
|
@@ -588,6 +592,11 @@ export interface GelSelectBase<TTableName extends string | undefined, TSelection
|
|
|
588
592
|
}
|
|
589
593
|
export declare class GelSelectBase<TTableName extends string | undefined, TSelection extends ColumnsSelection, TSelectMode extends SelectMode, TNullabilityMap extends Record<string, JoinNullability> = TTableName extends string ? Record<TTableName, 'not-null'> : {}, TDynamic extends boolean = false, TExcludedMethods extends string = never, TResult = SelectResult<TSelection, TSelectMode, TNullabilityMap>[], TSelectedFields = BuildSubquerySelection<TSelection, TNullabilityMap>> extends GelSelectQueryBuilderBase<GelSelectHKT, TTableName, TSelection, TSelectMode, TNullabilityMap, TDynamic, TExcludedMethods, TResult, TSelectedFields> implements RunnableQuery<TResult, 'gel'>, SQLWrapper {
|
|
590
594
|
static readonly [entityKind]: string;
|
|
595
|
+
$withCache(config?: {
|
|
596
|
+
config?: CacheConfig;
|
|
597
|
+
tag?: string;
|
|
598
|
+
autoInvalidate?: boolean;
|
|
599
|
+
} | false): this;
|
|
591
600
|
/**
|
|
592
601
|
* Create a prepared statement for this query. This allows
|
|
593
602
|
* the database to remember this query for the given session
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
} from "../../utils.js";
|
|
16
16
|
import { orderSelectedFields } from "../../utils.js";
|
|
17
17
|
import { ViewBaseConfig } from "../../view-common.js";
|
|
18
|
+
import { extractUsedTable } from "../utils.js";
|
|
18
19
|
class GelSelectBuilder {
|
|
19
20
|
static [entityKind] = "GelSelectBuilder";
|
|
20
21
|
fields;
|
|
@@ -79,6 +80,8 @@ class GelSelectQueryBuilderBase extends TypedQueryBuilder {
|
|
|
79
80
|
isPartialSelect;
|
|
80
81
|
session;
|
|
81
82
|
dialect;
|
|
83
|
+
cacheConfig = void 0;
|
|
84
|
+
usedTables = /* @__PURE__ */ new Set();
|
|
82
85
|
constructor({ table, fields, isPartialSelect, session, dialect, withList, distinct }) {
|
|
83
86
|
super();
|
|
84
87
|
this.config = {
|
|
@@ -92,10 +95,16 @@ class GelSelectQueryBuilderBase extends TypedQueryBuilder {
|
|
|
92
95
|
this.session = session;
|
|
93
96
|
this.dialect = dialect;
|
|
94
97
|
this._ = {
|
|
95
|
-
selectedFields: fields
|
|
98
|
+
selectedFields: fields,
|
|
99
|
+
config: this.config
|
|
96
100
|
};
|
|
97
101
|
this.tableName = getTableLikeName(table);
|
|
98
102
|
this.joinsNotNullableMap = typeof this.tableName === "string" ? { [this.tableName]: true } : {};
|
|
103
|
+
for (const item of extractUsedTable(table)) this.usedTables.add(item);
|
|
104
|
+
}
|
|
105
|
+
/** @internal */
|
|
106
|
+
getUsedTables() {
|
|
107
|
+
return [...this.usedTables];
|
|
99
108
|
}
|
|
100
109
|
createJoin(joinType, lateral) {
|
|
101
110
|
return (table, on) => {
|
|
@@ -104,6 +113,7 @@ class GelSelectQueryBuilderBase extends TypedQueryBuilder {
|
|
|
104
113
|
if (typeof tableName === "string" && this.config.joins?.some((join) => join.alias === tableName)) {
|
|
105
114
|
throw new Error(`Alias "${tableName}" is already used in this query`);
|
|
106
115
|
}
|
|
116
|
+
for (const item of extractUsedTable(table)) this.usedTables.add(item);
|
|
107
117
|
if (!this.isPartialSelect) {
|
|
108
118
|
if (Object.keys(this.joinsNotNullableMap).length === 1 && typeof baseTableName === "string") {
|
|
109
119
|
this.config.fields = {
|
|
@@ -721,8 +731,13 @@ class GelSelectQueryBuilderBase extends TypedQueryBuilder {
|
|
|
721
731
|
return rest;
|
|
722
732
|
}
|
|
723
733
|
as(alias) {
|
|
734
|
+
const usedTables = [];
|
|
735
|
+
usedTables.push(...extractUsedTable(this.config.table));
|
|
736
|
+
if (this.config.joins) {
|
|
737
|
+
for (const it of this.config.joins) usedTables.push(...extractUsedTable(it.table));
|
|
738
|
+
}
|
|
724
739
|
return new Proxy(
|
|
725
|
-
new Subquery(this.getSQL(), this.config.fields, alias),
|
|
740
|
+
new Subquery(this.getSQL(), this.config.fields, alias, false, [...new Set(usedTables)]),
|
|
726
741
|
new SelectionProxyHandler({ alias, sqlAliasedBehavior: "alias", sqlBehavior: "error" })
|
|
727
742
|
);
|
|
728
743
|
}
|
|
@@ -741,17 +756,24 @@ class GelSelectBase extends GelSelectQueryBuilderBase {
|
|
|
741
756
|
static [entityKind] = "GelSelect";
|
|
742
757
|
/** @internal */
|
|
743
758
|
_prepare(name) {
|
|
744
|
-
const { session, config, dialect, joinsNotNullableMap } = this;
|
|
759
|
+
const { session, config, dialect, joinsNotNullableMap, cacheConfig, usedTables } = this;
|
|
745
760
|
if (!session) {
|
|
746
761
|
throw new Error("Cannot execute a query on a query builder. Please use a database instance instead.");
|
|
747
762
|
}
|
|
748
763
|
return tracer.startActiveSpan("drizzle.prepareQuery", () => {
|
|
749
764
|
const fieldsList = orderSelectedFields(config.fields);
|
|
750
|
-
const query = session.prepareQuery(dialect.sqlToQuery(this.getSQL()), fieldsList, name, true
|
|
765
|
+
const query = session.prepareQuery(dialect.sqlToQuery(this.getSQL()), fieldsList, name, true, void 0, {
|
|
766
|
+
type: "select",
|
|
767
|
+
tables: [...usedTables]
|
|
768
|
+
}, cacheConfig);
|
|
751
769
|
query.joinsNotNullableMap = joinsNotNullableMap;
|
|
752
770
|
return query;
|
|
753
771
|
});
|
|
754
772
|
}
|
|
773
|
+
$withCache(config) {
|
|
774
|
+
this.cacheConfig = config === void 0 ? { config: {}, enable: true, autoInvalidate: true } : config === false ? { enable: false } : { enable: true, autoInvalidate: true, ...config };
|
|
775
|
+
return this;
|
|
776
|
+
}
|
|
755
777
|
/**
|
|
756
778
|
* Create a prepared statement for this query. This allows
|
|
757
779
|
* the database to remember this query for the given session
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/gel-core/query-builders/select.ts"],"sourcesContent":["import { entityKind, is } from '~/entity.ts';\nimport type { GelColumn } from '~/gel-core/columns/index.ts';\nimport type { GelDialect } from '~/gel-core/dialect.ts';\nimport type { GelSession, PreparedQueryConfig } from '~/gel-core/session.ts';\nimport type { SubqueryWithSelection } from '~/gel-core/subquery.ts';\nimport type { GelTable } from '~/gel-core/table.ts';\nimport { GelViewBase } from '~/gel-core/view-base.ts';\nimport { TypedQueryBuilder } from '~/query-builders/query-builder.ts';\nimport type {\n\tBuildSubquerySelection,\n\tGetSelectTableName,\n\tGetSelectTableSelection,\n\tJoinNullability,\n\tJoinType,\n\tSelectMode,\n\tSelectResult,\n\tSetOperator,\n} from '~/query-builders/select.types.ts';\nimport { QueryPromise } from '~/query-promise.ts';\nimport type { RunnableQuery } from '~/runnable-query.ts';\nimport { SelectionProxyHandler } from '~/selection-proxy.ts';\nimport { SQL, View } from '~/sql/sql.ts';\nimport type { ColumnsSelection, Placeholder, Query, SQLWrapper } from '~/sql/sql.ts';\nimport { Subquery } from '~/subquery.ts';\nimport { Table } from '~/table.ts';\nimport { tracer } from '~/tracing.ts';\nimport {\n\tapplyMixins,\n\tgetTableColumns,\n\tgetTableLikeName,\n\thaveSameKeys,\n\ttype NeonAuthToken,\n\ttype ValueOrArray,\n} from '~/utils.ts';\nimport { orderSelectedFields } from '~/utils.ts';\nimport { ViewBaseConfig } from '~/view-common.ts';\nimport type {\n\tAnyGelSelect,\n\tCreateGelSelectFromBuilderMode,\n\tGelCreateSetOperatorFn,\n\tGelSelectConfig,\n\tGelSelectDynamic,\n\tGelSelectHKT,\n\tGelSelectHKTBase,\n\tGelSelectJoinFn,\n\tGelSelectPrepare,\n\tGelSelectWithout,\n\tGelSetOperatorExcludedMethods,\n\tGelSetOperatorWithResult,\n\tGetGelSetOperators,\n\tLockConfig,\n\tLockStrength,\n\tSelectedFields,\n\tSetOperatorRightSelect,\n} from './select.types.ts';\n\nexport class GelSelectBuilder<\n\tTSelection extends SelectedFields | undefined,\n\tTBuilderMode extends 'db' | 'qb' = 'db',\n> {\n\tstatic readonly [entityKind]: string = 'GelSelectBuilder';\n\n\tprivate fields: TSelection;\n\tprivate session: GelSession | undefined;\n\tprivate dialect: GelDialect;\n\tprivate withList: Subquery[] = [];\n\tprivate distinct: boolean | {\n\t\ton: (GelColumn | SQLWrapper)[];\n\t} | undefined;\n\n\tconstructor(\n\t\tconfig: {\n\t\t\tfields: TSelection;\n\t\t\tsession: GelSession | undefined;\n\t\t\tdialect: GelDialect;\n\t\t\twithList?: Subquery[];\n\t\t\tdistinct?: boolean | {\n\t\t\t\ton: (GelColumn | SQLWrapper)[];\n\t\t\t};\n\t\t},\n\t) {\n\t\tthis.fields = config.fields;\n\t\tthis.session = config.session;\n\t\tthis.dialect = config.dialect;\n\t\tif (config.withList) {\n\t\t\tthis.withList = config.withList;\n\t\t}\n\t\tthis.distinct = config.distinct;\n\t}\n\n\tprivate authToken?: NeonAuthToken;\n\t/** @internal */\n\tsetToken(token?: NeonAuthToken) {\n\t\tthis.authToken = token;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Specify the table, subquery, or other target that you're\n\t * building a select query against.\n\t *\n\t * {@link https://www.postgresql.org/docs/current/sql-select.html#SQL-FROM | Postgres from documentation}\n\t */\n\tfrom<TFrom extends GelTable | Subquery | GelViewBase | SQL>(\n\t\tsource: TFrom,\n\t): CreateGelSelectFromBuilderMode<\n\t\tTBuilderMode,\n\t\tGetSelectTableName<TFrom>,\n\t\tTSelection extends undefined ? GetSelectTableSelection<TFrom> : TSelection,\n\t\tTSelection extends undefined ? 'single' : 'partial'\n\t> {\n\t\tconst isPartialSelect = !!this.fields;\n\n\t\tlet fields: SelectedFields;\n\t\tif (this.fields) {\n\t\t\tfields = this.fields;\n\t\t} else if (is(source, Subquery)) {\n\t\t\t// This is required to use the proxy handler to get the correct field values from the subquery\n\t\t\tfields = Object.fromEntries(\n\t\t\t\tObject.keys(source._.selectedFields).map((\n\t\t\t\t\tkey,\n\t\t\t\t) => [key, source[key as unknown as keyof typeof source] as unknown as SelectedFields[string]]),\n\t\t\t);\n\t\t} else if (is(source, GelViewBase)) {\n\t\t\tfields = source[ViewBaseConfig].selectedFields as SelectedFields;\n\t\t} else if (is(source, SQL)) {\n\t\t\tfields = {};\n\t\t} else {\n\t\t\tfields = getTableColumns<GelTable>(source);\n\t\t}\n\n\t\treturn new GelSelectBase({\n\t\t\ttable: source,\n\t\t\tfields,\n\t\t\tisPartialSelect,\n\t\t\tsession: this.session,\n\t\t\tdialect: this.dialect,\n\t\t\twithList: this.withList,\n\t\t\tdistinct: this.distinct,\n\t\t}) as any;\n\t}\n}\n\nexport abstract class GelSelectQueryBuilderBase<\n\tTHKT extends GelSelectHKTBase,\n\tTTableName extends string | undefined,\n\tTSelection extends ColumnsSelection,\n\tTSelectMode extends SelectMode,\n\tTNullabilityMap extends Record<string, JoinNullability> = TTableName extends string ? Record<TTableName, 'not-null'>\n\t\t: {},\n\tTDynamic extends boolean = false,\n\tTExcludedMethods extends string = never,\n\tTResult extends any[] = SelectResult<TSelection, TSelectMode, TNullabilityMap>[],\n\tTSelectedFields extends ColumnsSelection = BuildSubquerySelection<TSelection, TNullabilityMap>,\n> extends TypedQueryBuilder<TSelectedFields, TResult> {\n\tstatic override readonly [entityKind]: string = 'GelSelectQueryBuilder';\n\n\toverride readonly _: {\n\t\treadonly dialect: 'gel';\n\t\treadonly hkt: THKT;\n\t\treadonly tableName: TTableName;\n\t\treadonly selection: TSelection;\n\t\treadonly selectMode: TSelectMode;\n\t\treadonly nullabilityMap: TNullabilityMap;\n\t\treadonly dynamic: TDynamic;\n\t\treadonly excludedMethods: TExcludedMethods;\n\t\treadonly result: TResult;\n\t\treadonly selectedFields: TSelectedFields;\n\t};\n\n\tprotected config: GelSelectConfig;\n\tprotected joinsNotNullableMap: Record<string, boolean>;\n\tprivate tableName: string | undefined;\n\tprivate isPartialSelect: boolean;\n\tprotected session: GelSession | undefined;\n\tprotected dialect: GelDialect;\n\n\tconstructor(\n\t\t{ table, fields, isPartialSelect, session, dialect, withList, distinct }: {\n\t\t\ttable: GelSelectConfig['table'];\n\t\t\tfields: GelSelectConfig['fields'];\n\t\t\tisPartialSelect: boolean;\n\t\t\tsession: GelSession | undefined;\n\t\t\tdialect: GelDialect;\n\t\t\twithList: Subquery[];\n\t\t\tdistinct: boolean | {\n\t\t\t\ton: (GelColumn | SQLWrapper)[];\n\t\t\t} | undefined;\n\t\t},\n\t) {\n\t\tsuper();\n\t\tthis.config = {\n\t\t\twithList,\n\t\t\ttable,\n\t\t\tfields: { ...fields },\n\t\t\tdistinct,\n\t\t\tsetOperators: [],\n\t\t};\n\t\tthis.isPartialSelect = isPartialSelect;\n\t\tthis.session = session;\n\t\tthis.dialect = dialect;\n\t\tthis._ = {\n\t\t\tselectedFields: fields as TSelectedFields,\n\t\t} as this['_'];\n\t\tthis.tableName = getTableLikeName(table);\n\t\tthis.joinsNotNullableMap = typeof this.tableName === 'string' ? { [this.tableName]: true } : {};\n\t}\n\n\tprivate createJoin<\n\t\tTJoinType extends JoinType,\n\t\tTIsLateral extends (TJoinType extends 'full' | 'right' ? false : boolean),\n\t>(\n\t\tjoinType: TJoinType,\n\t\tlateral: TIsLateral,\n\t): GelSelectJoinFn<this, TDynamic, TJoinType, TIsLateral> {\n\t\treturn (\n\t\t\ttable: GelTable | Subquery | GelViewBase | SQL,\n\t\t\ton?: ((aliases: TSelection) => SQL | undefined) | SQL | undefined,\n\t\t) => {\n\t\t\tconst baseTableName = this.tableName;\n\t\t\tconst tableName = getTableLikeName(table);\n\n\t\t\tif (typeof tableName === 'string' && this.config.joins?.some((join) => join.alias === tableName)) {\n\t\t\t\tthrow new Error(`Alias \"${tableName}\" is already used in this query`);\n\t\t\t}\n\n\t\t\tif (!this.isPartialSelect) {\n\t\t\t\t// If this is the first join and this is not a partial select and we're not selecting from raw SQL, \"move\" the fields from the main table to the nested object\n\t\t\t\tif (Object.keys(this.joinsNotNullableMap).length === 1 && typeof baseTableName === 'string') {\n\t\t\t\t\tthis.config.fields = {\n\t\t\t\t\t\t[baseTableName]: this.config.fields,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tif (typeof tableName === 'string' && !is(table, SQL)) {\n\t\t\t\t\tconst selection = is(table, Subquery)\n\t\t\t\t\t\t? table._.selectedFields\n\t\t\t\t\t\t: is(table, View)\n\t\t\t\t\t\t? table[ViewBaseConfig].selectedFields\n\t\t\t\t\t\t: table[Table.Symbol.Columns];\n\t\t\t\t\tthis.config.fields[tableName] = selection;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (typeof on === 'function') {\n\t\t\t\ton = on(\n\t\t\t\t\tnew Proxy(\n\t\t\t\t\t\tthis.config.fields,\n\t\t\t\t\t\tnew SelectionProxyHandler({ sqlAliasedBehavior: 'sql', sqlBehavior: 'sql' }),\n\t\t\t\t\t) as TSelection,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (!this.config.joins) {\n\t\t\t\tthis.config.joins = [];\n\t\t\t}\n\n\t\t\tthis.config.joins.push({ on, table, joinType, alias: tableName, lateral });\n\n\t\t\tif (typeof tableName === 'string') {\n\t\t\t\tswitch (joinType) {\n\t\t\t\t\tcase 'left': {\n\t\t\t\t\t\tthis.joinsNotNullableMap[tableName] = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase 'right': {\n\t\t\t\t\t\tthis.joinsNotNullableMap = Object.fromEntries(\n\t\t\t\t\t\t\tObject.entries(this.joinsNotNullableMap).map(([key]) => [key, false]),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.joinsNotNullableMap[tableName] = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase 'cross':\n\t\t\t\t\tcase 'inner': {\n\t\t\t\t\t\tthis.joinsNotNullableMap[tableName] = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase 'full': {\n\t\t\t\t\t\tthis.joinsNotNullableMap = Object.fromEntries(\n\t\t\t\t\t\t\tObject.entries(this.joinsNotNullableMap).map(([key]) => [key, false]),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.joinsNotNullableMap[tableName] = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn this as any;\n\t\t};\n\t}\n\n\t/**\n\t * Executes a `left join` operation by adding another table to the current query.\n\t *\n\t * Calling this method associates each row of the table with the corresponding row from the joined table, if a match is found. If no matching row exists, it sets all columns of the joined table to null.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/joins#left-join}\n\t *\n\t * @param table the table to join.\n\t * @param on the `on` clause.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Select all users and their pets\n\t * const usersWithPets: { user: User; pets: Pet | null; }[] = await db.select()\n\t * .from(users)\n\t * .leftJoin(pets, eq(users.id, pets.ownerId))\n\t *\n\t * // Select userId and petId\n\t * const usersIdsAndPetIds: { userId: number; petId: number | null; }[] = await db.select({\n\t * userId: users.id,\n\t * petId: pets.id,\n\t * })\n\t * .from(users)\n\t * .leftJoin(pets, eq(users.id, pets.ownerId))\n\t * ```\n\t */\n\tleftJoin = this.createJoin('left', false);\n\n\t/**\n\t * Executes a `left join lateral` operation by adding subquery to the current query.\n\t *\n\t * A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.\n\t *\n\t * Calling this method associates each row of the table with the corresponding row from the joined table, if a match is found. If no matching row exists, it sets all columns of the joined table to null.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/joins#left-join-lateral}\n\t *\n\t * @param table the subquery to join.\n\t * @param on the `on` clause.\n\t */\n\tleftJoinLateral = this.createJoin('left', true);\n\n\t/**\n\t * Executes a `right join` operation by adding another table to the current query.\n\t *\n\t * Calling this method associates each row of the joined table with the corresponding row from the main table, if a match is found. If no matching row exists, it sets all columns of the main table to null.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/joins#right-join}\n\t *\n\t * @param table the table to join.\n\t * @param on the `on` clause.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Select all users and their pets\n\t * const usersWithPets: { user: User | null; pets: Pet; }[] = await db.select()\n\t * .from(users)\n\t * .rightJoin(pets, eq(users.id, pets.ownerId))\n\t *\n\t * // Select userId and petId\n\t * const usersIdsAndPetIds: { userId: number | null; petId: number; }[] = await db.select({\n\t * userId: users.id,\n\t * petId: pets.id,\n\t * })\n\t * .from(users)\n\t * .rightJoin(pets, eq(users.id, pets.ownerId))\n\t * ```\n\t */\n\trightJoin = this.createJoin('right', false);\n\n\t/**\n\t * Executes an `inner join` operation, creating a new table by combining rows from two tables that have matching values.\n\t *\n\t * Calling this method retrieves rows that have corresponding entries in both joined tables. Rows without matching entries in either table are excluded, resulting in a table that includes only matching pairs.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/joins#inner-join}\n\t *\n\t * @param table the table to join.\n\t * @param on the `on` clause.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Select all users and their pets\n\t * const usersWithPets: { user: User; pets: Pet; }[] = await db.select()\n\t * .from(users)\n\t * .innerJoin(pets, eq(users.id, pets.ownerId))\n\t *\n\t * // Select userId and petId\n\t * const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({\n\t * userId: users.id,\n\t * petId: pets.id,\n\t * })\n\t * .from(users)\n\t * .innerJoin(pets, eq(users.id, pets.ownerId))\n\t * ```\n\t */\n\tinnerJoin = this.createJoin('inner', false);\n\n\t/**\n\t * Executes an `inner join lateral` operation, creating a new table by combining rows from two queries that have matching values.\n\t *\n\t * A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.\n\t *\n\t * Calling this method retrieves rows that have corresponding entries in both joined tables. Rows without matching entries in either table are excluded, resulting in a table that includes only matching pairs.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/joins#inner-join-lateral}\n\t *\n\t * @param table the subquery to join.\n\t * @param on the `on` clause.\n\t */\n\tinnerJoinLateral = this.createJoin('inner', true);\n\n\t/**\n\t * Executes a `full join` operation by combining rows from two tables into a new table.\n\t *\n\t * Calling this method retrieves all rows from both main and joined tables, merging rows with matching values and filling in `null` for non-matching columns.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/joins#full-join}\n\t *\n\t * @param table the table to join.\n\t * @param on the `on` clause.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Select all users and their pets\n\t * const usersWithPets: { user: User | null; pets: Pet | null; }[] = await db.select()\n\t * .from(users)\n\t * .fullJoin(pets, eq(users.id, pets.ownerId))\n\t *\n\t * // Select userId and petId\n\t * const usersIdsAndPetIds: { userId: number | null; petId: number | null; }[] = await db.select({\n\t * userId: users.id,\n\t * petId: pets.id,\n\t * })\n\t * .from(users)\n\t * .fullJoin(pets, eq(users.id, pets.ownerId))\n\t * ```\n\t */\n\tfullJoin = this.createJoin('full', false);\n\n\t/**\n\t * Executes a `cross join` operation by combining rows from two tables into a new table.\n\t *\n\t * Calling this method retrieves all rows from both main and joined tables, merging all rows from each table.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/joins#cross-join}\n\t *\n\t * @param table the table to join.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Select all users, each user with every pet\n\t * const usersWithPets: { user: User; pets: Pet; }[] = await db.select()\n\t * .from(users)\n\t * .crossJoin(pets)\n\t *\n\t * // Select userId and petId\n\t * const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({\n\t * userId: users.id,\n\t * petId: pets.id,\n\t * })\n\t * .from(users)\n\t * .crossJoin(pets)\n\t * ```\n\t */\n\tcrossJoin = this.createJoin('cross', false);\n\n\t/**\n\t * Executes a `cross join lateral` operation by combining rows from two queries into a new table.\n\t *\n\t * A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.\n\t *\n\t * Calling this method retrieves all rows from both main and joined queries, merging all rows from each query.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/joins#cross-join-lateral}\n\t *\n\t * @param table the query to join.\n\t */\n\tcrossJoinLateral = this.createJoin('cross', true);\n\n\tprivate createSetOperator(\n\t\ttype: SetOperator,\n\t\tisAll: boolean,\n\t): <TValue extends GelSetOperatorWithResult<TResult>>(\n\t\trightSelection:\n\t\t\t| ((setOperators: GetGelSetOperators) => SetOperatorRightSelect<TValue, TResult>)\n\t\t\t| SetOperatorRightSelect<TValue, TResult>,\n\t) => GelSelectWithout<\n\t\tthis,\n\t\tTDynamic,\n\t\tGelSetOperatorExcludedMethods,\n\t\ttrue\n\t> {\n\t\treturn (rightSelection) => {\n\t\t\tconst rightSelect = (typeof rightSelection === 'function'\n\t\t\t\t? rightSelection(getGelSetOperators())\n\t\t\t\t: rightSelection) as TypedQueryBuilder<\n\t\t\t\t\tany,\n\t\t\t\t\tTResult\n\t\t\t\t>;\n\n\t\t\tif (!haveSameKeys(this.getSelectedFields(), rightSelect.getSelectedFields())) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'Set operator error (union / intersect / except): selected fields are not the same or are in a different order',\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tthis.config.setOperators.push({ type, isAll, rightSelect });\n\t\t\treturn this as any;\n\t\t};\n\t}\n\n\t/**\n\t * Adds `union` set operator to the query.\n\t *\n\t * Calling this method will combine the result sets of the `select` statements and remove any duplicate rows that appear across them.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/set-operations#union}\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Select all unique names from customers and users tables\n\t * await db.select({ name: users.name })\n\t * .from(users)\n\t * .union(\n\t * db.select({ name: customers.name }).from(customers)\n\t * );\n\t * // or\n\t * import { union } from 'drizzle-orm/gel-core'\n\t *\n\t * await union(\n\t * db.select({ name: users.name }).from(users),\n\t * db.select({ name: customers.name }).from(customers)\n\t * );\n\t * ```\n\t */\n\tunion = this.createSetOperator('union', false);\n\n\t/**\n\t * Adds `union all` set operator to the query.\n\t *\n\t * Calling this method will combine the result-set of the `select` statements and keep all duplicate rows that appear across them.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/set-operations#union-all}\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Select all transaction ids from both online and in-store sales\n\t * await db.select({ transaction: onlineSales.transactionId })\n\t * .from(onlineSales)\n\t * .unionAll(\n\t * db.select({ transaction: inStoreSales.transactionId }).from(inStoreSales)\n\t * );\n\t * // or\n\t * import { unionAll } from 'drizzle-orm/gel-core'\n\t *\n\t * await unionAll(\n\t * db.select({ transaction: onlineSales.transactionId }).from(onlineSales),\n\t * db.select({ transaction: inStoreSales.transactionId }).from(inStoreSales)\n\t * );\n\t * ```\n\t */\n\tunionAll = this.createSetOperator('union', true);\n\n\t/**\n\t * Adds `intersect` set operator to the query.\n\t *\n\t * Calling this method will retain only the rows that are present in both result sets and eliminate duplicates.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/set-operations#intersect}\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Select course names that are offered in both departments A and B\n\t * await db.select({ courseName: depA.courseName })\n\t * .from(depA)\n\t * .intersect(\n\t * db.select({ courseName: depB.courseName }).from(depB)\n\t * );\n\t * // or\n\t * import { intersect } from 'drizzle-orm/gel-core'\n\t *\n\t * await intersect(\n\t * db.select({ courseName: depA.courseName }).from(depA),\n\t * db.select({ courseName: depB.courseName }).from(depB)\n\t * );\n\t * ```\n\t */\n\tintersect = this.createSetOperator('intersect', false);\n\n\t/**\n\t * Adds `intersect all` set operator to the query.\n\t *\n\t * Calling this method will retain only the rows that are present in both result sets including all duplicates.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/set-operations#intersect-all}\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Select all products and quantities that are ordered by both regular and VIP customers\n\t * await db.select({\n\t * productId: regularCustomerOrders.productId,\n\t * quantityOrdered: regularCustomerOrders.quantityOrdered\n\t * })\n\t * .from(regularCustomerOrders)\n\t * .intersectAll(\n\t * db.select({\n\t * productId: vipCustomerOrders.productId,\n\t * quantityOrdered: vipCustomerOrders.quantityOrdered\n\t * })\n\t * .from(vipCustomerOrders)\n\t * );\n\t * // or\n\t * import { intersectAll } from 'drizzle-orm/gel-core'\n\t *\n\t * await intersectAll(\n\t * db.select({\n\t * productId: regularCustomerOrders.productId,\n\t * quantityOrdered: regularCustomerOrders.quantityOrdered\n\t * })\n\t * .from(regularCustomerOrders),\n\t * db.select({\n\t * productId: vipCustomerOrders.productId,\n\t * quantityOrdered: vipCustomerOrders.quantityOrdered\n\t * })\n\t * .from(vipCustomerOrders)\n\t * );\n\t * ```\n\t */\n\tintersectAll = this.createSetOperator('intersect', true);\n\n\t/**\n\t * Adds `except` set operator to the query.\n\t *\n\t * Calling this method will retrieve all unique rows from the left query, except for the rows that are present in the result set of the right query.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/set-operations#except}\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Select all courses offered in department A but not in department B\n\t * await db.select({ courseName: depA.courseName })\n\t * .from(depA)\n\t * .except(\n\t * db.select({ courseName: depB.courseName }).from(depB)\n\t * );\n\t * // or\n\t * import { except } from 'drizzle-orm/gel-core'\n\t *\n\t * await except(\n\t * db.select({ courseName: depA.courseName }).from(depA),\n\t * db.select({ courseName: depB.courseName }).from(depB)\n\t * );\n\t * ```\n\t */\n\texcept = this.createSetOperator('except', false);\n\n\t/**\n\t * Adds `except all` set operator to the query.\n\t *\n\t * Calling this method will retrieve all rows from the left query, except for the rows that are present in the result set of the right query.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/set-operations#except-all}\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Select all products that are ordered by regular customers but not by VIP customers\n\t * await db.select({\n\t * productId: regularCustomerOrders.productId,\n\t * quantityOrdered: regularCustomerOrders.quantityOrdered,\n\t * })\n\t * .from(regularCustomerOrders)\n\t * .exceptAll(\n\t * db.select({\n\t * productId: vipCustomerOrders.productId,\n\t * quantityOrdered: vipCustomerOrders.quantityOrdered,\n\t * })\n\t * .from(vipCustomerOrders)\n\t * );\n\t * // or\n\t * import { exceptAll } from 'drizzle-orm/gel-core'\n\t *\n\t * await exceptAll(\n\t * db.select({\n\t * productId: regularCustomerOrders.productId,\n\t * quantityOrdered: regularCustomerOrders.quantityOrdered\n\t * })\n\t * .from(regularCustomerOrders),\n\t * db.select({\n\t * productId: vipCustomerOrders.productId,\n\t * quantityOrdered: vipCustomerOrders.quantityOrdered\n\t * })\n\t * .from(vipCustomerOrders)\n\t * );\n\t * ```\n\t */\n\texceptAll = this.createSetOperator('except', true);\n\n\t/** @internal */\n\taddSetOperators(setOperators: GelSelectConfig['setOperators']): GelSelectWithout<\n\t\tthis,\n\t\tTDynamic,\n\t\tGelSetOperatorExcludedMethods,\n\t\ttrue\n\t> {\n\t\tthis.config.setOperators.push(...setOperators);\n\t\treturn this as any;\n\t}\n\n\t/**\n\t * Adds a `where` clause to the query.\n\t *\n\t * Calling this method will select only those rows that fulfill a specified condition.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/select#filtering}\n\t *\n\t * @param where the `where` clause.\n\t *\n\t * @example\n\t * You can use conditional operators and `sql function` to filter the rows to be selected.\n\t *\n\t * ```ts\n\t * // Select all cars with green color\n\t * await db.select().from(cars).where(eq(cars.color, 'green'));\n\t * // or\n\t * await db.select().from(cars).where(sql`${cars.color} = 'green'`)\n\t * ```\n\t *\n\t * You can logically combine conditional operators with `and()` and `or()` operators:\n\t *\n\t * ```ts\n\t * // Select all BMW cars with a green color\n\t * await db.select().from(cars).where(and(eq(cars.color, 'green'), eq(cars.brand, 'BMW')));\n\t *\n\t * // Select all cars with the green or blue color\n\t * await db.select().from(cars).where(or(eq(cars.color, 'green'), eq(cars.color, 'blue')));\n\t * ```\n\t */\n\twhere(\n\t\twhere: ((aliases: this['_']['selection']) => SQL | undefined) | SQL | undefined,\n\t): GelSelectWithout<this, TDynamic, 'where'> {\n\t\tif (typeof where === 'function') {\n\t\t\twhere = where(\n\t\t\t\tnew Proxy(\n\t\t\t\t\tthis.config.fields,\n\t\t\t\t\tnew SelectionProxyHandler({ sqlAliasedBehavior: 'sql', sqlBehavior: 'sql' }),\n\t\t\t\t) as TSelection,\n\t\t\t);\n\t\t}\n\t\tthis.config.where = where;\n\t\treturn this as any;\n\t}\n\n\t/**\n\t * Adds a `having` clause to the query.\n\t *\n\t * Calling this method will select only those rows that fulfill a specified condition. It is typically used with aggregate functions to filter the aggregated data based on a specified condition.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/select#aggregations}\n\t *\n\t * @param having the `having` clause.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Select all brands with more than one car\n\t * await db.select({\n\t * \tbrand: cars.brand,\n\t * \tcount: sql<number>`cast(count(${cars.id}) as int)`,\n\t * })\n\t * .from(cars)\n\t * .groupBy(cars.brand)\n\t * .having(({ count }) => gt(count, 1));\n\t * ```\n\t */\n\thaving(\n\t\thaving: ((aliases: this['_']['selection']) => SQL | undefined) | SQL | undefined,\n\t): GelSelectWithout<this, TDynamic, 'having'> {\n\t\tif (typeof having === 'function') {\n\t\t\thaving = having(\n\t\t\t\tnew Proxy(\n\t\t\t\t\tthis.config.fields,\n\t\t\t\t\tnew SelectionProxyHandler({ sqlAliasedBehavior: 'sql', sqlBehavior: 'sql' }),\n\t\t\t\t) as TSelection,\n\t\t\t);\n\t\t}\n\t\tthis.config.having = having;\n\t\treturn this as any;\n\t}\n\n\t/**\n\t * Adds a `group by` clause to the query.\n\t *\n\t * Calling this method will group rows that have the same values into summary rows, often used for aggregation purposes.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/select#aggregations}\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Group and count people by their last names\n\t * await db.select({\n\t * lastName: people.lastName,\n\t * count: sql<number>`cast(count(*) as int)`\n\t * })\n\t * .from(people)\n\t * .groupBy(people.lastName);\n\t * ```\n\t */\n\tgroupBy(\n\t\tbuilder: (aliases: this['_']['selection']) => ValueOrArray<GelColumn | SQL | SQL.Aliased>,\n\t): GelSelectWithout<this, TDynamic, 'groupBy'>;\n\tgroupBy(...columns: (GelColumn | SQL | SQL.Aliased)[]): GelSelectWithout<this, TDynamic, 'groupBy'>;\n\tgroupBy(\n\t\t...columns:\n\t\t\t| [(aliases: this['_']['selection']) => ValueOrArray<GelColumn | SQL | SQL.Aliased>]\n\t\t\t| (GelColumn | SQL | SQL.Aliased)[]\n\t): GelSelectWithout<this, TDynamic, 'groupBy'> {\n\t\tif (typeof columns[0] === 'function') {\n\t\t\tconst groupBy = columns[0](\n\t\t\t\tnew Proxy(\n\t\t\t\t\tthis.config.fields,\n\t\t\t\t\tnew SelectionProxyHandler({ sqlAliasedBehavior: 'alias', sqlBehavior: 'sql' }),\n\t\t\t\t) as TSelection,\n\t\t\t);\n\t\t\tthis.config.groupBy = Array.isArray(groupBy) ? groupBy : [groupBy];\n\t\t} else {\n\t\t\tthis.config.groupBy = columns as (GelColumn | SQL | SQL.Aliased)[];\n\t\t}\n\t\treturn this as any;\n\t}\n\n\t/**\n\t * Adds an `order by` clause to the query.\n\t *\n\t * Calling this method will sort the result-set in ascending or descending order. By default, the sort order is ascending.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/select#order-by}\n\t *\n\t * @example\n\t *\n\t * ```\n\t * // Select cars ordered by year\n\t * await db.select().from(cars).orderBy(cars.year);\n\t * ```\n\t *\n\t * You can specify whether results are in ascending or descending order with the `asc()` and `desc()` operators.\n\t *\n\t * ```ts\n\t * // Select cars ordered by year in descending order\n\t * await db.select().from(cars).orderBy(desc(cars.year));\n\t *\n\t * // Select cars ordered by year and price\n\t * await db.select().from(cars).orderBy(asc(cars.year), desc(cars.price));\n\t * ```\n\t */\n\torderBy(\n\t\tbuilder: (aliases: this['_']['selection']) => ValueOrArray<GelColumn | SQL | SQL.Aliased>,\n\t): GelSelectWithout<this, TDynamic, 'orderBy'>;\n\torderBy(...columns: (GelColumn | SQL | SQL.Aliased)[]): GelSelectWithout<this, TDynamic, 'orderBy'>;\n\torderBy(\n\t\t...columns:\n\t\t\t| [(aliases: this['_']['selection']) => ValueOrArray<GelColumn | SQL | SQL.Aliased>]\n\t\t\t| (GelColumn | SQL | SQL.Aliased)[]\n\t): GelSelectWithout<this, TDynamic, 'orderBy'> {\n\t\tif (typeof columns[0] === 'function') {\n\t\t\tconst orderBy = columns[0](\n\t\t\t\tnew Proxy(\n\t\t\t\t\tthis.config.fields,\n\t\t\t\t\tnew SelectionProxyHandler({ sqlAliasedBehavior: 'alias', sqlBehavior: 'sql' }),\n\t\t\t\t) as TSelection,\n\t\t\t);\n\n\t\t\tconst orderByArray = Array.isArray(orderBy) ? orderBy : [orderBy];\n\n\t\t\tif (this.config.setOperators.length > 0) {\n\t\t\t\tthis.config.setOperators.at(-1)!.orderBy = orderByArray;\n\t\t\t} else {\n\t\t\t\tthis.config.orderBy = orderByArray;\n\t\t\t}\n\t\t} else {\n\t\t\tconst orderByArray = columns as (GelColumn | SQL | SQL.Aliased)[];\n\n\t\t\tif (this.config.setOperators.length > 0) {\n\t\t\t\tthis.config.setOperators.at(-1)!.orderBy = orderByArray;\n\t\t\t} else {\n\t\t\t\tthis.config.orderBy = orderByArray;\n\t\t\t}\n\t\t}\n\t\treturn this as any;\n\t}\n\n\t/**\n\t * Adds a `limit` clause to the query.\n\t *\n\t * Calling this method will set the maximum number of rows that will be returned by this query.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/select#limit--offset}\n\t *\n\t * @param limit the `limit` clause.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Get the first 10 people from this query.\n\t * await db.select().from(people).limit(10);\n\t * ```\n\t */\n\tlimit(limit: number | Placeholder): GelSelectWithout<this, TDynamic, 'limit'> {\n\t\tif (this.config.setOperators.length > 0) {\n\t\t\tthis.config.setOperators.at(-1)!.limit = limit;\n\t\t} else {\n\t\t\tthis.config.limit = limit;\n\t\t}\n\t\treturn this as any;\n\t}\n\n\t/**\n\t * Adds an `offset` clause to the query.\n\t *\n\t * Calling this method will skip a number of rows when returning results from this query.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/select#limit--offset}\n\t *\n\t * @param offset the `offset` clause.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Get the 10th-20th people from this query.\n\t * await db.select().from(people).offset(10).limit(10);\n\t * ```\n\t */\n\toffset(offset: number | Placeholder): GelSelectWithout<this, TDynamic, 'offset'> {\n\t\tif (this.config.setOperators.length > 0) {\n\t\t\tthis.config.setOperators.at(-1)!.offset = offset;\n\t\t} else {\n\t\t\tthis.config.offset = offset;\n\t\t}\n\t\treturn this as any;\n\t}\n\n\t/**\n\t * Adds a `for` clause to the query.\n\t *\n\t * Calling this method will specify a lock strength for this query that controls how strictly it acquires exclusive access to the rows being queried.\n\t *\n\t * See docs: {@link https://www.postgresql.org/docs/current/sql-select.html#SQL-FOR-UPDATE-SHARE}\n\t *\n\t * @param strength the lock strength.\n\t * @param config the lock configuration.\n\t */\n\tfor(strength: LockStrength, config: LockConfig = {}): GelSelectWithout<this, TDynamic, 'for'> {\n\t\tthis.config.lockingClause = { strength, config };\n\t\treturn this as any;\n\t}\n\n\t/** @internal */\n\tgetSQL(): SQL {\n\t\treturn this.dialect.buildSelectQuery(this.config);\n\t}\n\n\ttoSQL(): Query {\n\t\tconst { typings: _typings, ...rest } = this.dialect.sqlToQuery(this.getSQL());\n\t\treturn rest;\n\t}\n\n\tas<TAlias extends string>(\n\t\talias: TAlias,\n\t): SubqueryWithSelection<this['_']['selectedFields'], TAlias> {\n\t\treturn new Proxy(\n\t\t\tnew Subquery(this.getSQL(), this.config.fields, alias),\n\t\t\tnew SelectionProxyHandler({ alias, sqlAliasedBehavior: 'alias', sqlBehavior: 'error' }),\n\t\t) as SubqueryWithSelection<this['_']['selectedFields'], TAlias>;\n\t}\n\n\t/** @internal */\n\toverride getSelectedFields(): this['_']['selectedFields'] {\n\t\treturn new Proxy(\n\t\t\tthis.config.fields,\n\t\t\tnew SelectionProxyHandler({ alias: this.tableName, sqlAliasedBehavior: 'alias', sqlBehavior: 'error' }),\n\t\t) as this['_']['selectedFields'];\n\t}\n\n\t$dynamic(): GelSelectDynamic<this> {\n\t\treturn this;\n\t}\n}\n\nexport interface GelSelectBase<\n\tTTableName extends string | undefined,\n\tTSelection extends ColumnsSelection,\n\tTSelectMode extends SelectMode,\n\tTNullabilityMap extends Record<string, JoinNullability> = TTableName extends string ? Record<TTableName, 'not-null'>\n\t\t: {},\n\tTDynamic extends boolean = false,\n\tTExcludedMethods extends string = never,\n\tTResult extends any[] = SelectResult<TSelection, TSelectMode, TNullabilityMap>[],\n\tTSelectedFields extends ColumnsSelection = BuildSubquerySelection<TSelection, TNullabilityMap>,\n> extends\n\tGelSelectQueryBuilderBase<\n\t\tGelSelectHKT,\n\t\tTTableName,\n\t\tTSelection,\n\t\tTSelectMode,\n\t\tTNullabilityMap,\n\t\tTDynamic,\n\t\tTExcludedMethods,\n\t\tTResult,\n\t\tTSelectedFields\n\t>,\n\tQueryPromise<TResult>,\n\tSQLWrapper\n{}\n\nexport class GelSelectBase<\n\tTTableName extends string | undefined,\n\tTSelection extends ColumnsSelection,\n\tTSelectMode extends SelectMode,\n\tTNullabilityMap extends Record<string, JoinNullability> = TTableName extends string ? Record<TTableName, 'not-null'>\n\t\t: {},\n\tTDynamic extends boolean = false,\n\tTExcludedMethods extends string = never,\n\tTResult = SelectResult<TSelection, TSelectMode, TNullabilityMap>[],\n\tTSelectedFields = BuildSubquerySelection<TSelection, TNullabilityMap>,\n> extends GelSelectQueryBuilderBase<\n\tGelSelectHKT,\n\tTTableName,\n\tTSelection,\n\tTSelectMode,\n\tTNullabilityMap,\n\tTDynamic,\n\tTExcludedMethods,\n\tTResult,\n\tTSelectedFields\n> implements RunnableQuery<TResult, 'gel'>, SQLWrapper {\n\tstatic override readonly [entityKind]: string = 'GelSelect';\n\n\t/** @internal */\n\t_prepare(name?: string): GelSelectPrepare<this> {\n\t\tconst { session, config, dialect, joinsNotNullableMap } = this;\n\t\tif (!session) {\n\t\t\tthrow new Error('Cannot execute a query on a query builder. Please use a database instance instead.');\n\t\t}\n\t\treturn tracer.startActiveSpan('drizzle.prepareQuery', () => {\n\t\t\tconst fieldsList = orderSelectedFields<GelColumn>(config.fields);\n\t\t\tconst query = session.prepareQuery<\n\t\t\t\tPreparedQueryConfig & { execute: TResult }\n\t\t\t>(dialect.sqlToQuery(this.getSQL()), fieldsList, name, true);\n\t\t\tquery.joinsNotNullableMap = joinsNotNullableMap;\n\n\t\t\treturn query;\n\t\t});\n\t}\n\n\t/**\n\t * Create a prepared statement for this query. This allows\n\t * the database to remember this query for the given session\n\t * and call it by name, rather than specifying the full query.\n\t *\n\t * {@link https://www.postgresql.org/docs/current/sql-prepare.html | Postgres prepare documentation}\n\t */\n\tprepare(name: string): GelSelectPrepare<this> {\n\t\treturn this._prepare(name);\n\t}\n\n\texecute: ReturnType<this['prepare']>['execute'] = (placeholderValues) => {\n\t\treturn tracer.startActiveSpan('drizzle.operation', () => {\n\t\t\treturn this._prepare().execute(placeholderValues);\n\t\t});\n\t};\n}\n\napplyMixins(GelSelectBase, [QueryPromise]);\n\nfunction createSetOperator(type: SetOperator, isAll: boolean): GelCreateSetOperatorFn {\n\treturn (leftSelect, rightSelect, ...restSelects) => {\n\t\tconst setOperators = [rightSelect, ...restSelects].map((select) => ({\n\t\t\ttype,\n\t\t\tisAll,\n\t\t\trightSelect: select as AnyGelSelect,\n\t\t}));\n\n\t\tfor (const setOperator of setOperators) {\n\t\t\tif (!haveSameKeys((leftSelect as any).getSelectedFields(), setOperator.rightSelect.getSelectedFields())) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'Set operator error (union / intersect / except): selected fields are not the same or are in a different order',\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\treturn (leftSelect as AnyGelSelect).addSetOperators(setOperators) as any;\n\t};\n}\n\nconst getGelSetOperators = () => ({\n\tunion,\n\tunionAll,\n\tintersect,\n\tintersectAll,\n\texcept,\n\texceptAll,\n});\n\n/**\n * Adds `union` set operator to the query.\n *\n * Calling this method will combine the result sets of the `select` statements and remove any duplicate rows that appear across them.\n *\n * See docs: {@link https://orm.drizzle.team/docs/set-operations#union}\n *\n * @example\n *\n * ```ts\n * // Select all unique names from customers and users tables\n * import { union } from 'drizzle-orm/Gel-core'\n *\n * await union(\n * db.select({ name: users.name }).from(users),\n * db.select({ name: customers.name }).from(customers)\n * );\n * // or\n * await db.select({ name: users.name })\n * .from(users)\n * .union(\n * db.select({ name: customers.name }).from(customers)\n * );\n * ```\n */\nexport const union = createSetOperator('union', false);\n\n/**\n * Adds `union all` set operator to the query.\n *\n * Calling this method will combine the result-set of the `select` statements and keep all duplicate rows that appear across them.\n *\n * See docs: {@link https://orm.drizzle.team/docs/set-operations#union-all}\n *\n * @example\n *\n * ```ts\n * // Select all transaction ids from both online and in-store sales\n * import { unionAll } from 'drizzle-orm/Gel-core'\n *\n * await unionAll(\n * db.select({ transaction: onlineSales.transactionId }).from(onlineSales),\n * db.select({ transaction: inStoreSales.transactionId }).from(inStoreSales)\n * );\n * // or\n * await db.select({ transaction: onlineSales.transactionId })\n * .from(onlineSales)\n * .unionAll(\n * db.select({ transaction: inStoreSales.transactionId }).from(inStoreSales)\n * );\n * ```\n */\nexport const unionAll = createSetOperator('union', true);\n\n/**\n * Adds `intersect` set operator to the query.\n *\n * Calling this method will retain only the rows that are present in both result sets and eliminate duplicates.\n *\n * See docs: {@link https://orm.drizzle.team/docs/set-operations#intersect}\n *\n * @example\n *\n * ```ts\n * // Select course names that are offered in both departments A and B\n * import { intersect } from 'drizzle-orm/Gel-core'\n *\n * await intersect(\n * db.select({ courseName: depA.courseName }).from(depA),\n * db.select({ courseName: depB.courseName }).from(depB)\n * );\n * // or\n * await db.select({ courseName: depA.courseName })\n * .from(depA)\n * .intersect(\n * db.select({ courseName: depB.courseName }).from(depB)\n * );\n * ```\n */\nexport const intersect = createSetOperator('intersect', false);\n\n/**\n * Adds `intersect all` set operator to the query.\n *\n * Calling this method will retain only the rows that are present in both result sets including all duplicates.\n *\n * See docs: {@link https://orm.drizzle.team/docs/set-operations#intersect-all}\n *\n * @example\n *\n * ```ts\n * // Select all products and quantities that are ordered by both regular and VIP customers\n * import { intersectAll } from 'drizzle-orm/Gel-core'\n *\n * await intersectAll(\n * db.select({\n * productId: regularCustomerOrders.productId,\n * quantityOrdered: regularCustomerOrders.quantityOrdered\n * })\n * .from(regularCustomerOrders),\n * db.select({\n * productId: vipCustomerOrders.productId,\n * quantityOrdered: vipCustomerOrders.quantityOrdered\n * })\n * .from(vipCustomerOrders)\n * );\n * // or\n * await db.select({\n * productId: regularCustomerOrders.productId,\n * quantityOrdered: regularCustomerOrders.quantityOrdered\n * })\n * .from(regularCustomerOrders)\n * .intersectAll(\n * db.select({\n * productId: vipCustomerOrders.productId,\n * quantityOrdered: vipCustomerOrders.quantityOrdered\n * })\n * .from(vipCustomerOrders)\n * );\n * ```\n */\nexport const intersectAll = createSetOperator('intersect', true);\n\n/**\n * Adds `except` set operator to the query.\n *\n * Calling this method will retrieve all unique rows from the left query, except for the rows that are present in the result set of the right query.\n *\n * See docs: {@link https://orm.drizzle.team/docs/set-operations#except}\n *\n * @example\n *\n * ```ts\n * // Select all courses offered in department A but not in department B\n * import { except } from 'drizzle-orm/Gel-core'\n *\n * await except(\n * db.select({ courseName: depA.courseName }).from(depA),\n * db.select({ courseName: depB.courseName }).from(depB)\n * );\n * // or\n * await db.select({ courseName: depA.courseName })\n * .from(depA)\n * .except(\n * db.select({ courseName: depB.courseName }).from(depB)\n * );\n * ```\n */\nexport const except = createSetOperator('except', false);\n\n/**\n * Adds `except all` set operator to the query.\n *\n * Calling this method will retrieve all rows from the left query, except for the rows that are present in the result set of the right query.\n *\n * See docs: {@link https://orm.drizzle.team/docs/set-operations#except-all}\n *\n * @example\n *\n * ```ts\n * // Select all products that are ordered by regular customers but not by VIP customers\n * import { exceptAll } from 'drizzle-orm/Gel-core'\n *\n * await exceptAll(\n * db.select({\n * productId: regularCustomerOrders.productId,\n * quantityOrdered: regularCustomerOrders.quantityOrdered\n * })\n * .from(regularCustomerOrders),\n * db.select({\n * productId: vipCustomerOrders.productId,\n * quantityOrdered: vipCustomerOrders.quantityOrdered\n * })\n * .from(vipCustomerOrders)\n * );\n * // or\n * await db.select({\n * productId: regularCustomerOrders.productId,\n * quantityOrdered: regularCustomerOrders.quantityOrdered,\n * })\n * .from(regularCustomerOrders)\n * .exceptAll(\n * db.select({\n * productId: vipCustomerOrders.productId,\n * quantityOrdered: vipCustomerOrders.quantityOrdered,\n * })\n * .from(vipCustomerOrders)\n * );\n * ```\n */\nexport const exceptAll = createSetOperator('except', true);\n"],"mappings":"AAAA,SAAS,YAAY,UAAU;AAM/B,SAAS,mBAAmB;AAC5B,SAAS,yBAAyB;AAWlC,SAAS,oBAAoB;AAE7B,SAAS,6BAA6B;AACtC,SAAS,KAAK,YAAY;AAE1B,SAAS,gBAAgB;AACzB,SAAS,aAAa;AACtB,SAAS,cAAc;AACvB;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGM;AACP,SAAS,2BAA2B;AACpC,SAAS,sBAAsB;AAqBxB,MAAM,iBAGX;AAAA,EACD,QAAiB,UAAU,IAAY;AAAA,EAE/B;AAAA,EACA;AAAA,EACA;AAAA,EACA,WAAuB,CAAC;AAAA,EACxB;AAAA,EAIR,YACC,QASC;AACD,SAAK,SAAS,OAAO;AACrB,SAAK,UAAU,OAAO;AACtB,SAAK,UAAU,OAAO;AACtB,QAAI,OAAO,UAAU;AACpB,WAAK,WAAW,OAAO;AAAA,IACxB;AACA,SAAK,WAAW,OAAO;AAAA,EACxB;AAAA,EAEQ;AAAA;AAAA,EAER,SAAS,OAAuB;AAC/B,SAAK,YAAY;AACjB,WAAO;AAAA,EACR;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,KACC,QAM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A;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,QAAQ,MAAsC;AAC7C,WAAO,KAAK,SAAS,IAAI;AAAA,EAC1B;AAAA,EAEA,UAAkD,CAAC,sBAAsB;AACxE,WAAO,OAAO,gBAAgB,qBAAqB,MAAM;AACxD,aAAO,KAAK,SAAS,EAAE,QAAQ,iBAAiB;AAAA,IACjD,CAAC;AAAA,EACF;AACD;AAEA,YAAY,eAAe,CAAC,YAAY,CAAC;AAEzC,SAAS,kBAAkB,MAAmB,OAAwC;AACrF,SAAO,CAAC,YAAY,gBAAgB,gBAAgB;AACnD,UAAM,eAAe,CAAC,aAAa,GAAG,WAAW,EAAE,IAAI,CAAC,YAAY;AAAA,MACnE;AAAA,MACA;AAAA,MACA,aAAa;AAAA,IACd,EAAE;AAEF,eAAW,eAAe,cAAc;AACvC,UAAI,CAAC,aAAc,WAAmB,kBAAkB,GAAG,YAAY,YAAY,kBAAkB,CAAC,GAAG;AACxG,cAAM,IAAI;AAAA,UACT;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAEA,WAAQ,WAA4B,gBAAgB,YAAY;AAAA,EACjE;AACD;AAEA,MAAM,qBAAqB,OAAO;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AA2BO,MAAM,QAAQ,kBAAkB,SAAS,KAAK;AA2B9C,MAAM,WAAW,kBAAkB,SAAS,IAAI;AA2BhD,MAAM,YAAY,kBAAkB,aAAa,KAAK;AA0CtD,MAAM,eAAe,kBAAkB,aAAa,IAAI;AA2BxD,MAAM,SAAS,kBAAkB,UAAU,KAAK;AA0ChD,MAAM,YAAY,kBAAkB,UAAU,IAAI;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/gel-core/query-builders/select.ts"],"sourcesContent":["import type { CacheConfig, WithCacheConfig } from '~/cache/core/types.ts';\nimport { entityKind, is } from '~/entity.ts';\nimport type { GelColumn } from '~/gel-core/columns/index.ts';\nimport type { GelDialect } from '~/gel-core/dialect.ts';\nimport type { GelSession, PreparedQueryConfig } from '~/gel-core/session.ts';\nimport type { SubqueryWithSelection } from '~/gel-core/subquery.ts';\nimport type { GelTable } from '~/gel-core/table.ts';\nimport { GelViewBase } from '~/gel-core/view-base.ts';\nimport { TypedQueryBuilder } from '~/query-builders/query-builder.ts';\nimport type {\n\tBuildSubquerySelection,\n\tGetSelectTableName,\n\tGetSelectTableSelection,\n\tJoinNullability,\n\tJoinType,\n\tSelectMode,\n\tSelectResult,\n\tSetOperator,\n} from '~/query-builders/select.types.ts';\nimport { QueryPromise } from '~/query-promise.ts';\nimport type { RunnableQuery } from '~/runnable-query.ts';\nimport { SelectionProxyHandler } from '~/selection-proxy.ts';\nimport { SQL, View } from '~/sql/sql.ts';\nimport type { ColumnsSelection, Placeholder, Query, SQLWrapper } from '~/sql/sql.ts';\nimport { Subquery } from '~/subquery.ts';\nimport { Table } from '~/table.ts';\nimport { tracer } from '~/tracing.ts';\nimport {\n\tapplyMixins,\n\tgetTableColumns,\n\tgetTableLikeName,\n\thaveSameKeys,\n\ttype NeonAuthToken,\n\ttype ValueOrArray,\n} from '~/utils.ts';\nimport { orderSelectedFields } from '~/utils.ts';\nimport { ViewBaseConfig } from '~/view-common.ts';\nimport { extractUsedTable } from '../utils.ts';\nimport type {\n\tAnyGelSelect,\n\tCreateGelSelectFromBuilderMode,\n\tGelCreateSetOperatorFn,\n\tGelSelectConfig,\n\tGelSelectDynamic,\n\tGelSelectHKT,\n\tGelSelectHKTBase,\n\tGelSelectJoinFn,\n\tGelSelectPrepare,\n\tGelSelectWithout,\n\tGelSetOperatorExcludedMethods,\n\tGelSetOperatorWithResult,\n\tGetGelSetOperators,\n\tLockConfig,\n\tLockStrength,\n\tSelectedFields,\n\tSetOperatorRightSelect,\n} from './select.types.ts';\n\nexport class GelSelectBuilder<\n\tTSelection extends SelectedFields | undefined,\n\tTBuilderMode extends 'db' | 'qb' = 'db',\n> {\n\tstatic readonly [entityKind]: string = 'GelSelectBuilder';\n\n\tprivate fields: TSelection;\n\tprivate session: GelSession | undefined;\n\tprivate dialect: GelDialect;\n\tprivate withList: Subquery[] = [];\n\tprivate distinct: boolean | {\n\t\ton: (GelColumn | SQLWrapper)[];\n\t} | undefined;\n\n\tconstructor(\n\t\tconfig: {\n\t\t\tfields: TSelection;\n\t\t\tsession: GelSession | undefined;\n\t\t\tdialect: GelDialect;\n\t\t\twithList?: Subquery[];\n\t\t\tdistinct?: boolean | {\n\t\t\t\ton: (GelColumn | SQLWrapper)[];\n\t\t\t};\n\t\t},\n\t) {\n\t\tthis.fields = config.fields;\n\t\tthis.session = config.session;\n\t\tthis.dialect = config.dialect;\n\t\tif (config.withList) {\n\t\t\tthis.withList = config.withList;\n\t\t}\n\t\tthis.distinct = config.distinct;\n\t}\n\n\tprivate authToken?: NeonAuthToken;\n\t/** @internal */\n\tsetToken(token?: NeonAuthToken) {\n\t\tthis.authToken = token;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Specify the table, subquery, or other target that you're\n\t * building a select query against.\n\t *\n\t * {@link https://www.postgresql.org/docs/current/sql-select.html#SQL-FROM | Postgres from documentation}\n\t */\n\tfrom<TFrom extends GelTable | Subquery | GelViewBase | SQL>(\n\t\tsource: TFrom,\n\t): CreateGelSelectFromBuilderMode<\n\t\tTBuilderMode,\n\t\tGetSelectTableName<TFrom>,\n\t\tTSelection extends undefined ? GetSelectTableSelection<TFrom> : TSelection,\n\t\tTSelection extends undefined ? 'single' : 'partial'\n\t> {\n\t\tconst isPartialSelect = !!this.fields;\n\n\t\tlet fields: SelectedFields;\n\t\tif (this.fields) {\n\t\t\tfields = this.fields;\n\t\t} else if (is(source, Subquery)) {\n\t\t\t// This is required to use the proxy handler to get the correct field values from the subquery\n\t\t\tfields = Object.fromEntries(\n\t\t\t\tObject.keys(source._.selectedFields).map((\n\t\t\t\t\tkey,\n\t\t\t\t) => [key, source[key as unknown as keyof typeof source] as unknown as SelectedFields[string]]),\n\t\t\t);\n\t\t} else if (is(source, GelViewBase)) {\n\t\t\tfields = source[ViewBaseConfig].selectedFields as SelectedFields;\n\t\t} else if (is(source, SQL)) {\n\t\t\tfields = {};\n\t\t} else {\n\t\t\tfields = getTableColumns<GelTable>(source);\n\t\t}\n\n\t\treturn new GelSelectBase({\n\t\t\ttable: source,\n\t\t\tfields,\n\t\t\tisPartialSelect,\n\t\t\tsession: this.session,\n\t\t\tdialect: this.dialect,\n\t\t\twithList: this.withList,\n\t\t\tdistinct: this.distinct,\n\t\t}) as any;\n\t}\n}\n\nexport abstract class GelSelectQueryBuilderBase<\n\tTHKT extends GelSelectHKTBase,\n\tTTableName extends string | undefined,\n\tTSelection extends ColumnsSelection,\n\tTSelectMode extends SelectMode,\n\tTNullabilityMap extends Record<string, JoinNullability> = TTableName extends string ? Record<TTableName, 'not-null'>\n\t\t: {},\n\tTDynamic extends boolean = false,\n\tTExcludedMethods extends string = never,\n\tTResult extends any[] = SelectResult<TSelection, TSelectMode, TNullabilityMap>[],\n\tTSelectedFields extends ColumnsSelection = BuildSubquerySelection<TSelection, TNullabilityMap>,\n> extends TypedQueryBuilder<TSelectedFields, TResult> {\n\tstatic override readonly [entityKind]: string = 'GelSelectQueryBuilder';\n\n\toverride readonly _: {\n\t\treadonly dialect: 'gel';\n\t\treadonly hkt: THKT;\n\t\treadonly tableName: TTableName;\n\t\treadonly selection: TSelection;\n\t\treadonly selectMode: TSelectMode;\n\t\treadonly nullabilityMap: TNullabilityMap;\n\t\treadonly dynamic: TDynamic;\n\t\treadonly excludedMethods: TExcludedMethods;\n\t\treadonly result: TResult;\n\t\treadonly selectedFields: TSelectedFields;\n\t\treadonly config: GelSelectConfig;\n\t};\n\n\tprotected config: GelSelectConfig;\n\tprotected joinsNotNullableMap: Record<string, boolean>;\n\tprivate tableName: string | undefined;\n\tprivate isPartialSelect: boolean;\n\tprotected session: GelSession | undefined;\n\tprotected dialect: GelDialect;\n\tprotected cacheConfig?: WithCacheConfig = undefined;\n\tprotected usedTables: Set<string> = new Set();\n\n\tconstructor(\n\t\t{ table, fields, isPartialSelect, session, dialect, withList, distinct }: {\n\t\t\ttable: GelSelectConfig['table'];\n\t\t\tfields: GelSelectConfig['fields'];\n\t\t\tisPartialSelect: boolean;\n\t\t\tsession: GelSession | undefined;\n\t\t\tdialect: GelDialect;\n\t\t\twithList: Subquery[];\n\t\t\tdistinct: boolean | {\n\t\t\t\ton: (GelColumn | SQLWrapper)[];\n\t\t\t} | undefined;\n\t\t},\n\t) {\n\t\tsuper();\n\t\tthis.config = {\n\t\t\twithList,\n\t\t\ttable,\n\t\t\tfields: { ...fields },\n\t\t\tdistinct,\n\t\t\tsetOperators: [],\n\t\t};\n\t\tthis.isPartialSelect = isPartialSelect;\n\t\tthis.session = session;\n\t\tthis.dialect = dialect;\n\t\tthis._ = {\n\t\t\tselectedFields: fields as TSelectedFields,\n\t\t\tconfig: this.config,\n\t\t} as this['_'];\n\t\tthis.tableName = getTableLikeName(table);\n\t\tthis.joinsNotNullableMap = typeof this.tableName === 'string' ? { [this.tableName]: true } : {};\n\t\tfor (const item of extractUsedTable(table)) this.usedTables.add(item);\n\t}\n\n\t/** @internal */\n\tgetUsedTables() {\n\t\treturn [...this.usedTables];\n\t}\n\n\tprivate createJoin<\n\t\tTJoinType extends JoinType,\n\t\tTIsLateral extends (TJoinType extends 'full' | 'right' ? false : boolean),\n\t>(\n\t\tjoinType: TJoinType,\n\t\tlateral: TIsLateral,\n\t): GelSelectJoinFn<this, TDynamic, TJoinType, TIsLateral> {\n\t\treturn (\n\t\t\ttable: GelTable | Subquery | GelViewBase | SQL,\n\t\t\ton?: ((aliases: TSelection) => SQL | undefined) | SQL | undefined,\n\t\t) => {\n\t\t\tconst baseTableName = this.tableName;\n\t\t\tconst tableName = getTableLikeName(table);\n\n\t\t\tif (typeof tableName === 'string' && this.config.joins?.some((join) => join.alias === tableName)) {\n\t\t\t\tthrow new Error(`Alias \"${tableName}\" is already used in this query`);\n\t\t\t}\n\n\t\t\t// store all tables used in a query\n\t\t\tfor (const item of extractUsedTable(table)) this.usedTables.add(item);\n\n\t\t\tif (!this.isPartialSelect) {\n\t\t\t\t// If this is the first join and this is not a partial select and we're not selecting from raw SQL, \"move\" the fields from the main table to the nested object\n\t\t\t\tif (Object.keys(this.joinsNotNullableMap).length === 1 && typeof baseTableName === 'string') {\n\t\t\t\t\tthis.config.fields = {\n\t\t\t\t\t\t[baseTableName]: this.config.fields,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tif (typeof tableName === 'string' && !is(table, SQL)) {\n\t\t\t\t\tconst selection = is(table, Subquery)\n\t\t\t\t\t\t? table._.selectedFields\n\t\t\t\t\t\t: is(table, View)\n\t\t\t\t\t\t? table[ViewBaseConfig].selectedFields\n\t\t\t\t\t\t: table[Table.Symbol.Columns];\n\t\t\t\t\tthis.config.fields[tableName] = selection;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (typeof on === 'function') {\n\t\t\t\ton = on(\n\t\t\t\t\tnew Proxy(\n\t\t\t\t\t\tthis.config.fields,\n\t\t\t\t\t\tnew SelectionProxyHandler({ sqlAliasedBehavior: 'sql', sqlBehavior: 'sql' }),\n\t\t\t\t\t) as TSelection,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (!this.config.joins) {\n\t\t\t\tthis.config.joins = [];\n\t\t\t}\n\n\t\t\tthis.config.joins.push({ on, table, joinType, alias: tableName, lateral });\n\n\t\t\tif (typeof tableName === 'string') {\n\t\t\t\tswitch (joinType) {\n\t\t\t\t\tcase 'left': {\n\t\t\t\t\t\tthis.joinsNotNullableMap[tableName] = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase 'right': {\n\t\t\t\t\t\tthis.joinsNotNullableMap = Object.fromEntries(\n\t\t\t\t\t\t\tObject.entries(this.joinsNotNullableMap).map(([key]) => [key, false]),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.joinsNotNullableMap[tableName] = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase 'cross':\n\t\t\t\t\tcase 'inner': {\n\t\t\t\t\t\tthis.joinsNotNullableMap[tableName] = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase 'full': {\n\t\t\t\t\t\tthis.joinsNotNullableMap = Object.fromEntries(\n\t\t\t\t\t\t\tObject.entries(this.joinsNotNullableMap).map(([key]) => [key, false]),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.joinsNotNullableMap[tableName] = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn this as any;\n\t\t};\n\t}\n\n\t/**\n\t * Executes a `left join` operation by adding another table to the current query.\n\t *\n\t * Calling this method associates each row of the table with the corresponding row from the joined table, if a match is found. If no matching row exists, it sets all columns of the joined table to null.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/joins#left-join}\n\t *\n\t * @param table the table to join.\n\t * @param on the `on` clause.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Select all users and their pets\n\t * const usersWithPets: { user: User; pets: Pet | null; }[] = await db.select()\n\t * .from(users)\n\t * .leftJoin(pets, eq(users.id, pets.ownerId))\n\t *\n\t * // Select userId and petId\n\t * const usersIdsAndPetIds: { userId: number; petId: number | null; }[] = await db.select({\n\t * userId: users.id,\n\t * petId: pets.id,\n\t * })\n\t * .from(users)\n\t * .leftJoin(pets, eq(users.id, pets.ownerId))\n\t * ```\n\t */\n\tleftJoin = this.createJoin('left', false);\n\n\t/**\n\t * Executes a `left join lateral` operation by adding subquery to the current query.\n\t *\n\t * A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.\n\t *\n\t * Calling this method associates each row of the table with the corresponding row from the joined table, if a match is found. If no matching row exists, it sets all columns of the joined table to null.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/joins#left-join-lateral}\n\t *\n\t * @param table the subquery to join.\n\t * @param on the `on` clause.\n\t */\n\tleftJoinLateral = this.createJoin('left', true);\n\n\t/**\n\t * Executes a `right join` operation by adding another table to the current query.\n\t *\n\t * Calling this method associates each row of the joined table with the corresponding row from the main table, if a match is found. If no matching row exists, it sets all columns of the main table to null.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/joins#right-join}\n\t *\n\t * @param table the table to join.\n\t * @param on the `on` clause.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Select all users and their pets\n\t * const usersWithPets: { user: User | null; pets: Pet; }[] = await db.select()\n\t * .from(users)\n\t * .rightJoin(pets, eq(users.id, pets.ownerId))\n\t *\n\t * // Select userId and petId\n\t * const usersIdsAndPetIds: { userId: number | null; petId: number; }[] = await db.select({\n\t * userId: users.id,\n\t * petId: pets.id,\n\t * })\n\t * .from(users)\n\t * .rightJoin(pets, eq(users.id, pets.ownerId))\n\t * ```\n\t */\n\trightJoin = this.createJoin('right', false);\n\n\t/**\n\t * Executes an `inner join` operation, creating a new table by combining rows from two tables that have matching values.\n\t *\n\t * Calling this method retrieves rows that have corresponding entries in both joined tables. Rows without matching entries in either table are excluded, resulting in a table that includes only matching pairs.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/joins#inner-join}\n\t *\n\t * @param table the table to join.\n\t * @param on the `on` clause.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Select all users and their pets\n\t * const usersWithPets: { user: User; pets: Pet; }[] = await db.select()\n\t * .from(users)\n\t * .innerJoin(pets, eq(users.id, pets.ownerId))\n\t *\n\t * // Select userId and petId\n\t * const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({\n\t * userId: users.id,\n\t * petId: pets.id,\n\t * })\n\t * .from(users)\n\t * .innerJoin(pets, eq(users.id, pets.ownerId))\n\t * ```\n\t */\n\tinnerJoin = this.createJoin('inner', false);\n\n\t/**\n\t * Executes an `inner join lateral` operation, creating a new table by combining rows from two queries that have matching values.\n\t *\n\t * A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.\n\t *\n\t * Calling this method retrieves rows that have corresponding entries in both joined tables. Rows without matching entries in either table are excluded, resulting in a table that includes only matching pairs.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/joins#inner-join-lateral}\n\t *\n\t * @param table the subquery to join.\n\t * @param on the `on` clause.\n\t */\n\tinnerJoinLateral = this.createJoin('inner', true);\n\n\t/**\n\t * Executes a `full join` operation by combining rows from two tables into a new table.\n\t *\n\t * Calling this method retrieves all rows from both main and joined tables, merging rows with matching values and filling in `null` for non-matching columns.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/joins#full-join}\n\t *\n\t * @param table the table to join.\n\t * @param on the `on` clause.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Select all users and their pets\n\t * const usersWithPets: { user: User | null; pets: Pet | null; }[] = await db.select()\n\t * .from(users)\n\t * .fullJoin(pets, eq(users.id, pets.ownerId))\n\t *\n\t * // Select userId and petId\n\t * const usersIdsAndPetIds: { userId: number | null; petId: number | null; }[] = await db.select({\n\t * userId: users.id,\n\t * petId: pets.id,\n\t * })\n\t * .from(users)\n\t * .fullJoin(pets, eq(users.id, pets.ownerId))\n\t * ```\n\t */\n\tfullJoin = this.createJoin('full', false);\n\n\t/**\n\t * Executes a `cross join` operation by combining rows from two tables into a new table.\n\t *\n\t * Calling this method retrieves all rows from both main and joined tables, merging all rows from each table.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/joins#cross-join}\n\t *\n\t * @param table the table to join.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Select all users, each user with every pet\n\t * const usersWithPets: { user: User; pets: Pet; }[] = await db.select()\n\t * .from(users)\n\t * .crossJoin(pets)\n\t *\n\t * // Select userId and petId\n\t * const usersIdsAndPetIds: { userId: number; petId: number; }[] = await db.select({\n\t * userId: users.id,\n\t * petId: pets.id,\n\t * })\n\t * .from(users)\n\t * .crossJoin(pets)\n\t * ```\n\t */\n\tcrossJoin = this.createJoin('cross', false);\n\n\t/**\n\t * Executes a `cross join lateral` operation by combining rows from two queries into a new table.\n\t *\n\t * A `lateral` join allows the right-hand expression to refer to columns from the left-hand side.\n\t *\n\t * Calling this method retrieves all rows from both main and joined queries, merging all rows from each query.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/joins#cross-join-lateral}\n\t *\n\t * @param table the query to join.\n\t */\n\tcrossJoinLateral = this.createJoin('cross', true);\n\n\tprivate createSetOperator(\n\t\ttype: SetOperator,\n\t\tisAll: boolean,\n\t): <TValue extends GelSetOperatorWithResult<TResult>>(\n\t\trightSelection:\n\t\t\t| ((setOperators: GetGelSetOperators) => SetOperatorRightSelect<TValue, TResult>)\n\t\t\t| SetOperatorRightSelect<TValue, TResult>,\n\t) => GelSelectWithout<\n\t\tthis,\n\t\tTDynamic,\n\t\tGelSetOperatorExcludedMethods,\n\t\ttrue\n\t> {\n\t\treturn (rightSelection) => {\n\t\t\tconst rightSelect = (typeof rightSelection === 'function'\n\t\t\t\t? rightSelection(getGelSetOperators())\n\t\t\t\t: rightSelection) as TypedQueryBuilder<\n\t\t\t\t\tany,\n\t\t\t\t\tTResult\n\t\t\t\t>;\n\n\t\t\tif (!haveSameKeys(this.getSelectedFields(), rightSelect.getSelectedFields())) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'Set operator error (union / intersect / except): selected fields are not the same or are in a different order',\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tthis.config.setOperators.push({ type, isAll, rightSelect });\n\t\t\treturn this as any;\n\t\t};\n\t}\n\n\t/**\n\t * Adds `union` set operator to the query.\n\t *\n\t * Calling this method will combine the result sets of the `select` statements and remove any duplicate rows that appear across them.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/set-operations#union}\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Select all unique names from customers and users tables\n\t * await db.select({ name: users.name })\n\t * .from(users)\n\t * .union(\n\t * db.select({ name: customers.name }).from(customers)\n\t * );\n\t * // or\n\t * import { union } from 'drizzle-orm/gel-core'\n\t *\n\t * await union(\n\t * db.select({ name: users.name }).from(users),\n\t * db.select({ name: customers.name }).from(customers)\n\t * );\n\t * ```\n\t */\n\tunion = this.createSetOperator('union', false);\n\n\t/**\n\t * Adds `union all` set operator to the query.\n\t *\n\t * Calling this method will combine the result-set of the `select` statements and keep all duplicate rows that appear across them.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/set-operations#union-all}\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Select all transaction ids from both online and in-store sales\n\t * await db.select({ transaction: onlineSales.transactionId })\n\t * .from(onlineSales)\n\t * .unionAll(\n\t * db.select({ transaction: inStoreSales.transactionId }).from(inStoreSales)\n\t * );\n\t * // or\n\t * import { unionAll } from 'drizzle-orm/gel-core'\n\t *\n\t * await unionAll(\n\t * db.select({ transaction: onlineSales.transactionId }).from(onlineSales),\n\t * db.select({ transaction: inStoreSales.transactionId }).from(inStoreSales)\n\t * );\n\t * ```\n\t */\n\tunionAll = this.createSetOperator('union', true);\n\n\t/**\n\t * Adds `intersect` set operator to the query.\n\t *\n\t * Calling this method will retain only the rows that are present in both result sets and eliminate duplicates.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/set-operations#intersect}\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Select course names that are offered in both departments A and B\n\t * await db.select({ courseName: depA.courseName })\n\t * .from(depA)\n\t * .intersect(\n\t * db.select({ courseName: depB.courseName }).from(depB)\n\t * );\n\t * // or\n\t * import { intersect } from 'drizzle-orm/gel-core'\n\t *\n\t * await intersect(\n\t * db.select({ courseName: depA.courseName }).from(depA),\n\t * db.select({ courseName: depB.courseName }).from(depB)\n\t * );\n\t * ```\n\t */\n\tintersect = this.createSetOperator('intersect', false);\n\n\t/**\n\t * Adds `intersect all` set operator to the query.\n\t *\n\t * Calling this method will retain only the rows that are present in both result sets including all duplicates.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/set-operations#intersect-all}\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Select all products and quantities that are ordered by both regular and VIP customers\n\t * await db.select({\n\t * productId: regularCustomerOrders.productId,\n\t * quantityOrdered: regularCustomerOrders.quantityOrdered\n\t * })\n\t * .from(regularCustomerOrders)\n\t * .intersectAll(\n\t * db.select({\n\t * productId: vipCustomerOrders.productId,\n\t * quantityOrdered: vipCustomerOrders.quantityOrdered\n\t * })\n\t * .from(vipCustomerOrders)\n\t * );\n\t * // or\n\t * import { intersectAll } from 'drizzle-orm/gel-core'\n\t *\n\t * await intersectAll(\n\t * db.select({\n\t * productId: regularCustomerOrders.productId,\n\t * quantityOrdered: regularCustomerOrders.quantityOrdered\n\t * })\n\t * .from(regularCustomerOrders),\n\t * db.select({\n\t * productId: vipCustomerOrders.productId,\n\t * quantityOrdered: vipCustomerOrders.quantityOrdered\n\t * })\n\t * .from(vipCustomerOrders)\n\t * );\n\t * ```\n\t */\n\tintersectAll = this.createSetOperator('intersect', true);\n\n\t/**\n\t * Adds `except` set operator to the query.\n\t *\n\t * Calling this method will retrieve all unique rows from the left query, except for the rows that are present in the result set of the right query.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/set-operations#except}\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Select all courses offered in department A but not in department B\n\t * await db.select({ courseName: depA.courseName })\n\t * .from(depA)\n\t * .except(\n\t * db.select({ courseName: depB.courseName }).from(depB)\n\t * );\n\t * // or\n\t * import { except } from 'drizzle-orm/gel-core'\n\t *\n\t * await except(\n\t * db.select({ courseName: depA.courseName }).from(depA),\n\t * db.select({ courseName: depB.courseName }).from(depB)\n\t * );\n\t * ```\n\t */\n\texcept = this.createSetOperator('except', false);\n\n\t/**\n\t * Adds `except all` set operator to the query.\n\t *\n\t * Calling this method will retrieve all rows from the left query, except for the rows that are present in the result set of the right query.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/set-operations#except-all}\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Select all products that are ordered by regular customers but not by VIP customers\n\t * await db.select({\n\t * productId: regularCustomerOrders.productId,\n\t * quantityOrdered: regularCustomerOrders.quantityOrdered,\n\t * })\n\t * .from(regularCustomerOrders)\n\t * .exceptAll(\n\t * db.select({\n\t * productId: vipCustomerOrders.productId,\n\t * quantityOrdered: vipCustomerOrders.quantityOrdered,\n\t * })\n\t * .from(vipCustomerOrders)\n\t * );\n\t * // or\n\t * import { exceptAll } from 'drizzle-orm/gel-core'\n\t *\n\t * await exceptAll(\n\t * db.select({\n\t * productId: regularCustomerOrders.productId,\n\t * quantityOrdered: regularCustomerOrders.quantityOrdered\n\t * })\n\t * .from(regularCustomerOrders),\n\t * db.select({\n\t * productId: vipCustomerOrders.productId,\n\t * quantityOrdered: vipCustomerOrders.quantityOrdered\n\t * })\n\t * .from(vipCustomerOrders)\n\t * );\n\t * ```\n\t */\n\texceptAll = this.createSetOperator('except', true);\n\n\t/** @internal */\n\taddSetOperators(setOperators: GelSelectConfig['setOperators']): GelSelectWithout<\n\t\tthis,\n\t\tTDynamic,\n\t\tGelSetOperatorExcludedMethods,\n\t\ttrue\n\t> {\n\t\tthis.config.setOperators.push(...setOperators);\n\t\treturn this as any;\n\t}\n\n\t/**\n\t * Adds a `where` clause to the query.\n\t *\n\t * Calling this method will select only those rows that fulfill a specified condition.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/select#filtering}\n\t *\n\t * @param where the `where` clause.\n\t *\n\t * @example\n\t * You can use conditional operators and `sql function` to filter the rows to be selected.\n\t *\n\t * ```ts\n\t * // Select all cars with green color\n\t * await db.select().from(cars).where(eq(cars.color, 'green'));\n\t * // or\n\t * await db.select().from(cars).where(sql`${cars.color} = 'green'`)\n\t * ```\n\t *\n\t * You can logically combine conditional operators with `and()` and `or()` operators:\n\t *\n\t * ```ts\n\t * // Select all BMW cars with a green color\n\t * await db.select().from(cars).where(and(eq(cars.color, 'green'), eq(cars.brand, 'BMW')));\n\t *\n\t * // Select all cars with the green or blue color\n\t * await db.select().from(cars).where(or(eq(cars.color, 'green'), eq(cars.color, 'blue')));\n\t * ```\n\t */\n\twhere(\n\t\twhere: ((aliases: this['_']['selection']) => SQL | undefined) | SQL | undefined,\n\t): GelSelectWithout<this, TDynamic, 'where'> {\n\t\tif (typeof where === 'function') {\n\t\t\twhere = where(\n\t\t\t\tnew Proxy(\n\t\t\t\t\tthis.config.fields,\n\t\t\t\t\tnew SelectionProxyHandler({ sqlAliasedBehavior: 'sql', sqlBehavior: 'sql' }),\n\t\t\t\t) as TSelection,\n\t\t\t);\n\t\t}\n\t\tthis.config.where = where;\n\t\treturn this as any;\n\t}\n\n\t/**\n\t * Adds a `having` clause to the query.\n\t *\n\t * Calling this method will select only those rows that fulfill a specified condition. It is typically used with aggregate functions to filter the aggregated data based on a specified condition.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/select#aggregations}\n\t *\n\t * @param having the `having` clause.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Select all brands with more than one car\n\t * await db.select({\n\t * \tbrand: cars.brand,\n\t * \tcount: sql<number>`cast(count(${cars.id}) as int)`,\n\t * })\n\t * .from(cars)\n\t * .groupBy(cars.brand)\n\t * .having(({ count }) => gt(count, 1));\n\t * ```\n\t */\n\thaving(\n\t\thaving: ((aliases: this['_']['selection']) => SQL | undefined) | SQL | undefined,\n\t): GelSelectWithout<this, TDynamic, 'having'> {\n\t\tif (typeof having === 'function') {\n\t\t\thaving = having(\n\t\t\t\tnew Proxy(\n\t\t\t\t\tthis.config.fields,\n\t\t\t\t\tnew SelectionProxyHandler({ sqlAliasedBehavior: 'sql', sqlBehavior: 'sql' }),\n\t\t\t\t) as TSelection,\n\t\t\t);\n\t\t}\n\t\tthis.config.having = having;\n\t\treturn this as any;\n\t}\n\n\t/**\n\t * Adds a `group by` clause to the query.\n\t *\n\t * Calling this method will group rows that have the same values into summary rows, often used for aggregation purposes.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/select#aggregations}\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Group and count people by their last names\n\t * await db.select({\n\t * lastName: people.lastName,\n\t * count: sql<number>`cast(count(*) as int)`\n\t * })\n\t * .from(people)\n\t * .groupBy(people.lastName);\n\t * ```\n\t */\n\tgroupBy(\n\t\tbuilder: (aliases: this['_']['selection']) => ValueOrArray<GelColumn | SQL | SQL.Aliased>,\n\t): GelSelectWithout<this, TDynamic, 'groupBy'>;\n\tgroupBy(...columns: (GelColumn | SQL | SQL.Aliased)[]): GelSelectWithout<this, TDynamic, 'groupBy'>;\n\tgroupBy(\n\t\t...columns:\n\t\t\t| [(aliases: this['_']['selection']) => ValueOrArray<GelColumn | SQL | SQL.Aliased>]\n\t\t\t| (GelColumn | SQL | SQL.Aliased)[]\n\t): GelSelectWithout<this, TDynamic, 'groupBy'> {\n\t\tif (typeof columns[0] === 'function') {\n\t\t\tconst groupBy = columns[0](\n\t\t\t\tnew Proxy(\n\t\t\t\t\tthis.config.fields,\n\t\t\t\t\tnew SelectionProxyHandler({ sqlAliasedBehavior: 'alias', sqlBehavior: 'sql' }),\n\t\t\t\t) as TSelection,\n\t\t\t);\n\t\t\tthis.config.groupBy = Array.isArray(groupBy) ? groupBy : [groupBy];\n\t\t} else {\n\t\t\tthis.config.groupBy = columns as (GelColumn | SQL | SQL.Aliased)[];\n\t\t}\n\t\treturn this as any;\n\t}\n\n\t/**\n\t * Adds an `order by` clause to the query.\n\t *\n\t * Calling this method will sort the result-set in ascending or descending order. By default, the sort order is ascending.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/select#order-by}\n\t *\n\t * @example\n\t *\n\t * ```\n\t * // Select cars ordered by year\n\t * await db.select().from(cars).orderBy(cars.year);\n\t * ```\n\t *\n\t * You can specify whether results are in ascending or descending order with the `asc()` and `desc()` operators.\n\t *\n\t * ```ts\n\t * // Select cars ordered by year in descending order\n\t * await db.select().from(cars).orderBy(desc(cars.year));\n\t *\n\t * // Select cars ordered by year and price\n\t * await db.select().from(cars).orderBy(asc(cars.year), desc(cars.price));\n\t * ```\n\t */\n\torderBy(\n\t\tbuilder: (aliases: this['_']['selection']) => ValueOrArray<GelColumn | SQL | SQL.Aliased>,\n\t): GelSelectWithout<this, TDynamic, 'orderBy'>;\n\torderBy(...columns: (GelColumn | SQL | SQL.Aliased)[]): GelSelectWithout<this, TDynamic, 'orderBy'>;\n\torderBy(\n\t\t...columns:\n\t\t\t| [(aliases: this['_']['selection']) => ValueOrArray<GelColumn | SQL | SQL.Aliased>]\n\t\t\t| (GelColumn | SQL | SQL.Aliased)[]\n\t): GelSelectWithout<this, TDynamic, 'orderBy'> {\n\t\tif (typeof columns[0] === 'function') {\n\t\t\tconst orderBy = columns[0](\n\t\t\t\tnew Proxy(\n\t\t\t\t\tthis.config.fields,\n\t\t\t\t\tnew SelectionProxyHandler({ sqlAliasedBehavior: 'alias', sqlBehavior: 'sql' }),\n\t\t\t\t) as TSelection,\n\t\t\t);\n\n\t\t\tconst orderByArray = Array.isArray(orderBy) ? orderBy : [orderBy];\n\n\t\t\tif (this.config.setOperators.length > 0) {\n\t\t\t\tthis.config.setOperators.at(-1)!.orderBy = orderByArray;\n\t\t\t} else {\n\t\t\t\tthis.config.orderBy = orderByArray;\n\t\t\t}\n\t\t} else {\n\t\t\tconst orderByArray = columns as (GelColumn | SQL | SQL.Aliased)[];\n\n\t\t\tif (this.config.setOperators.length > 0) {\n\t\t\t\tthis.config.setOperators.at(-1)!.orderBy = orderByArray;\n\t\t\t} else {\n\t\t\t\tthis.config.orderBy = orderByArray;\n\t\t\t}\n\t\t}\n\t\treturn this as any;\n\t}\n\n\t/**\n\t * Adds a `limit` clause to the query.\n\t *\n\t * Calling this method will set the maximum number of rows that will be returned by this query.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/select#limit--offset}\n\t *\n\t * @param limit the `limit` clause.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Get the first 10 people from this query.\n\t * await db.select().from(people).limit(10);\n\t * ```\n\t */\n\tlimit(limit: number | Placeholder): GelSelectWithout<this, TDynamic, 'limit'> {\n\t\tif (this.config.setOperators.length > 0) {\n\t\t\tthis.config.setOperators.at(-1)!.limit = limit;\n\t\t} else {\n\t\t\tthis.config.limit = limit;\n\t\t}\n\t\treturn this as any;\n\t}\n\n\t/**\n\t * Adds an `offset` clause to the query.\n\t *\n\t * Calling this method will skip a number of rows when returning results from this query.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/select#limit--offset}\n\t *\n\t * @param offset the `offset` clause.\n\t *\n\t * @example\n\t *\n\t * ```ts\n\t * // Get the 10th-20th people from this query.\n\t * await db.select().from(people).offset(10).limit(10);\n\t * ```\n\t */\n\toffset(offset: number | Placeholder): GelSelectWithout<this, TDynamic, 'offset'> {\n\t\tif (this.config.setOperators.length > 0) {\n\t\t\tthis.config.setOperators.at(-1)!.offset = offset;\n\t\t} else {\n\t\t\tthis.config.offset = offset;\n\t\t}\n\t\treturn this as any;\n\t}\n\n\t/**\n\t * Adds a `for` clause to the query.\n\t *\n\t * Calling this method will specify a lock strength for this query that controls how strictly it acquires exclusive access to the rows being queried.\n\t *\n\t * See docs: {@link https://www.postgresql.org/docs/current/sql-select.html#SQL-FOR-UPDATE-SHARE}\n\t *\n\t * @param strength the lock strength.\n\t * @param config the lock configuration.\n\t */\n\tfor(strength: LockStrength, config: LockConfig = {}): GelSelectWithout<this, TDynamic, 'for'> {\n\t\tthis.config.lockingClause = { strength, config };\n\t\treturn this as any;\n\t}\n\n\t/** @internal */\n\tgetSQL(): SQL {\n\t\treturn this.dialect.buildSelectQuery(this.config);\n\t}\n\n\ttoSQL(): Query {\n\t\tconst { typings: _typings, ...rest } = this.dialect.sqlToQuery(this.getSQL());\n\t\treturn rest;\n\t}\n\n\tas<TAlias extends string>(\n\t\talias: TAlias,\n\t): SubqueryWithSelection<this['_']['selectedFields'], TAlias> {\n\t\tconst usedTables: string[] = [];\n\t\tusedTables.push(...extractUsedTable(this.config.table));\n\t\tif (this.config.joins) { for (const it of this.config.joins) usedTables.push(...extractUsedTable(it.table)); }\n\n\t\treturn new Proxy(\n\t\t\tnew Subquery(this.getSQL(), this.config.fields, alias, false, [...new Set(usedTables)]),\n\t\t\tnew SelectionProxyHandler({ alias, sqlAliasedBehavior: 'alias', sqlBehavior: 'error' }),\n\t\t) as SubqueryWithSelection<this['_']['selectedFields'], TAlias>;\n\t}\n\n\t/** @internal */\n\toverride getSelectedFields(): this['_']['selectedFields'] {\n\t\treturn new Proxy(\n\t\t\tthis.config.fields,\n\t\t\tnew SelectionProxyHandler({ alias: this.tableName, sqlAliasedBehavior: 'alias', sqlBehavior: 'error' }),\n\t\t) as this['_']['selectedFields'];\n\t}\n\n\t$dynamic(): GelSelectDynamic<this> {\n\t\treturn this;\n\t}\n}\n\nexport interface GelSelectBase<\n\tTTableName extends string | undefined,\n\tTSelection extends ColumnsSelection,\n\tTSelectMode extends SelectMode,\n\tTNullabilityMap extends Record<string, JoinNullability> = TTableName extends string ? Record<TTableName, 'not-null'>\n\t\t: {},\n\tTDynamic extends boolean = false,\n\tTExcludedMethods extends string = never,\n\tTResult extends any[] = SelectResult<TSelection, TSelectMode, TNullabilityMap>[],\n\tTSelectedFields extends ColumnsSelection = BuildSubquerySelection<TSelection, TNullabilityMap>,\n> extends\n\tGelSelectQueryBuilderBase<\n\t\tGelSelectHKT,\n\t\tTTableName,\n\t\tTSelection,\n\t\tTSelectMode,\n\t\tTNullabilityMap,\n\t\tTDynamic,\n\t\tTExcludedMethods,\n\t\tTResult,\n\t\tTSelectedFields\n\t>,\n\tQueryPromise<TResult>,\n\tSQLWrapper\n{}\n\nexport class GelSelectBase<\n\tTTableName extends string | undefined,\n\tTSelection extends ColumnsSelection,\n\tTSelectMode extends SelectMode,\n\tTNullabilityMap extends Record<string, JoinNullability> = TTableName extends string ? Record<TTableName, 'not-null'>\n\t\t: {},\n\tTDynamic extends boolean = false,\n\tTExcludedMethods extends string = never,\n\tTResult = SelectResult<TSelection, TSelectMode, TNullabilityMap>[],\n\tTSelectedFields = BuildSubquerySelection<TSelection, TNullabilityMap>,\n> extends GelSelectQueryBuilderBase<\n\tGelSelectHKT,\n\tTTableName,\n\tTSelection,\n\tTSelectMode,\n\tTNullabilityMap,\n\tTDynamic,\n\tTExcludedMethods,\n\tTResult,\n\tTSelectedFields\n> implements RunnableQuery<TResult, 'gel'>, SQLWrapper {\n\tstatic override readonly [entityKind]: string = 'GelSelect';\n\n\t/** @internal */\n\t_prepare(name?: string): GelSelectPrepare<this> {\n\t\tconst { session, config, dialect, joinsNotNullableMap, cacheConfig, usedTables } = this;\n\t\tif (!session) {\n\t\t\tthrow new Error('Cannot execute a query on a query builder. Please use a database instance instead.');\n\t\t}\n\t\treturn tracer.startActiveSpan('drizzle.prepareQuery', () => {\n\t\t\tconst fieldsList = orderSelectedFields<GelColumn>(config.fields);\n\t\t\tconst query = session.prepareQuery<\n\t\t\t\tPreparedQueryConfig & { execute: TResult }\n\t\t\t>(dialect.sqlToQuery(this.getSQL()), fieldsList, name, true, undefined, {\n\t\t\t\ttype: 'select',\n\t\t\t\ttables: [...usedTables],\n\t\t\t}, cacheConfig);\n\t\t\tquery.joinsNotNullableMap = joinsNotNullableMap;\n\n\t\t\treturn query;\n\t\t});\n\t}\n\n\t$withCache(config?: { config?: CacheConfig; tag?: string; autoInvalidate?: boolean } | false) {\n\t\tthis.cacheConfig = config === undefined\n\t\t\t? { config: {}, enable: true, autoInvalidate: true }\n\t\t\t: config === false\n\t\t\t? { enable: false }\n\t\t\t: { enable: true, autoInvalidate: true, ...config };\n\t\treturn this;\n\t}\n\n\t/**\n\t * Create a prepared statement for this query. This allows\n\t * the database to remember this query for the given session\n\t * and call it by name, rather than specifying the full query.\n\t *\n\t * {@link https://www.postgresql.org/docs/current/sql-prepare.html | Postgres prepare documentation}\n\t */\n\tprepare(name: string): GelSelectPrepare<this> {\n\t\treturn this._prepare(name);\n\t}\n\n\texecute: ReturnType<this['prepare']>['execute'] = (placeholderValues) => {\n\t\treturn tracer.startActiveSpan('drizzle.operation', () => {\n\t\t\treturn this._prepare().execute(placeholderValues);\n\t\t});\n\t};\n}\n\napplyMixins(GelSelectBase, [QueryPromise]);\n\nfunction createSetOperator(type: SetOperator, isAll: boolean): GelCreateSetOperatorFn {\n\treturn (leftSelect, rightSelect, ...restSelects) => {\n\t\tconst setOperators = [rightSelect, ...restSelects].map((select) => ({\n\t\t\ttype,\n\t\t\tisAll,\n\t\t\trightSelect: select as AnyGelSelect,\n\t\t}));\n\n\t\tfor (const setOperator of setOperators) {\n\t\t\tif (!haveSameKeys((leftSelect as any).getSelectedFields(), setOperator.rightSelect.getSelectedFields())) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'Set operator error (union / intersect / except): selected fields are not the same or are in a different order',\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\treturn (leftSelect as AnyGelSelect).addSetOperators(setOperators) as any;\n\t};\n}\n\nconst getGelSetOperators = () => ({\n\tunion,\n\tunionAll,\n\tintersect,\n\tintersectAll,\n\texcept,\n\texceptAll,\n});\n\n/**\n * Adds `union` set operator to the query.\n *\n * Calling this method will combine the result sets of the `select` statements and remove any duplicate rows that appear across them.\n *\n * See docs: {@link https://orm.drizzle.team/docs/set-operations#union}\n *\n * @example\n *\n * ```ts\n * // Select all unique names from customers and users tables\n * import { union } from 'drizzle-orm/Gel-core'\n *\n * await union(\n * db.select({ name: users.name }).from(users),\n * db.select({ name: customers.name }).from(customers)\n * );\n * // or\n * await db.select({ name: users.name })\n * .from(users)\n * .union(\n * db.select({ name: customers.name }).from(customers)\n * );\n * ```\n */\nexport const union = createSetOperator('union', false);\n\n/**\n * Adds `union all` set operator to the query.\n *\n * Calling this method will combine the result-set of the `select` statements and keep all duplicate rows that appear across them.\n *\n * See docs: {@link https://orm.drizzle.team/docs/set-operations#union-all}\n *\n * @example\n *\n * ```ts\n * // Select all transaction ids from both online and in-store sales\n * import { unionAll } from 'drizzle-orm/Gel-core'\n *\n * await unionAll(\n * db.select({ transaction: onlineSales.transactionId }).from(onlineSales),\n * db.select({ transaction: inStoreSales.transactionId }).from(inStoreSales)\n * );\n * // or\n * await db.select({ transaction: onlineSales.transactionId })\n * .from(onlineSales)\n * .unionAll(\n * db.select({ transaction: inStoreSales.transactionId }).from(inStoreSales)\n * );\n * ```\n */\nexport const unionAll = createSetOperator('union', true);\n\n/**\n * Adds `intersect` set operator to the query.\n *\n * Calling this method will retain only the rows that are present in both result sets and eliminate duplicates.\n *\n * See docs: {@link https://orm.drizzle.team/docs/set-operations#intersect}\n *\n * @example\n *\n * ```ts\n * // Select course names that are offered in both departments A and B\n * import { intersect } from 'drizzle-orm/Gel-core'\n *\n * await intersect(\n * db.select({ courseName: depA.courseName }).from(depA),\n * db.select({ courseName: depB.courseName }).from(depB)\n * );\n * // or\n * await db.select({ courseName: depA.courseName })\n * .from(depA)\n * .intersect(\n * db.select({ courseName: depB.courseName }).from(depB)\n * );\n * ```\n */\nexport const intersect = createSetOperator('intersect', false);\n\n/**\n * Adds `intersect all` set operator to the query.\n *\n * Calling this method will retain only the rows that are present in both result sets including all duplicates.\n *\n * See docs: {@link https://orm.drizzle.team/docs/set-operations#intersect-all}\n *\n * @example\n *\n * ```ts\n * // Select all products and quantities that are ordered by both regular and VIP customers\n * import { intersectAll } from 'drizzle-orm/Gel-core'\n *\n * await intersectAll(\n * db.select({\n * productId: regularCustomerOrders.productId,\n * quantityOrdered: regularCustomerOrders.quantityOrdered\n * })\n * .from(regularCustomerOrders),\n * db.select({\n * productId: vipCustomerOrders.productId,\n * quantityOrdered: vipCustomerOrders.quantityOrdered\n * })\n * .from(vipCustomerOrders)\n * );\n * // or\n * await db.select({\n * productId: regularCustomerOrders.productId,\n * quantityOrdered: regularCustomerOrders.quantityOrdered\n * })\n * .from(regularCustomerOrders)\n * .intersectAll(\n * db.select({\n * productId: vipCustomerOrders.productId,\n * quantityOrdered: vipCustomerOrders.quantityOrdered\n * })\n * .from(vipCustomerOrders)\n * );\n * ```\n */\nexport const intersectAll = createSetOperator('intersect', true);\n\n/**\n * Adds `except` set operator to the query.\n *\n * Calling this method will retrieve all unique rows from the left query, except for the rows that are present in the result set of the right query.\n *\n * See docs: {@link https://orm.drizzle.team/docs/set-operations#except}\n *\n * @example\n *\n * ```ts\n * // Select all courses offered in department A but not in department B\n * import { except } from 'drizzle-orm/Gel-core'\n *\n * await except(\n * db.select({ courseName: depA.courseName }).from(depA),\n * db.select({ courseName: depB.courseName }).from(depB)\n * );\n * // or\n * await db.select({ courseName: depA.courseName })\n * .from(depA)\n * .except(\n * db.select({ courseName: depB.courseName }).from(depB)\n * );\n * ```\n */\nexport const except = createSetOperator('except', false);\n\n/**\n * Adds `except all` set operator to the query.\n *\n * Calling this method will retrieve all rows from the left query, except for the rows that are present in the result set of the right query.\n *\n * See docs: {@link https://orm.drizzle.team/docs/set-operations#except-all}\n *\n * @example\n *\n * ```ts\n * // Select all products that are ordered by regular customers but not by VIP customers\n * import { exceptAll } from 'drizzle-orm/Gel-core'\n *\n * await exceptAll(\n * db.select({\n * productId: regularCustomerOrders.productId,\n * quantityOrdered: regularCustomerOrders.quantityOrdered\n * })\n * .from(regularCustomerOrders),\n * db.select({\n * productId: vipCustomerOrders.productId,\n * quantityOrdered: vipCustomerOrders.quantityOrdered\n * })\n * .from(vipCustomerOrders)\n * );\n * // or\n * await db.select({\n * productId: regularCustomerOrders.productId,\n * quantityOrdered: regularCustomerOrders.quantityOrdered,\n * })\n * .from(regularCustomerOrders)\n * .exceptAll(\n * db.select({\n * productId: vipCustomerOrders.productId,\n * quantityOrdered: vipCustomerOrders.quantityOrdered,\n * })\n * .from(vipCustomerOrders)\n * );\n * ```\n */\nexport const exceptAll = createSetOperator('except', true);\n"],"mappings":"AACA,SAAS,YAAY,UAAU;AAM/B,SAAS,mBAAmB;AAC5B,SAAS,yBAAyB;AAWlC,SAAS,oBAAoB;AAE7B,SAAS,6BAA6B;AACtC,SAAS,KAAK,YAAY;AAE1B,SAAS,gBAAgB;AACzB,SAAS,aAAa;AACtB,SAAS,cAAc;AACvB;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;A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var import_subquery = require("../../subquery.cjs");
|
|
|
31
31
|
var import_table2 = require("../../table.cjs");
|
|
32
32
|
var import_utils = require("../../utils.cjs");
|
|
33
33
|
var import_view_common = require("../../view-common.cjs");
|
|
34
|
+
var import_utils2 = require("../utils.cjs");
|
|
34
35
|
class GelUpdateBuilder {
|
|
35
36
|
constructor(table, session, dialect, withList) {
|
|
36
37
|
this.table = table;
|
|
@@ -204,7 +205,10 @@ class GelUpdateBase extends import_query_promise.QueryPromise {
|
|
|
204
205
|
}
|
|
205
206
|
/** @internal */
|
|
206
207
|
_prepare(name) {
|
|
207
|
-
const query = this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()), this.config.returning, name, true
|
|
208
|
+
const query = this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()), this.config.returning, name, true, void 0, {
|
|
209
|
+
type: "update",
|
|
210
|
+
tables: (0, import_utils2.extractUsedTable)(this.config.table)
|
|
211
|
+
});
|
|
208
212
|
query.joinsNotNullableMap = this.joinsNotNullableMap;
|
|
209
213
|
return query;
|
|
210
214
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/gel-core/query-builders/update.ts"],"sourcesContent":["import type { GetColumnData } from '~/column.ts';\nimport { entityKind, is } from '~/entity.ts';\nimport type { GelDialect } from '~/gel-core/dialect.ts';\nimport type {\n\tGelPreparedQuery,\n\tGelQueryResultHKT,\n\tGelQueryResultKind,\n\tGelSession,\n\tPreparedQueryConfig,\n} from '~/gel-core/session.ts';\nimport { GelTable } from '~/gel-core/table.ts';\nimport type {\n\tAppendToNullabilityMap,\n\tAppendToResult,\n\tGetSelectTableName,\n\tGetSelectTableSelection,\n\tJoinNullability,\n\tJoinType,\n\tSelectMode,\n\tSelectResult,\n} from '~/query-builders/select.types.ts';\nimport { QueryPromise } from '~/query-promise.ts';\nimport type { RunnableQuery } from '~/runnable-query.ts';\nimport { SelectionProxyHandler } from '~/selection-proxy.ts';\nimport { type ColumnsSelection, type Query, SQL, type SQLWrapper } from '~/sql/sql.ts';\nimport { Subquery } from '~/subquery.ts';\nimport { Table } from '~/table.ts';\nimport {\n\ttype Assume,\n\tgetTableLikeName,\n\tmapUpdateSet,\n\ttype NeonAuthToken,\n\torderSelectedFields,\n\ttype UpdateSet,\n} from '~/utils.ts';\nimport { ViewBaseConfig } from '~/view-common.ts';\nimport type { GelColumn } from '../columns/common.ts';\nimport type { GelViewBase } from '../view-base.ts';\nimport type { GelSelectJoinConfig, SelectedFields, SelectedFieldsOrdered } from './select.types.ts';\n\nexport interface GelUpdateConfig {\n\twhere?: SQL | undefined;\n\tset: UpdateSet;\n\ttable: GelTable;\n\tfrom?: GelTable | Subquery | GelViewBase | SQL;\n\tjoins: GelSelectJoinConfig[];\n\treturning?: SelectedFieldsOrdered;\n\twithList?: Subquery[];\n}\n\nexport type GelUpdateSetSource<TTable extends GelTable> =\n\t& {\n\t\t[Key in keyof TTable['$inferInsert']]?:\n\t\t\t| GetColumnData<TTable['_']['columns'][Key]>\n\t\t\t| SQL\n\t\t\t| GelColumn;\n\t}\n\t& {};\n\nexport class GelUpdateBuilder<TTable extends GelTable, TQueryResult extends GelQueryResultHKT> {\n\tstatic readonly [entityKind]: string = 'GelUpdateBuilder';\n\n\tdeclare readonly _: {\n\t\treadonly table: TTable;\n\t};\n\n\tconstructor(\n\t\tprivate table: TTable,\n\t\tprivate session: GelSession,\n\t\tprivate dialect: GelDialect,\n\t\tprivate withList?: Subquery[],\n\t) {}\n\n\tprivate authToken?: NeonAuthToken;\n\tsetToken(token: NeonAuthToken) {\n\t\tthis.authToken = token;\n\t\treturn this;\n\t}\n\n\tset(\n\t\tvalues: GelUpdateSetSource<TTable>,\n\t): GelUpdateWithout<GelUpdateBase<TTable, TQueryResult>, false, 'leftJoin' | 'rightJoin' | 'innerJoin' | 'fullJoin'> {\n\t\treturn new GelUpdateBase<TTable, TQueryResult>(\n\t\t\tthis.table,\n\t\t\tmapUpdateSet(this.table, values),\n\t\t\tthis.session,\n\t\t\tthis.dialect,\n\t\t\tthis.withList,\n\t\t);\n\t}\n}\n\nexport type GelUpdateWithout<\n\tT extends AnyGelUpdate,\n\tTDynamic extends boolean,\n\tK extends keyof T & string,\n> = TDynamic extends true ? T : Omit<\n\tGelUpdateBase<\n\t\tT['_']['table'],\n\t\tT['_']['queryResult'],\n\t\tT['_']['from'],\n\t\tT['_']['returning'],\n\t\tT['_']['nullabilityMap'],\n\t\tT['_']['joins'],\n\t\tTDynamic,\n\t\tT['_']['excludedMethods'] | K\n\t>,\n\tT['_']['excludedMethods'] | K\n>;\n\nexport type GelUpdateWithJoins<\n\tT extends AnyGelUpdate,\n\tTDynamic extends boolean,\n\tTFrom extends GelTable | Subquery | GelViewBase | SQL,\n> = TDynamic extends true ? T : Omit<\n\tGelUpdateBase<\n\t\tT['_']['table'],\n\t\tT['_']['queryResult'],\n\t\tTFrom,\n\t\tT['_']['returning'],\n\t\tAppendToNullabilityMap<T['_']['nullabilityMap'], GetSelectTableName<TFrom>, 'inner'>,\n\t\t[...T['_']['joins'], {\n\t\t\tname: GetSelectTableName<TFrom>;\n\t\t\tjoinType: 'inner';\n\t\t\ttable: TFrom;\n\t\t}],\n\t\tTDynamic,\n\t\tExclude<T['_']['excludedMethods'] | 'from', 'leftJoin' | 'rightJoin' | 'innerJoin' | 'fullJoin'>\n\t>,\n\tExclude<T['_']['excludedMethods'] | 'from', 'leftJoin' | 'rightJoin' | 'innerJoin' | 'fullJoin'>\n>;\n\nexport type GelUpdateJoinFn<\n\tT extends AnyGelUpdate,\n\tTDynamic extends boolean,\n\tTJoinType extends JoinType,\n> = <\n\tTJoinedTable extends GelTable | Subquery | GelViewBase | SQL,\n>(\n\ttable: TJoinedTable,\n\ton:\n\t\t| (\n\t\t\t(\n\t\t\t\tupdateTable: T['_']['table']['_']['columns'],\n\t\t\t\tfrom: T['_']['from'] extends GelTable ? T['_']['from']['_']['columns']\n\t\t\t\t\t: T['_']['from'] extends Subquery | GelViewBase ? T['_']['from']['_']['selectedFields']\n\t\t\t\t\t: never,\n\t\t\t) => SQL | undefined\n\t\t)\n\t\t| SQL\n\t\t| undefined,\n) => GelUpdateJoin<T, TDynamic, TJoinType, TJoinedTable>;\n\nexport type GelUpdateJoin<\n\tT extends AnyGelUpdate,\n\tTDynamic extends boolean,\n\tTJoinType extends JoinType,\n\tTJoinedTable extends GelTable | Subquery | GelViewBase | SQL,\n> = TDynamic extends true ? T : GelUpdateBase<\n\tT['_']['table'],\n\tT['_']['queryResult'],\n\tT['_']['from'],\n\tT['_']['returning'],\n\tAppendToNullabilityMap<T['_']['nullabilityMap'], GetSelectTableName<TJoinedTable>, TJoinType>,\n\t[...T['_']['joins'], {\n\t\tname: GetSelectTableName<TJoinedTable>;\n\t\tjoinType: TJoinType;\n\t\ttable: TJoinedTable;\n\t}],\n\tTDynamic,\n\tT['_']['excludedMethods']\n>;\n\ntype Join = {\n\tname: string | undefined;\n\tjoinType: JoinType;\n\ttable: GelTable | Subquery | GelViewBase | SQL;\n};\n\ntype AccumulateToResult<\n\tT extends AnyGelUpdate,\n\tTSelectMode extends SelectMode,\n\tTJoins extends Join[],\n\tTSelectedFields extends ColumnsSelection,\n> = TJoins extends [infer TJoin extends Join, ...infer TRest extends Join[]] ? AccumulateToResult<\n\t\tT,\n\t\tTSelectMode extends 'partial' ? TSelectMode : 'multiple',\n\t\tTRest,\n\t\tAppendToResult<\n\t\t\tT['_']['table']['_']['name'],\n\t\t\tTSelectedFields,\n\t\t\tTJoin['name'],\n\t\t\tTJoin['table'] extends Table ? TJoin['table']['_']['columns']\n\t\t\t\t: TJoin['table'] extends Subquery ? Assume<TJoin['table']['_']['selectedFields'], SelectedFields>\n\t\t\t\t: never,\n\t\t\tTSelectMode extends 'partial' ? TSelectMode : 'multiple'\n\t\t>\n\t>\n\t: TSelectedFields;\n\nexport type GelUpdateReturningAll<T extends AnyGelUpdate, TDynamic extends boolean> = GelUpdateWithout<\n\tGelUpdateBase<\n\t\tT['_']['table'],\n\t\tT['_']['queryResult'],\n\t\tT['_']['from'],\n\t\tSelectResult<\n\t\t\tAccumulateToResult<\n\t\t\t\tT,\n\t\t\t\t'single',\n\t\t\t\tT['_']['joins'],\n\t\t\t\tGetSelectTableSelection<T['_']['table']>\n\t\t\t>,\n\t\t\t'partial',\n\t\t\tT['_']['nullabilityMap']\n\t\t>,\n\t\tT['_']['nullabilityMap'],\n\t\tT['_']['joins'],\n\t\tTDynamic,\n\t\tT['_']['excludedMethods']\n\t>,\n\tTDynamic,\n\t'returning'\n>;\n\nexport type GelUpdateReturning<\n\tT extends AnyGelUpdate,\n\tTDynamic extends boolean,\n\tTSelectedFields extends SelectedFields,\n> = GelUpdateWithout<\n\tGelUpdateBase<\n\t\tT['_']['table'],\n\t\tT['_']['queryResult'],\n\t\tT['_']['from'],\n\t\tSelectResult<\n\t\t\tAccumulateToResult<\n\t\t\t\tT,\n\t\t\t\t'partial',\n\t\t\t\tT['_']['joins'],\n\t\t\t\tTSelectedFields\n\t\t\t>,\n\t\t\t'partial',\n\t\t\tT['_']['nullabilityMap']\n\t\t>,\n\t\tT['_']['nullabilityMap'],\n\t\tT['_']['joins'],\n\t\tTDynamic,\n\t\tT['_']['excludedMethods']\n\t>,\n\tTDynamic,\n\t'returning'\n>;\n\nexport type GelUpdatePrepare<T extends AnyGelUpdate> = GelPreparedQuery<\n\tPreparedQueryConfig & {\n\t\texecute: T['_']['returning'] extends undefined ? GelQueryResultKind<T['_']['queryResult'], never>\n\t\t\t: T['_']['returning'][];\n\t}\n>;\n\nexport type GelUpdateDynamic<T extends AnyGelUpdate> = GelUpdate<\n\tT['_']['table'],\n\tT['_']['queryResult'],\n\tT['_']['from'],\n\tT['_']['returning'],\n\tT['_']['nullabilityMap']\n>;\n\nexport type GelUpdate<\n\tTTable extends GelTable = GelTable,\n\tTQueryResult extends GelQueryResultHKT = GelQueryResultHKT,\n\tTFrom extends GelTable | Subquery | GelViewBase | SQL | undefined = undefined,\n\tTReturning extends Record<string, unknown> | undefined = Record<string, unknown> | undefined,\n\tTNullabilityMap extends Record<string, JoinNullability> = Record<TTable['_']['name'], 'not-null'>,\n\tTJoins extends Join[] = [],\n> = GelUpdateBase<TTable, TQueryResult, TFrom, TReturning, TNullabilityMap, TJoins, true, never>;\n\nexport type AnyGelUpdate = GelUpdateBase<any, any, any, any, any, any, any, any>;\n\nexport interface GelUpdateBase<\n\tTTable extends GelTable,\n\tTQueryResult extends GelQueryResultHKT,\n\tTFrom extends GelTable | Subquery | GelViewBase | SQL | undefined = undefined,\n\tTReturning extends Record<string, unknown> | undefined = undefined,\n\tTNullabilityMap extends Record<string, JoinNullability> = Record<TTable['_']['name'], 'not-null'>,\n\tTJoins extends Join[] = [],\n\tTDynamic extends boolean = false,\n\tTExcludedMethods extends string = never,\n> extends\n\tQueryPromise<TReturning extends undefined ? GelQueryResultKind<TQueryResult, never> : TReturning[]>,\n\tRunnableQuery<TReturning extends undefined ? GelQueryResultKind<TQueryResult, never> : TReturning[], 'gel'>,\n\tSQLWrapper\n{\n\treadonly _: {\n\t\treadonly dialect: 'gel';\n\t\treadonly table: TTable;\n\t\treadonly joins: TJoins;\n\t\treadonly nullabilityMap: TNullabilityMap;\n\t\treadonly queryResult: TQueryResult;\n\t\treadonly from: TFrom;\n\t\treadonly returning: TReturning;\n\t\treadonly dynamic: TDynamic;\n\t\treadonly excludedMethods: TExcludedMethods;\n\t\treadonly result: TReturning extends undefined ? GelQueryResultKind<TQueryResult, never> : TReturning[];\n\t};\n}\n\nexport class GelUpdateBase<\n\tTTable extends GelTable,\n\tTQueryResult extends GelQueryResultHKT,\n\tTFrom extends GelTable | Subquery | GelViewBase | SQL | undefined = undefined,\n\tTReturning extends Record<string, unknown> | undefined = undefined,\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\tTNullabilityMap extends Record<string, JoinNullability> = Record<TTable['_']['name'], 'not-null'>,\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\tTJoins extends Join[] = [],\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\tTDynamic extends boolean = false,\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\tTExcludedMethods extends string = never,\n> extends QueryPromise<TReturning extends undefined ? GelQueryResultKind<TQueryResult, never> : TReturning[]>\n\timplements\n\t\tRunnableQuery<TReturning extends undefined ? GelQueryResultKind<TQueryResult, never> : TReturning[], 'gel'>,\n\t\tSQLWrapper\n{\n\tstatic override readonly [entityKind]: string = 'GelUpdate';\n\n\tprivate config: GelUpdateConfig;\n\tprivate tableName: string | undefined;\n\tprivate joinsNotNullableMap: Record<string, boolean>;\n\n\tconstructor(\n\t\ttable: TTable,\n\t\tset: UpdateSet,\n\t\tprivate session: GelSession,\n\t\tprivate dialect: GelDialect,\n\t\twithList?: Subquery[],\n\t) {\n\t\tsuper();\n\t\tthis.config = { set, table, withList, joins: [] };\n\t\tthis.tableName = getTableLikeName(table);\n\t\tthis.joinsNotNullableMap = typeof this.tableName === 'string' ? { [this.tableName]: true } : {};\n\t}\n\n\tfrom<TFrom extends GelTable | Subquery | GelViewBase | SQL>(\n\t\tsource: TFrom,\n\t): GelUpdateWithJoins<this, TDynamic, TFrom> {\n\t\tconst tableName = getTableLikeName(source);\n\t\tif (typeof tableName === 'string') {\n\t\t\tthis.joinsNotNullableMap[tableName] = true;\n\t\t}\n\t\tthis.config.from = source;\n\t\treturn this as any;\n\t}\n\n\tprivate getTableLikeFields(table: GelTable | Subquery | GelViewBase): Record<string, unknown> {\n\t\tif (is(table, GelTable)) {\n\t\t\treturn table[Table.Symbol.Columns];\n\t\t} else if (is(table, Subquery)) {\n\t\t\treturn table._.selectedFields;\n\t\t}\n\t\treturn table[ViewBaseConfig].selectedFields;\n\t}\n\n\tprivate createJoin<TJoinType extends JoinType>(\n\t\tjoinType: TJoinType,\n\t): GelUpdateJoinFn<this, TDynamic, TJoinType> {\n\t\treturn ((\n\t\t\ttable: GelTable | Subquery | GelViewBase | SQL,\n\t\t\ton: ((updateTable: TTable, from: TFrom) => SQL | undefined) | SQL | undefined,\n\t\t) => {\n\t\t\tconst tableName = getTableLikeName(table);\n\n\t\t\tif (typeof tableName === 'string' && this.config.joins.some((join) => join.alias === tableName)) {\n\t\t\t\tthrow new Error(`Alias \"${tableName}\" is already used in this query`);\n\t\t\t}\n\n\t\t\tif (typeof on === 'function') {\n\t\t\t\tconst from = this.config.from && !is(this.config.from, SQL)\n\t\t\t\t\t? this.getTableLikeFields(this.config.from)\n\t\t\t\t\t: undefined;\n\t\t\t\ton = on(\n\t\t\t\t\tnew Proxy(\n\t\t\t\t\t\tthis.config.table[Table.Symbol.Columns],\n\t\t\t\t\t\tnew SelectionProxyHandler({ sqlAliasedBehavior: 'sql', sqlBehavior: 'sql' }),\n\t\t\t\t\t) as any,\n\t\t\t\t\tfrom && new Proxy(\n\t\t\t\t\t\tfrom,\n\t\t\t\t\t\tnew SelectionProxyHandler({ sqlAliasedBehavior: 'sql', sqlBehavior: 'sql' }),\n\t\t\t\t\t) as any,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tthis.config.joins.push({ on, table, joinType, alias: tableName });\n\n\t\t\tif (typeof tableName === 'string') {\n\t\t\t\tswitch (joinType) {\n\t\t\t\t\tcase 'left': {\n\t\t\t\t\t\tthis.joinsNotNullableMap[tableName] = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase 'right': {\n\t\t\t\t\t\tthis.joinsNotNullableMap = Object.fromEntries(\n\t\t\t\t\t\t\tObject.entries(this.joinsNotNullableMap).map(([key]) => [key, false]),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.joinsNotNullableMap[tableName] = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase 'inner': {\n\t\t\t\t\t\tthis.joinsNotNullableMap[tableName] = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase 'full': {\n\t\t\t\t\t\tthis.joinsNotNullableMap = Object.fromEntries(\n\t\t\t\t\t\t\tObject.entries(this.joinsNotNullableMap).map(([key]) => [key, false]),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.joinsNotNullableMap[tableName] = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn this as any;\n\t\t}) as any;\n\t}\n\n\tleftJoin = this.createJoin('left');\n\n\trightJoin = this.createJoin('right');\n\n\tinnerJoin = this.createJoin('inner');\n\n\tfullJoin = this.createJoin('full');\n\n\t/**\n\t * Adds a 'where' clause to the query.\n\t *\n\t * Calling this method will update only those rows that fulfill a specified condition.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/update}\n\t *\n\t * @param where the 'where' clause.\n\t *\n\t * @example\n\t * You can use conditional operators and `sql function` to filter the rows to be updated.\n\t *\n\t * ```ts\n\t * // Update all cars with green color\n\t * await db.update(cars).set({ color: 'red' })\n\t * .where(eq(cars.color, 'green'));\n\t * // or\n\t * await db.update(cars).set({ color: 'red' })\n\t * .where(sql`${cars.color} = 'green'`)\n\t * ```\n\t *\n\t * You can logically combine conditional operators with `and()` and `or()` operators:\n\t *\n\t * ```ts\n\t * // Update all BMW cars with a green color\n\t * await db.update(cars).set({ color: 'red' })\n\t * .where(and(eq(cars.color, 'green'), eq(cars.brand, 'BMW')));\n\t *\n\t * // Update all cars with the green or blue color\n\t * await db.update(cars).set({ color: 'red' })\n\t * .where(or(eq(cars.color, 'green'), eq(cars.color, 'blue')));\n\t * ```\n\t */\n\twhere(where: SQL | undefined): GelUpdateWithout<this, TDynamic, 'where'> {\n\t\tthis.config.where = where;\n\t\treturn this as any;\n\t}\n\n\t/**\n\t * Adds a `returning` clause to the query.\n\t *\n\t * Calling this method will return the specified fields of the updated rows. If no fields are specified, all fields will be returned.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/update#update-with-returning}\n\t *\n\t * @example\n\t * ```ts\n\t * // Update all cars with the green color and return all fields\n\t * const updatedCars: Car[] = await db.update(cars)\n\t * .set({ color: 'red' })\n\t * .where(eq(cars.color, 'green'))\n\t * .returning();\n\t *\n\t * // Update all cars with the green color and return only their id and brand fields\n\t * const updatedCarsIdsAndBrands: { id: number, brand: string }[] = await db.update(cars)\n\t * .set({ color: 'red' })\n\t * .where(eq(cars.color, 'green'))\n\t * .returning({ id: cars.id, brand: cars.brand });\n\t * ```\n\t */\n\treturning(): GelUpdateReturningAll<this, TDynamic>;\n\treturning<TSelectedFields extends SelectedFields>(\n\t\tfields: TSelectedFields,\n\t): GelUpdateReturning<this, TDynamic, TSelectedFields>;\n\treturning(\n\t\tfields?: SelectedFields,\n\t): GelUpdateWithout<AnyGelUpdate, TDynamic, 'returning'> {\n\t\tif (!fields) {\n\t\t\tfields = Object.assign({}, this.config.table[Table.Symbol.Columns]);\n\n\t\t\tif (this.config.from) {\n\t\t\t\tconst tableName = getTableLikeName(this.config.from);\n\n\t\t\t\tif (typeof tableName === 'string' && this.config.from && !is(this.config.from, SQL)) {\n\t\t\t\t\tconst fromFields = this.getTableLikeFields(this.config.from);\n\t\t\t\t\tfields[tableName] = fromFields as any;\n\t\t\t\t}\n\n\t\t\t\tfor (const join of this.config.joins) {\n\t\t\t\t\tconst tableName = getTableLikeName(join.table);\n\n\t\t\t\t\tif (typeof tableName === 'string' && !is(join.table, SQL)) {\n\t\t\t\t\t\tconst fromFields = this.getTableLikeFields(join.table);\n\t\t\t\t\t\tfields[tableName] = fromFields as any;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tthis.config.returning = orderSelectedFields<GelColumn>(fields);\n\t\treturn this as any;\n\t}\n\n\t/** @internal */\n\tgetSQL(): SQL {\n\t\treturn this.dialect.buildUpdateQuery(this.config);\n\t}\n\n\ttoSQL(): Query {\n\t\tconst { typings: _typings, ...rest } = this.dialect.sqlToQuery(this.getSQL());\n\t\treturn rest;\n\t}\n\n\t/** @internal */\n\t_prepare(name?: string): GelUpdatePrepare<this> {\n\t\tconst query = this.session.prepareQuery<\n\t\t\tPreparedQueryConfig & { execute: TReturning[] }\n\t\t>(this.dialect.sqlToQuery(this.getSQL()), this.config.returning, name, true);\n\t\tquery.joinsNotNullableMap = this.joinsNotNullableMap;\n\t\treturn query;\n\t}\n\n\tprepare(name: string): GelUpdatePrepare<this> {\n\t\treturn this._prepare(name);\n\t}\n\n\toverride execute: ReturnType<this['prepare']>['execute'] = (placeholderValues) => {\n\t\treturn this._prepare().execute(placeholderValues);\n\t};\n\n\t$dynamic(): GelUpdateDynamic<this> {\n\t\treturn this as any;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAA+B;AAS/B,mBAAyB;AAWzB,2BAA6B;AAE7B,6BAAsC;AACtC,iBAAwE;AACxE,sBAAyB;AACzB,IAAAA,gBAAsB;AACtB,mBAOO;AACP,yBAA+B;AAwBxB,MAAM,iBAAkF;AAAA,EAO9F,YACS,OACA,SACA,SACA,UACP;AAJO;AACA;AACA;AACA;AAAA,EACN;AAAA,EAXH,QAAiB,wBAAU,IAAY;AAAA,EAa/B;AAAA,EACR,SAAS,OAAsB;AAC9B,SAAK,YAAY;AACjB,WAAO;AAAA,EACR;AAAA,EAEA,IACC,QACoH;AACpH,WAAO,IAAI;AAAA,MACV,KAAK;AAAA,UACL,2BAAa,KAAK,OAAO,MAAM;AAAA,MAC/B,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,IACN;AAAA,EACD;AACD;AAwNO,MAAM,sBAaH,kCAIV;AAAA,EAOC,YACC,OACA,KACQ,SACA,SACR,UACC;AACD,UAAM;AAJE;AACA;AAIR,SAAK,SAAS,EAAE,KAAK,OAAO,UAAU,OAAO,CAAC,EAAE;AAChD,SAAK,gBAAY,+BAAiB,KAAK;AACvC,SAAK,sBAAsB,OAAO,KAAK,cAAc,WAAW,EAAE,CAAC,KAAK,SAAS,GAAG,KAAK,IAAI,CAAC;AAAA,EAC/F;AAAA,EAjBA,QAA0B,wBAAU,I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"],"sourcesContent":["import type { GetColumnData } from '~/column.ts';\nimport { entityKind, is } from '~/entity.ts';\nimport type { GelDialect } from '~/gel-core/dialect.ts';\nimport type {\n\tGelPreparedQuery,\n\tGelQueryResultHKT,\n\tGelQueryResultKind,\n\tGelSession,\n\tPreparedQueryConfig,\n} from '~/gel-core/session.ts';\nimport { GelTable } from '~/gel-core/table.ts';\nimport type {\n\tAppendToNullabilityMap,\n\tAppendToResult,\n\tGetSelectTableName,\n\tGetSelectTableSelection,\n\tJoinNullability,\n\tJoinType,\n\tSelectMode,\n\tSelectResult,\n} from '~/query-builders/select.types.ts';\nimport { QueryPromise } from '~/query-promise.ts';\nimport type { RunnableQuery } from '~/runnable-query.ts';\nimport { SelectionProxyHandler } from '~/selection-proxy.ts';\nimport { type ColumnsSelection, type Query, SQL, type SQLWrapper } from '~/sql/sql.ts';\nimport { Subquery } from '~/subquery.ts';\nimport { Table } from '~/table.ts';\nimport {\n\ttype Assume,\n\tgetTableLikeName,\n\tmapUpdateSet,\n\ttype NeonAuthToken,\n\torderSelectedFields,\n\ttype UpdateSet,\n} from '~/utils.ts';\nimport { ViewBaseConfig } from '~/view-common.ts';\nimport type { GelColumn } from '../columns/common.ts';\nimport { extractUsedTable } from '../utils.ts';\nimport type { GelViewBase } from '../view-base.ts';\nimport type { GelSelectJoinConfig, SelectedFields, SelectedFieldsOrdered } from './select.types.ts';\n\nexport interface GelUpdateConfig {\n\twhere?: SQL | undefined;\n\tset: UpdateSet;\n\ttable: GelTable;\n\tfrom?: GelTable | Subquery | GelViewBase | SQL;\n\tjoins: GelSelectJoinConfig[];\n\treturning?: SelectedFieldsOrdered;\n\twithList?: Subquery[];\n}\n\nexport type GelUpdateSetSource<TTable extends GelTable> =\n\t& {\n\t\t[Key in keyof TTable['$inferInsert']]?:\n\t\t\t| GetColumnData<TTable['_']['columns'][Key]>\n\t\t\t| SQL\n\t\t\t| GelColumn;\n\t}\n\t& {};\n\nexport class GelUpdateBuilder<TTable extends GelTable, TQueryResult extends GelQueryResultHKT> {\n\tstatic readonly [entityKind]: string = 'GelUpdateBuilder';\n\n\tdeclare readonly _: {\n\t\treadonly table: TTable;\n\t};\n\n\tconstructor(\n\t\tprivate table: TTable,\n\t\tprivate session: GelSession,\n\t\tprivate dialect: GelDialect,\n\t\tprivate withList?: Subquery[],\n\t) {}\n\n\tprivate authToken?: NeonAuthToken;\n\tsetToken(token: NeonAuthToken) {\n\t\tthis.authToken = token;\n\t\treturn this;\n\t}\n\n\tset(\n\t\tvalues: GelUpdateSetSource<TTable>,\n\t): GelUpdateWithout<GelUpdateBase<TTable, TQueryResult>, false, 'leftJoin' | 'rightJoin' | 'innerJoin' | 'fullJoin'> {\n\t\treturn new GelUpdateBase<TTable, TQueryResult>(\n\t\t\tthis.table,\n\t\t\tmapUpdateSet(this.table, values),\n\t\t\tthis.session,\n\t\t\tthis.dialect,\n\t\t\tthis.withList,\n\t\t);\n\t}\n}\n\nexport type GelUpdateWithout<\n\tT extends AnyGelUpdate,\n\tTDynamic extends boolean,\n\tK extends keyof T & string,\n> = TDynamic extends true ? T : Omit<\n\tGelUpdateBase<\n\t\tT['_']['table'],\n\t\tT['_']['queryResult'],\n\t\tT['_']['from'],\n\t\tT['_']['returning'],\n\t\tT['_']['nullabilityMap'],\n\t\tT['_']['joins'],\n\t\tTDynamic,\n\t\tT['_']['excludedMethods'] | K\n\t>,\n\tT['_']['excludedMethods'] | K\n>;\n\nexport type GelUpdateWithJoins<\n\tT extends AnyGelUpdate,\n\tTDynamic extends boolean,\n\tTFrom extends GelTable | Subquery | GelViewBase | SQL,\n> = TDynamic extends true ? T : Omit<\n\tGelUpdateBase<\n\t\tT['_']['table'],\n\t\tT['_']['queryResult'],\n\t\tTFrom,\n\t\tT['_']['returning'],\n\t\tAppendToNullabilityMap<T['_']['nullabilityMap'], GetSelectTableName<TFrom>, 'inner'>,\n\t\t[...T['_']['joins'], {\n\t\t\tname: GetSelectTableName<TFrom>;\n\t\t\tjoinType: 'inner';\n\t\t\ttable: TFrom;\n\t\t}],\n\t\tTDynamic,\n\t\tExclude<T['_']['excludedMethods'] | 'from', 'leftJoin' | 'rightJoin' | 'innerJoin' | 'fullJoin'>\n\t>,\n\tExclude<T['_']['excludedMethods'] | 'from', 'leftJoin' | 'rightJoin' | 'innerJoin' | 'fullJoin'>\n>;\n\nexport type GelUpdateJoinFn<\n\tT extends AnyGelUpdate,\n\tTDynamic extends boolean,\n\tTJoinType extends JoinType,\n> = <\n\tTJoinedTable extends GelTable | Subquery | GelViewBase | SQL,\n>(\n\ttable: TJoinedTable,\n\ton:\n\t\t| (\n\t\t\t(\n\t\t\t\tupdateTable: T['_']['table']['_']['columns'],\n\t\t\t\tfrom: T['_']['from'] extends GelTable ? T['_']['from']['_']['columns']\n\t\t\t\t\t: T['_']['from'] extends Subquery | GelViewBase ? T['_']['from']['_']['selectedFields']\n\t\t\t\t\t: never,\n\t\t\t) => SQL | undefined\n\t\t)\n\t\t| SQL\n\t\t| undefined,\n) => GelUpdateJoin<T, TDynamic, TJoinType, TJoinedTable>;\n\nexport type GelUpdateJoin<\n\tT extends AnyGelUpdate,\n\tTDynamic extends boolean,\n\tTJoinType extends JoinType,\n\tTJoinedTable extends GelTable | Subquery | GelViewBase | SQL,\n> = TDynamic extends true ? T : GelUpdateBase<\n\tT['_']['table'],\n\tT['_']['queryResult'],\n\tT['_']['from'],\n\tT['_']['returning'],\n\tAppendToNullabilityMap<T['_']['nullabilityMap'], GetSelectTableName<TJoinedTable>, TJoinType>,\n\t[...T['_']['joins'], {\n\t\tname: GetSelectTableName<TJoinedTable>;\n\t\tjoinType: TJoinType;\n\t\ttable: TJoinedTable;\n\t}],\n\tTDynamic,\n\tT['_']['excludedMethods']\n>;\n\ntype Join = {\n\tname: string | undefined;\n\tjoinType: JoinType;\n\ttable: GelTable | Subquery | GelViewBase | SQL;\n};\n\ntype AccumulateToResult<\n\tT extends AnyGelUpdate,\n\tTSelectMode extends SelectMode,\n\tTJoins extends Join[],\n\tTSelectedFields extends ColumnsSelection,\n> = TJoins extends [infer TJoin extends Join, ...infer TRest extends Join[]] ? AccumulateToResult<\n\t\tT,\n\t\tTSelectMode extends 'partial' ? TSelectMode : 'multiple',\n\t\tTRest,\n\t\tAppendToResult<\n\t\t\tT['_']['table']['_']['name'],\n\t\t\tTSelectedFields,\n\t\t\tTJoin['name'],\n\t\t\tTJoin['table'] extends Table ? TJoin['table']['_']['columns']\n\t\t\t\t: TJoin['table'] extends Subquery ? Assume<TJoin['table']['_']['selectedFields'], SelectedFields>\n\t\t\t\t: never,\n\t\t\tTSelectMode extends 'partial' ? TSelectMode : 'multiple'\n\t\t>\n\t>\n\t: TSelectedFields;\n\nexport type GelUpdateReturningAll<T extends AnyGelUpdate, TDynamic extends boolean> = GelUpdateWithout<\n\tGelUpdateBase<\n\t\tT['_']['table'],\n\t\tT['_']['queryResult'],\n\t\tT['_']['from'],\n\t\tSelectResult<\n\t\t\tAccumulateToResult<\n\t\t\t\tT,\n\t\t\t\t'single',\n\t\t\t\tT['_']['joins'],\n\t\t\t\tGetSelectTableSelection<T['_']['table']>\n\t\t\t>,\n\t\t\t'partial',\n\t\t\tT['_']['nullabilityMap']\n\t\t>,\n\t\tT['_']['nullabilityMap'],\n\t\tT['_']['joins'],\n\t\tTDynamic,\n\t\tT['_']['excludedMethods']\n\t>,\n\tTDynamic,\n\t'returning'\n>;\n\nexport type GelUpdateReturning<\n\tT extends AnyGelUpdate,\n\tTDynamic extends boolean,\n\tTSelectedFields extends SelectedFields,\n> = GelUpdateWithout<\n\tGelUpdateBase<\n\t\tT['_']['table'],\n\t\tT['_']['queryResult'],\n\t\tT['_']['from'],\n\t\tSelectResult<\n\t\t\tAccumulateToResult<\n\t\t\t\tT,\n\t\t\t\t'partial',\n\t\t\t\tT['_']['joins'],\n\t\t\t\tTSelectedFields\n\t\t\t>,\n\t\t\t'partial',\n\t\t\tT['_']['nullabilityMap']\n\t\t>,\n\t\tT['_']['nullabilityMap'],\n\t\tT['_']['joins'],\n\t\tTDynamic,\n\t\tT['_']['excludedMethods']\n\t>,\n\tTDynamic,\n\t'returning'\n>;\n\nexport type GelUpdatePrepare<T extends AnyGelUpdate> = GelPreparedQuery<\n\tPreparedQueryConfig & {\n\t\texecute: T['_']['returning'] extends undefined ? GelQueryResultKind<T['_']['queryResult'], never>\n\t\t\t: T['_']['returning'][];\n\t}\n>;\n\nexport type GelUpdateDynamic<T extends AnyGelUpdate> = GelUpdate<\n\tT['_']['table'],\n\tT['_']['queryResult'],\n\tT['_']['from'],\n\tT['_']['returning'],\n\tT['_']['nullabilityMap']\n>;\n\nexport type GelUpdate<\n\tTTable extends GelTable = GelTable,\n\tTQueryResult extends GelQueryResultHKT = GelQueryResultHKT,\n\tTFrom extends GelTable | Subquery | GelViewBase | SQL | undefined = undefined,\n\tTReturning extends Record<string, unknown> | undefined = Record<string, unknown> | undefined,\n\tTNullabilityMap extends Record<string, JoinNullability> = Record<TTable['_']['name'], 'not-null'>,\n\tTJoins extends Join[] = [],\n> = GelUpdateBase<TTable, TQueryResult, TFrom, TReturning, TNullabilityMap, TJoins, true, never>;\n\nexport type AnyGelUpdate = GelUpdateBase<any, any, any, any, any, any, any, any>;\n\nexport interface GelUpdateBase<\n\tTTable extends GelTable,\n\tTQueryResult extends GelQueryResultHKT,\n\tTFrom extends GelTable | Subquery | GelViewBase | SQL | undefined = undefined,\n\tTReturning extends Record<string, unknown> | undefined = undefined,\n\tTNullabilityMap extends Record<string, JoinNullability> = Record<TTable['_']['name'], 'not-null'>,\n\tTJoins extends Join[] = [],\n\tTDynamic extends boolean = false,\n\tTExcludedMethods extends string = never,\n> extends\n\tQueryPromise<TReturning extends undefined ? GelQueryResultKind<TQueryResult, never> : TReturning[]>,\n\tRunnableQuery<TReturning extends undefined ? GelQueryResultKind<TQueryResult, never> : TReturning[], 'gel'>,\n\tSQLWrapper\n{\n\treadonly _: {\n\t\treadonly dialect: 'gel';\n\t\treadonly table: TTable;\n\t\treadonly joins: TJoins;\n\t\treadonly nullabilityMap: TNullabilityMap;\n\t\treadonly queryResult: TQueryResult;\n\t\treadonly from: TFrom;\n\t\treadonly returning: TReturning;\n\t\treadonly dynamic: TDynamic;\n\t\treadonly excludedMethods: TExcludedMethods;\n\t\treadonly result: TReturning extends undefined ? GelQueryResultKind<TQueryResult, never> : TReturning[];\n\t};\n}\n\nexport class GelUpdateBase<\n\tTTable extends GelTable,\n\tTQueryResult extends GelQueryResultHKT,\n\tTFrom extends GelTable | Subquery | GelViewBase | SQL | undefined = undefined,\n\tTReturning extends Record<string, unknown> | undefined = undefined,\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\tTNullabilityMap extends Record<string, JoinNullability> = Record<TTable['_']['name'], 'not-null'>,\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\tTJoins extends Join[] = [],\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\tTDynamic extends boolean = false,\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\tTExcludedMethods extends string = never,\n> extends QueryPromise<TReturning extends undefined ? GelQueryResultKind<TQueryResult, never> : TReturning[]>\n\timplements\n\t\tRunnableQuery<TReturning extends undefined ? GelQueryResultKind<TQueryResult, never> : TReturning[], 'gel'>,\n\t\tSQLWrapper\n{\n\tstatic override readonly [entityKind]: string = 'GelUpdate';\n\n\tprivate config: GelUpdateConfig;\n\tprivate tableName: string | undefined;\n\tprivate joinsNotNullableMap: Record<string, boolean>;\n\n\tconstructor(\n\t\ttable: TTable,\n\t\tset: UpdateSet,\n\t\tprivate session: GelSession,\n\t\tprivate dialect: GelDialect,\n\t\twithList?: Subquery[],\n\t) {\n\t\tsuper();\n\t\tthis.config = { set, table, withList, joins: [] };\n\t\tthis.tableName = getTableLikeName(table);\n\t\tthis.joinsNotNullableMap = typeof this.tableName === 'string' ? { [this.tableName]: true } : {};\n\t}\n\n\tfrom<TFrom extends GelTable | Subquery | GelViewBase | SQL>(\n\t\tsource: TFrom,\n\t): GelUpdateWithJoins<this, TDynamic, TFrom> {\n\t\tconst tableName = getTableLikeName(source);\n\t\tif (typeof tableName === 'string') {\n\t\t\tthis.joinsNotNullableMap[tableName] = true;\n\t\t}\n\t\tthis.config.from = source;\n\t\treturn this as any;\n\t}\n\n\tprivate getTableLikeFields(table: GelTable | Subquery | GelViewBase): Record<string, unknown> {\n\t\tif (is(table, GelTable)) {\n\t\t\treturn table[Table.Symbol.Columns];\n\t\t} else if (is(table, Subquery)) {\n\t\t\treturn table._.selectedFields;\n\t\t}\n\t\treturn table[ViewBaseConfig].selectedFields;\n\t}\n\n\tprivate createJoin<TJoinType extends JoinType>(\n\t\tjoinType: TJoinType,\n\t): GelUpdateJoinFn<this, TDynamic, TJoinType> {\n\t\treturn ((\n\t\t\ttable: GelTable | Subquery | GelViewBase | SQL,\n\t\t\ton: ((updateTable: TTable, from: TFrom) => SQL | undefined) | SQL | undefined,\n\t\t) => {\n\t\t\tconst tableName = getTableLikeName(table);\n\n\t\t\tif (typeof tableName === 'string' && this.config.joins.some((join) => join.alias === tableName)) {\n\t\t\t\tthrow new Error(`Alias \"${tableName}\" is already used in this query`);\n\t\t\t}\n\n\t\t\tif (typeof on === 'function') {\n\t\t\t\tconst from = this.config.from && !is(this.config.from, SQL)\n\t\t\t\t\t? this.getTableLikeFields(this.config.from)\n\t\t\t\t\t: undefined;\n\t\t\t\ton = on(\n\t\t\t\t\tnew Proxy(\n\t\t\t\t\t\tthis.config.table[Table.Symbol.Columns],\n\t\t\t\t\t\tnew SelectionProxyHandler({ sqlAliasedBehavior: 'sql', sqlBehavior: 'sql' }),\n\t\t\t\t\t) as any,\n\t\t\t\t\tfrom && new Proxy(\n\t\t\t\t\t\tfrom,\n\t\t\t\t\t\tnew SelectionProxyHandler({ sqlAliasedBehavior: 'sql', sqlBehavior: 'sql' }),\n\t\t\t\t\t) as any,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tthis.config.joins.push({ on, table, joinType, alias: tableName });\n\n\t\t\tif (typeof tableName === 'string') {\n\t\t\t\tswitch (joinType) {\n\t\t\t\t\tcase 'left': {\n\t\t\t\t\t\tthis.joinsNotNullableMap[tableName] = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase 'right': {\n\t\t\t\t\t\tthis.joinsNotNullableMap = Object.fromEntries(\n\t\t\t\t\t\t\tObject.entries(this.joinsNotNullableMap).map(([key]) => [key, false]),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.joinsNotNullableMap[tableName] = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase 'inner': {\n\t\t\t\t\t\tthis.joinsNotNullableMap[tableName] = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase 'full': {\n\t\t\t\t\t\tthis.joinsNotNullableMap = Object.fromEntries(\n\t\t\t\t\t\t\tObject.entries(this.joinsNotNullableMap).map(([key]) => [key, false]),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.joinsNotNullableMap[tableName] = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn this as any;\n\t\t}) as any;\n\t}\n\n\tleftJoin = this.createJoin('left');\n\n\trightJoin = this.createJoin('right');\n\n\tinnerJoin = this.createJoin('inner');\n\n\tfullJoin = this.createJoin('full');\n\n\t/**\n\t * Adds a 'where' clause to the query.\n\t *\n\t * Calling this method will update only those rows that fulfill a specified condition.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/update}\n\t *\n\t * @param where the 'where' clause.\n\t *\n\t * @example\n\t * You can use conditional operators and `sql function` to filter the rows to be updated.\n\t *\n\t * ```ts\n\t * // Update all cars with green color\n\t * await db.update(cars).set({ color: 'red' })\n\t * .where(eq(cars.color, 'green'));\n\t * // or\n\t * await db.update(cars).set({ color: 'red' })\n\t * .where(sql`${cars.color} = 'green'`)\n\t * ```\n\t *\n\t * You can logically combine conditional operators with `and()` and `or()` operators:\n\t *\n\t * ```ts\n\t * // Update all BMW cars with a green color\n\t * await db.update(cars).set({ color: 'red' })\n\t * .where(and(eq(cars.color, 'green'), eq(cars.brand, 'BMW')));\n\t *\n\t * // Update all cars with the green or blue color\n\t * await db.update(cars).set({ color: 'red' })\n\t * .where(or(eq(cars.color, 'green'), eq(cars.color, 'blue')));\n\t * ```\n\t */\n\twhere(where: SQL | undefined): GelUpdateWithout<this, TDynamic, 'where'> {\n\t\tthis.config.where = where;\n\t\treturn this as any;\n\t}\n\n\t/**\n\t * Adds a `returning` clause to the query.\n\t *\n\t * Calling this method will return the specified fields of the updated rows. If no fields are specified, all fields will be returned.\n\t *\n\t * See docs: {@link https://orm.drizzle.team/docs/update#update-with-returning}\n\t *\n\t * @example\n\t * ```ts\n\t * // Update all cars with the green color and return all fields\n\t * const updatedCars: Car[] = await db.update(cars)\n\t * .set({ color: 'red' })\n\t * .where(eq(cars.color, 'green'))\n\t * .returning();\n\t *\n\t * // Update all cars with the green color and return only their id and brand fields\n\t * const updatedCarsIdsAndBrands: { id: number, brand: string }[] = await db.update(cars)\n\t * .set({ color: 'red' })\n\t * .where(eq(cars.color, 'green'))\n\t * .returning({ id: cars.id, brand: cars.brand });\n\t * ```\n\t */\n\treturning(): GelUpdateReturningAll<this, TDynamic>;\n\treturning<TSelectedFields extends SelectedFields>(\n\t\tfields: TSelectedFields,\n\t): GelUpdateReturning<this, TDynamic, TSelectedFields>;\n\treturning(\n\t\tfields?: SelectedFields,\n\t): GelUpdateWithout<AnyGelUpdate, TDynamic, 'returning'> {\n\t\tif (!fields) {\n\t\t\tfields = Object.assign({}, this.config.table[Table.Symbol.Columns]);\n\n\t\t\tif (this.config.from) {\n\t\t\t\tconst tableName = getTableLikeName(this.config.from);\n\n\t\t\t\tif (typeof tableName === 'string' && this.config.from && !is(this.config.from, SQL)) {\n\t\t\t\t\tconst fromFields = this.getTableLikeFields(this.config.from);\n\t\t\t\t\tfields[tableName] = fromFields as any;\n\t\t\t\t}\n\n\t\t\t\tfor (const join of this.config.joins) {\n\t\t\t\t\tconst tableName = getTableLikeName(join.table);\n\n\t\t\t\t\tif (typeof tableName === 'string' && !is(join.table, SQL)) {\n\t\t\t\t\t\tconst fromFields = this.getTableLikeFields(join.table);\n\t\t\t\t\t\tfields[tableName] = fromFields as any;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tthis.config.returning = orderSelectedFields<GelColumn>(fields);\n\t\treturn this as any;\n\t}\n\n\t/** @internal */\n\tgetSQL(): SQL {\n\t\treturn this.dialect.buildUpdateQuery(this.config);\n\t}\n\n\ttoSQL(): Query {\n\t\tconst { typings: _typings, ...rest } = this.dialect.sqlToQuery(this.getSQL());\n\t\treturn rest;\n\t}\n\n\t/** @internal */\n\t_prepare(name?: string): GelUpdatePrepare<this> {\n\t\tconst query = this.session.prepareQuery<\n\t\t\tPreparedQueryConfig & { execute: TReturning[] }\n\t\t>(this.dialect.sqlToQuery(this.getSQL()), this.config.returning, name, true, undefined, {\n\t\t\ttype: 'update',\n\t\t\ttables: extractUsedTable(this.config.table),\n\t\t});\n\t\tquery.joinsNotNullableMap = this.joinsNotNullableMap;\n\t\treturn query;\n\t}\n\n\tprepare(name: string): GelUpdatePrepare<this> {\n\t\treturn this._prepare(name);\n\t}\n\n\toverride execute: ReturnType<this['prepare']>['execute'] = (placeholderValues) => {\n\t\treturn this._prepare().execute(placeholderValues);\n\t};\n\n\t$dynamic(): GelUpdateDynamic<this> {\n\t\treturn this as any;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAA+B;AAS/B,mBAAyB;AAWzB,2BAA6B;AAE7B,6BAAsC;AACtC,iBAAwE;AACxE,sBAAyB;AACzB,IAAAA,gBAAsB;AACtB,mBAOO;AACP,yBAA+B;AAE/B,IAAAC,gBAAiC;AAuB1B,MAAM,iBAAkF;AAAA,EAO9F,YACS,OACA,SACA,SACA,UACP;AAJO;AACA;AACA;AACA;AA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AAM;AAAA,EACjD;AAAA,EAEA,QAAe;AACd,UAAM,EAAE,SAAS,UAAU,GAAG,KAAK,IAAI,KAAK,QAAQ,WAAW,KAAK,OAAO,CAAC;AAC5E,WAAO;AAAA,EACR;AAAA;AAAA,EAGA,SAAS,MAAuC;AAC/C,UAAM,QAAQ,KAAK,QAAQ,aAEzB,KAAK,QAAQ,WAAW,KAAK,OAAO,CAAC,GAAG,KAAK,OAAO,WAAW,MAAM,MAAM,QAAW;AAAA,MACvF,MAAM;AAAA,MACN,YAAQ,gCAAiB,KAAK,OAAO,KAAK;AAAA,IAC3C,CAAC;AACD,UAAM,sBAAsB,KAAK;AACjC,WAAO;AAAA,EACR;AAAA,EAEA,QAAQ,MAAsC;AAC7C,WAAO,KAAK,SAAS,IAAI;AAAA,EAC1B;AAAA,EAES,UAAkD,CAAC,sBAAsB;AACjF,WAAO,KAAK,SAAS,EAAE,QAAQ,iBAAiB;AAAA,EACjD;AAAA,EAEA,WAAmC;AAClC,WAAO;AAAA,EACR;AACD;","names":["import_table","import_utils","tableName"]}
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
orderSelectedFields
|
|
12
12
|
} from "../../utils.js";
|
|
13
13
|
import { ViewBaseConfig } from "../../view-common.js";
|
|
14
|
+
import { extractUsedTable } from "../utils.js";
|
|
14
15
|
class GelUpdateBuilder {
|
|
15
16
|
constructor(table, session, dialect, withList) {
|
|
16
17
|
this.table = table;
|
|
@@ -184,7 +185,10 @@ class GelUpdateBase extends QueryPromise {
|
|
|
184
185
|
}
|
|
185
186
|
/** @internal */
|
|
186
187
|
_prepare(name) {
|
|
187
|
-
const query = this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()), this.config.returning, name, true
|
|
188
|
+
const query = this.session.prepareQuery(this.dialect.sqlToQuery(this.getSQL()), this.config.returning, name, true, void 0, {
|
|
189
|
+
type: "update",
|
|
190
|
+
tables: extractUsedTable(this.config.table)
|
|
191
|
+
});
|
|
188
192
|
query.joinsNotNullableMap = this.joinsNotNullableMap;
|
|
189
193
|
return query;
|
|
190
194
|
}
|