drizzle-orm 0.39.3 → 0.40.0-53e792e
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_relations.cjs +328 -0
- package/_relations.cjs.map +1 -0
- package/_relations.d.cts +215 -0
- package/_relations.d.ts +215 -0
- package/_relations.js +316 -0
- package/_relations.js.map +1 -0
- package/alias.cjs.map +1 -1
- package/alias.d.cts +3 -3
- package/alias.d.ts +3 -3
- package/alias.js.map +1 -1
- package/aws-data-api/pg/driver.cjs +19 -5
- package/aws-data-api/pg/driver.cjs.map +1 -1
- package/aws-data-api/pg/driver.d.cts +9 -8
- package/aws-data-api/pg/driver.d.ts +9 -8
- package/aws-data-api/pg/driver.js +9 -8
- package/aws-data-api/pg/driver.js.map +1 -1
- package/aws-data-api/pg/migrator.cjs.map +1 -1
- package/aws-data-api/pg/migrator.d.cts +2 -1
- package/aws-data-api/pg/migrator.d.ts +2 -1
- package/aws-data-api/pg/migrator.js.map +1 -1
- package/aws-data-api/pg/session.cjs +67 -4
- package/aws-data-api/pg/session.cjs.map +1 -1
- package/aws-data-api/pg/session.d.cts +13 -8
- package/aws-data-api/pg/session.d.ts +13 -8
- package/aws-data-api/pg/session.js +67 -4
- package/aws-data-api/pg/session.js.map +1 -1
- package/better-sqlite3/driver.cjs +12 -5
- package/better-sqlite3/driver.cjs.map +1 -1
- package/better-sqlite3/driver.d.cts +7 -6
- package/better-sqlite3/driver.d.ts +7 -6
- package/better-sqlite3/driver.js +12 -8
- package/better-sqlite3/driver.js.map +1 -1
- package/better-sqlite3/migrator.cjs.map +1 -1
- package/better-sqlite3/migrator.d.cts +2 -1
- package/better-sqlite3/migrator.d.ts +2 -1
- package/better-sqlite3/migrator.js.map +1 -1
- package/better-sqlite3/session.cjs +49 -4
- package/better-sqlite3/session.cjs.map +1 -1
- package/better-sqlite3/session.d.cts +14 -8
- package/better-sqlite3/session.d.ts +14 -8
- package/better-sqlite3/session.js +49 -4
- package/better-sqlite3/session.js.map +1 -1
- package/bun-sql/driver.cjs +16 -5
- package/bun-sql/driver.cjs.map +1 -1
- package/bun-sql/driver.d.cts +7 -6
- package/bun-sql/driver.d.ts +7 -6
- package/bun-sql/driver.js +6 -8
- package/bun-sql/driver.js.map +1 -1
- package/bun-sql/migrator.cjs.map +1 -1
- package/bun-sql/migrator.d.cts +2 -1
- package/bun-sql/migrator.d.ts +2 -1
- package/bun-sql/migrator.js.map +1 -1
- package/bun-sql/session.cjs +50 -6
- package/bun-sql/session.cjs.map +1 -1
- package/bun-sql/session.d.cts +14 -9
- package/bun-sql/session.d.ts +14 -9
- package/bun-sql/session.js +50 -6
- package/bun-sql/session.js.map +1 -1
- package/bun-sqlite/driver.cjs +22 -5
- package/bun-sqlite/driver.cjs.map +1 -1
- package/bun-sqlite/driver.d.cts +7 -6
- package/bun-sqlite/driver.d.ts +7 -6
- package/bun-sqlite/driver.js +12 -8
- package/bun-sqlite/driver.js.map +1 -1
- package/bun-sqlite/migrator.cjs.map +1 -1
- package/bun-sqlite/migrator.d.cts +2 -1
- package/bun-sqlite/migrator.d.ts +2 -1
- package/bun-sqlite/migrator.js.map +1 -1
- package/bun-sqlite/session.cjs +49 -4
- package/bun-sqlite/session.cjs.map +1 -1
- package/bun-sqlite/session.d.cts +14 -8
- package/bun-sqlite/session.d.ts +14 -8
- package/bun-sqlite/session.js +49 -4
- package/bun-sqlite/session.js.map +1 -1
- package/casing.cjs +3 -0
- package/casing.cjs.map +1 -1
- package/casing.d.cts +1 -1
- package/casing.d.ts +1 -1
- package/casing.js +4 -1
- package/casing.js.map +1 -1
- package/column-builder.cjs.map +1 -1
- package/column-builder.d.cts +6 -5
- package/column-builder.d.ts +6 -5
- package/column-builder.js.map +1 -1
- package/d1/driver.cjs +22 -5
- package/d1/driver.cjs.map +1 -1
- package/d1/driver.d.cts +3 -2
- package/d1/driver.d.ts +3 -2
- package/d1/driver.js +12 -8
- package/d1/driver.js.map +1 -1
- package/d1/migrator.cjs.map +1 -1
- package/d1/migrator.d.cts +2 -1
- package/d1/migrator.d.ts +2 -1
- package/d1/migrator.js.map +1 -1
- package/d1/session.cjs +50 -8
- package/d1/session.cjs.map +1 -1
- package/d1/session.d.cts +15 -8
- package/d1/session.d.ts +15 -8
- package/d1/session.js +50 -8
- package/d1/session.js.map +1 -1
- package/durable-sqlite/driver.cjs +16 -5
- package/durable-sqlite/driver.cjs.map +1 -1
- package/durable-sqlite/driver.d.cts +3 -2
- package/durable-sqlite/driver.d.ts +3 -2
- package/durable-sqlite/driver.js +6 -8
- package/durable-sqlite/driver.js.map +1 -1
- package/durable-sqlite/migrator.cjs.map +1 -1
- package/durable-sqlite/migrator.d.cts +2 -1
- package/durable-sqlite/migrator.d.ts +2 -1
- package/durable-sqlite/migrator.js.map +1 -1
- package/durable-sqlite/session.cjs +46 -4
- package/durable-sqlite/session.cjs.map +1 -1
- package/durable-sqlite/session.d.cts +14 -8
- package/durable-sqlite/session.d.ts +14 -8
- package/durable-sqlite/session.js +46 -4
- package/durable-sqlite/session.js.map +1 -1
- package/expo-sqlite/driver.cjs +22 -5
- package/expo-sqlite/driver.cjs.map +1 -1
- package/expo-sqlite/driver.d.cts +3 -2
- package/expo-sqlite/driver.d.ts +3 -2
- package/expo-sqlite/driver.js +12 -8
- package/expo-sqlite/driver.js.map +1 -1
- package/expo-sqlite/migrator.cjs.map +1 -1
- package/expo-sqlite/migrator.d.cts +3 -2
- package/expo-sqlite/migrator.d.ts +3 -2
- package/expo-sqlite/migrator.js.map +1 -1
- package/expo-sqlite/query.cjs +13 -2
- package/expo-sqlite/query.cjs.map +1 -1
- package/expo-sqlite/query.d.cts +2 -1
- package/expo-sqlite/query.d.ts +2 -1
- package/expo-sqlite/query.js +3 -2
- package/expo-sqlite/query.js.map +1 -1
- package/expo-sqlite/session.cjs +47 -4
- package/expo-sqlite/session.cjs.map +1 -1
- package/expo-sqlite/session.d.cts +14 -8
- package/expo-sqlite/session.d.ts +14 -8
- package/expo-sqlite/session.js +47 -4
- package/expo-sqlite/session.js.map +1 -1
- package/gel/driver.cjs +108 -0
- package/gel/driver.cjs.map +1 -0
- package/gel/driver.d.cts +39 -0
- package/gel/driver.d.ts +39 -0
- package/gel/driver.js +72 -0
- package/gel/driver.js.map +1 -0
- package/gel/index.cjs +25 -0
- package/gel/index.cjs.map +1 -0
- package/gel/index.d.cts +2 -0
- package/gel/index.d.ts +2 -0
- package/gel/index.js +3 -0
- package/gel/index.js.map +1 -0
- package/gel/migrator.cjs +5 -0
- package/gel/migrator.cjs.map +1 -0
- package/gel/migrator.d.cts +1 -0
- package/gel/migrator.d.ts +1 -0
- package/gel/migrator.js +4 -0
- package/gel/migrator.js.map +1 -0
- package/gel/session.cjs +181 -0
- package/gel/session.cjs.map +1 -0
- package/gel/session.d.cts +52 -0
- package/gel/session.d.ts +52 -0
- package/gel/session.js +155 -0
- package/gel/session.js.map +1 -0
- package/gel-core/alias.cjs +32 -0
- package/gel-core/alias.cjs.map +1 -0
- package/gel-core/alias.d.cts +4 -0
- package/gel-core/alias.d.ts +4 -0
- package/gel-core/alias.js +8 -0
- package/gel-core/alias.js.map +1 -0
- package/gel-core/checks.cjs +58 -0
- package/gel-core/checks.cjs.map +1 -0
- package/gel-core/checks.d.cts +18 -0
- package/gel-core/checks.d.ts +18 -0
- package/gel-core/checks.js +32 -0
- package/gel-core/checks.js.map +1 -0
- package/gel-core/columns/all.cjs +72 -0
- package/gel-core/columns/all.cjs.map +1 -0
- package/gel-core/columns/all.d.cts +43 -0
- package/gel-core/columns/all.d.ts +43 -0
- package/gel-core/columns/all.js +48 -0
- package/gel-core/columns/all.js.map +1 -0
- package/gel-core/columns/bigint.cjs +54 -0
- package/gel-core/columns/bigint.cjs.map +1 -0
- package/gel-core/columns/bigint.d.cts +23 -0
- package/gel-core/columns/bigint.d.ts +23 -0
- package/gel-core/columns/bigint.js +28 -0
- package/gel-core/columns/bigint.js.map +1 -0
- package/gel-core/columns/bigintT.cjs +60 -0
- package/gel-core/columns/bigintT.cjs.map +1 -0
- package/gel-core/columns/bigintT.d.cts +24 -0
- package/gel-core/columns/bigintT.d.ts +24 -0
- package/gel-core/columns/bigintT.js +34 -0
- package/gel-core/columns/bigintT.js.map +1 -0
- package/gel-core/columns/boolean.cjs +53 -0
- package/gel-core/columns/boolean.cjs.map +1 -0
- package/gel-core/columns/boolean.d.cts +22 -0
- package/gel-core/columns/boolean.d.ts +22 -0
- package/gel-core/columns/boolean.js +27 -0
- package/gel-core/columns/boolean.js.map +1 -0
- package/gel-core/columns/bytes.cjs +56 -0
- package/gel-core/columns/bytes.cjs.map +1 -0
- package/gel-core/columns/bytes.d.cts +22 -0
- package/gel-core/columns/bytes.d.ts +22 -0
- package/gel-core/columns/bytes.js +30 -0
- package/gel-core/columns/bytes.js.map +1 -0
- package/gel-core/columns/common.cjs +213 -0
- package/gel-core/columns/common.cjs.map +1 -0
- package/gel-core/columns/common.d.cts +147 -0
- package/gel-core/columns/common.d.ts +147 -0
- package/gel-core/columns/common.js +184 -0
- package/gel-core/columns/common.js.map +1 -0
- package/gel-core/columns/custom.cjs +77 -0
- package/gel-core/columns/custom.cjs.map +1 -0
- package/gel-core/columns/custom.d.cts +155 -0
- package/gel-core/columns/custom.d.ts +155 -0
- package/gel-core/columns/custom.js +51 -0
- package/gel-core/columns/custom.js.map +1 -0
- package/gel-core/columns/date-duration.cjs +56 -0
- package/gel-core/columns/date-duration.cjs.map +1 -0
- package/gel-core/columns/date-duration.d.cts +23 -0
- package/gel-core/columns/date-duration.d.ts +23 -0
- package/gel-core/columns/date-duration.js +30 -0
- package/gel-core/columns/date-duration.js.map +1 -0
- package/gel-core/columns/date.common.cjs +37 -0
- package/gel-core/columns/date.common.cjs.map +1 -0
- package/gel-core/columns/date.common.d.cts +7 -0
- package/gel-core/columns/date.common.d.ts +7 -0
- package/gel-core/columns/date.common.js +13 -0
- package/gel-core/columns/date.common.js.map +1 -0
- package/gel-core/columns/decimal.cjs +56 -0
- package/gel-core/columns/decimal.cjs.map +1 -0
- package/gel-core/columns/decimal.d.cts +26 -0
- package/gel-core/columns/decimal.d.ts +26 -0
- package/gel-core/columns/decimal.js +30 -0
- package/gel-core/columns/decimal.js.map +1 -0
- package/gel-core/columns/double-precision.cjs +62 -0
- package/gel-core/columns/double-precision.cjs.map +1 -0
- package/gel-core/columns/double-precision.d.cts +23 -0
- package/gel-core/columns/double-precision.d.ts +23 -0
- package/gel-core/columns/double-precision.js +36 -0
- package/gel-core/columns/double-precision.js.map +1 -0
- package/gel-core/columns/duration.cjs +53 -0
- package/gel-core/columns/duration.cjs.map +1 -0
- package/gel-core/columns/duration.d.cts +23 -0
- package/gel-core/columns/duration.d.ts +23 -0
- package/gel-core/columns/duration.js +27 -0
- package/gel-core/columns/duration.js.map +1 -0
- package/gel-core/columns/index.cjs +65 -0
- package/gel-core/columns/index.cjs.map +1 -0
- package/gel-core/columns/index.d.cts +22 -0
- package/gel-core/columns/index.d.ts +22 -0
- package/gel-core/columns/index.js +23 -0
- package/gel-core/columns/index.js.map +1 -0
- package/gel-core/columns/int.common.cjs +67 -0
- package/gel-core/columns/int.common.cjs.map +1 -0
- package/gel-core/columns/int.common.d.cts +15 -0
- package/gel-core/columns/int.common.d.ts +15 -0
- package/gel-core/columns/int.common.js +43 -0
- package/gel-core/columns/int.common.js.map +1 -0
- package/gel-core/columns/integer.cjs +54 -0
- package/gel-core/columns/integer.cjs.map +1 -0
- package/gel-core/columns/integer.d.cts +23 -0
- package/gel-core/columns/integer.d.ts +23 -0
- package/gel-core/columns/integer.js +28 -0
- package/gel-core/columns/integer.js.map +1 -0
- package/gel-core/columns/json.cjs +56 -0
- package/gel-core/columns/json.cjs.map +1 -0
- package/gel-core/columns/json.d.cts +26 -0
- package/gel-core/columns/json.d.ts +26 -0
- package/gel-core/columns/json.js +30 -0
- package/gel-core/columns/json.js.map +1 -0
- package/gel-core/columns/localdate.cjs +57 -0
- package/gel-core/columns/localdate.cjs.map +1 -0
- package/gel-core/columns/localdate.d.cts +24 -0
- package/gel-core/columns/localdate.d.ts +24 -0
- package/gel-core/columns/localdate.js +31 -0
- package/gel-core/columns/localdate.js.map +1 -0
- package/gel-core/columns/localtime.cjs +57 -0
- package/gel-core/columns/localtime.cjs.map +1 -0
- package/gel-core/columns/localtime.d.cts +24 -0
- package/gel-core/columns/localtime.d.ts +24 -0
- package/gel-core/columns/localtime.js +31 -0
- package/gel-core/columns/localtime.js.map +1 -0
- package/gel-core/columns/real.cjs +57 -0
- package/gel-core/columns/real.cjs.map +1 -0
- package/gel-core/columns/real.d.cts +28 -0
- package/gel-core/columns/real.d.ts +28 -0
- package/gel-core/columns/real.js +31 -0
- package/gel-core/columns/real.js.map +1 -0
- package/gel-core/columns/relative-duration.cjs +56 -0
- package/gel-core/columns/relative-duration.cjs.map +1 -0
- package/gel-core/columns/relative-duration.d.cts +23 -0
- package/gel-core/columns/relative-duration.d.ts +23 -0
- package/gel-core/columns/relative-duration.js +30 -0
- package/gel-core/columns/relative-duration.js.map +1 -0
- package/gel-core/columns/smallint.cjs +54 -0
- package/gel-core/columns/smallint.cjs.map +1 -0
- package/gel-core/columns/smallint.d.cts +23 -0
- package/gel-core/columns/smallint.d.ts +23 -0
- package/gel-core/columns/smallint.js +28 -0
- package/gel-core/columns/smallint.js.map +1 -0
- package/gel-core/columns/text.cjs +54 -0
- package/gel-core/columns/text.cjs.map +1 -0
- package/gel-core/columns/text.d.cts +26 -0
- package/gel-core/columns/text.d.ts +26 -0
- package/gel-core/columns/text.js +28 -0
- package/gel-core/columns/text.js.map +1 -0
- package/gel-core/columns/timestamp.cjs +60 -0
- package/gel-core/columns/timestamp.cjs.map +1 -0
- package/gel-core/columns/timestamp.d.cts +28 -0
- package/gel-core/columns/timestamp.d.ts +28 -0
- package/gel-core/columns/timestamp.js +34 -0
- package/gel-core/columns/timestamp.js.map +1 -0
- package/gel-core/columns/timestamptz.cjs +65 -0
- package/gel-core/columns/timestamptz.cjs.map +1 -0
- package/gel-core/columns/timestamptz.d.cts +28 -0
- package/gel-core/columns/timestamptz.d.ts +28 -0
- package/gel-core/columns/timestamptz.js +39 -0
- package/gel-core/columns/timestamptz.js.map +1 -0
- package/gel-core/columns/uuid.cjs +53 -0
- package/gel-core/columns/uuid.cjs.map +1 -0
- package/gel-core/columns/uuid.d.cts +22 -0
- package/gel-core/columns/uuid.d.ts +22 -0
- package/gel-core/columns/uuid.js +27 -0
- package/gel-core/columns/uuid.js.map +1 -0
- package/gel-core/db.cjs +362 -0
- package/gel-core/db.cjs.map +1 -0
- package/gel-core/db.d.cts +288 -0
- package/gel-core/db.d.ts +288 -0
- package/gel-core/db.js +343 -0
- package/gel-core/db.js.map +1 -0
- package/gel-core/dialect.cjs +826 -0
- package/gel-core/dialect.cjs.map +1 -0
- package/gel-core/dialect.d.cts +80 -0
- package/gel-core/dialect.d.ts +80 -0
- package/gel-core/dialect.js +803 -0
- package/gel-core/dialect.js.map +1 -0
- package/gel-core/expressions.cjs +49 -0
- package/gel-core/expressions.cjs.map +1 -0
- package/gel-core/expressions.d.cts +8 -0
- package/gel-core/expressions.d.ts +8 -0
- package/gel-core/expressions.js +22 -0
- package/gel-core/expressions.js.map +1 -0
- package/gel-core/foreign-keys.cjs +100 -0
- package/gel-core/foreign-keys.cjs.map +1 -0
- package/gel-core/foreign-keys.d.cts +48 -0
- package/gel-core/foreign-keys.d.ts +48 -0
- package/gel-core/foreign-keys.js +74 -0
- package/gel-core/foreign-keys.js.map +1 -0
- package/gel-core/index.cjs +61 -0
- package/gel-core/index.cjs.map +1 -0
- package/gel-core/index.d.cts +20 -0
- package/gel-core/index.d.ts +20 -0
- package/gel-core/index.js +21 -0
- package/gel-core/index.js.map +1 -0
- package/gel-core/indexes.cjs +149 -0
- package/gel-core/indexes.cjs.map +1 -0
- package/gel-core/indexes.d.cts +79 -0
- package/gel-core/indexes.d.ts +79 -0
- package/gel-core/indexes.js +121 -0
- package/gel-core/indexes.js.map +1 -0
- package/gel-core/policies.cjs +58 -0
- package/gel-core/policies.cjs.map +1 -0
- package/gel-core/policies.d.cts +24 -0
- package/gel-core/policies.d.ts +24 -0
- package/gel-core/policies.js +33 -0
- package/gel-core/policies.js.map +1 -0
- package/gel-core/primary-keys.cjs +68 -0
- package/gel-core/primary-keys.cjs.map +1 -0
- package/gel-core/primary-keys.d.cts +30 -0
- package/gel-core/primary-keys.d.ts +30 -0
- package/gel-core/primary-keys.js +42 -0
- package/gel-core/primary-keys.js.map +1 -0
- package/gel-core/query-builders/_query.cjs +149 -0
- package/gel-core/query-builders/_query.cjs.map +1 -0
- package/gel-core/query-builders/_query.d.cts +46 -0
- package/gel-core/query-builders/_query.d.ts +46 -0
- package/gel-core/query-builders/_query.js +114 -0
- package/gel-core/query-builders/_query.js.map +1 -0
- package/gel-core/query-builders/count.cjs +73 -0
- package/gel-core/query-builders/count.cjs.map +1 -0
- package/gel-core/query-builders/count.d.cts +25 -0
- package/gel-core/query-builders/count.d.ts +25 -0
- package/gel-core/query-builders/count.js +49 -0
- package/gel-core/query-builders/count.js.map +1 -0
- package/gel-core/query-builders/delete.cjs +105 -0
- package/gel-core/query-builders/delete.cjs.map +1 -0
- package/gel-core/query-builders/delete.d.cts +99 -0
- package/gel-core/query-builders/delete.d.ts +99 -0
- package/gel-core/query-builders/delete.js +81 -0
- package/gel-core/query-builders/delete.js.map +1 -0
- package/gel-core/query-builders/index.cjs +35 -0
- package/gel-core/query-builders/index.cjs.map +1 -0
- package/gel-core/query-builders/index.d.cts +7 -0
- package/gel-core/query-builders/index.d.ts +7 -0
- package/gel-core/query-builders/index.js +8 -0
- package/gel-core/query-builders/index.js.map +1 -0
- package/gel-core/query-builders/insert.cjs +218 -0
- package/gel-core/query-builders/insert.cjs.map +1 -0
- package/gel-core/query-builders/insert.d.cts +116 -0
- package/gel-core/query-builders/insert.d.ts +116 -0
- package/gel-core/query-builders/insert.js +193 -0
- package/gel-core/query-builders/insert.js.map +1 -0
- package/gel-core/query-builders/query-builder.cjs +114 -0
- package/gel-core/query-builders/query-builder.cjs.map +1 -0
- package/gel-core/query-builders/query-builder.d.cts +40 -0
- package/gel-core/query-builders/query-builder.d.ts +40 -0
- package/gel-core/query-builders/query-builder.js +90 -0
- package/gel-core/query-builders/query-builder.js.map +1 -0
- package/gel-core/query-builders/query.cjs +142 -0
- package/gel-core/query-builders/query.cjs.map +1 -0
- package/gel-core/query-builders/query.d.cts +47 -0
- package/gel-core/query-builders/query.d.ts +47 -0
- package/gel-core/query-builders/query.js +119 -0
- package/gel-core/query-builders/query.js.map +1 -0
- package/gel-core/query-builders/raw.cjs +57 -0
- package/gel-core/query-builders/raw.cjs.map +1 -0
- package/gel-core/query-builders/raw.d.cts +22 -0
- package/gel-core/query-builders/raw.d.ts +22 -0
- package/gel-core/query-builders/raw.js +33 -0
- package/gel-core/query-builders/raw.js.map +1 -0
- package/gel-core/query-builders/refresh-materialized-view.cjs +77 -0
- package/gel-core/query-builders/refresh-materialized-view.cjs.map +1 -0
- package/gel-core/query-builders/refresh-materialized-view.d.cts +27 -0
- package/gel-core/query-builders/refresh-materialized-view.d.ts +27 -0
- package/gel-core/query-builders/refresh-materialized-view.js +53 -0
- package/gel-core/query-builders/refresh-materialized-view.js.map +1 -0
- package/gel-core/query-builders/select.cjs +775 -0
- package/gel-core/query-builders/select.cjs.map +1 -0
- package/gel-core/query-builders/select.d.cts +721 -0
- package/gel-core/query-builders/select.d.ts +721 -0
- package/gel-core/query-builders/select.js +748 -0
- package/gel-core/query-builders/select.js.map +1 -0
- package/gel-core/query-builders/select.types.cjs +17 -0
- package/gel-core/query-builders/select.types.cjs.map +1 -0
- package/gel-core/query-builders/select.types.d.cts +138 -0
- package/gel-core/query-builders/select.types.d.ts +138 -0
- package/gel-core/query-builders/select.types.js +1 -0
- package/gel-core/query-builders/select.types.js.map +1 -0
- package/gel-core/query-builders/update.cjs +226 -0
- package/gel-core/query-builders/update.cjs.map +1 -0
- package/gel-core/query-builders/update.d.cts +166 -0
- package/gel-core/query-builders/update.d.ts +166 -0
- package/gel-core/query-builders/update.js +205 -0
- package/gel-core/query-builders/update.js.map +1 -0
- package/gel-core/roles.cjs +57 -0
- package/gel-core/roles.cjs.map +1 -0
- package/gel-core/roles.d.cts +13 -0
- package/gel-core/roles.d.ts +13 -0
- package/gel-core/roles.js +32 -0
- package/gel-core/roles.js.map +1 -0
- package/gel-core/schema.cjs +74 -0
- package/gel-core/schema.cjs.map +1 -0
- package/gel-core/schema.d.cts +15 -0
- package/gel-core/schema.d.ts +15 -0
- package/gel-core/schema.js +48 -0
- package/gel-core/schema.js.map +1 -0
- package/gel-core/sequence.cjs +52 -0
- package/gel-core/sequence.cjs.map +1 -0
- package/gel-core/sequence.d.cts +18 -0
- package/gel-core/sequence.d.ts +18 -0
- package/gel-core/sequence.js +25 -0
- package/gel-core/sequence.js.map +1 -0
- package/gel-core/session.cjs +95 -0
- package/gel-core/session.cjs.map +1 -0
- package/gel-core/session.d.cts +59 -0
- package/gel-core/session.d.ts +59 -0
- package/gel-core/session.js +69 -0
- package/gel-core/session.js.map +1 -0
- package/gel-core/subquery.cjs +17 -0
- package/gel-core/subquery.cjs.map +1 -0
- package/gel-core/subquery.d.cts +5 -0
- package/gel-core/subquery.d.ts +5 -0
- package/gel-core/subquery.js +1 -0
- package/gel-core/subquery.js.map +1 -0
- package/gel-core/table.cjs +100 -0
- package/gel-core/table.cjs.map +1 -0
- package/gel-core/table.d.cts +95 -0
- package/gel-core/table.d.ts +95 -0
- package/gel-core/table.js +71 -0
- package/gel-core/table.js.map +1 -0
- package/gel-core/unique-constraint.cjs +89 -0
- package/gel-core/unique-constraint.cjs.map +1 -0
- package/gel-core/unique-constraint.d.cts +25 -0
- package/gel-core/unique-constraint.d.ts +25 -0
- package/gel-core/unique-constraint.js +61 -0
- package/gel-core/unique-constraint.js.map +1 -0
- package/gel-core/utils.cjs +100 -0
- package/gel-core/utils.cjs.map +1 -0
- package/gel-core/utils.d.cts +51 -0
- package/gel-core/utils.d.ts +51 -0
- package/gel-core/utils.js +74 -0
- package/gel-core/utils.js.map +1 -0
- package/gel-core/view-base.cjs +33 -0
- package/gel-core/view-base.cjs.map +1 -0
- package/gel-core/view-base.d.cts +8 -0
- package/gel-core/view-base.d.ts +8 -0
- package/gel-core/view-base.js +9 -0
- package/gel-core/view-base.js.map +1 -0
- package/gel-core/view-common.cjs +29 -0
- package/gel-core/view-common.cjs.map +1 -0
- package/gel-core/view-common.d.cts +1 -0
- package/gel-core/view-common.d.ts +1 -0
- package/gel-core/view-common.js +5 -0
- package/gel-core/view-common.js.map +1 -0
- package/gel-core/view.cjs +302 -0
- package/gel-core/view.cjs.map +1 -0
- package/gel-core/view.d.cts +150 -0
- package/gel-core/view.d.ts +150 -0
- package/gel-core/view.js +268 -0
- package/gel-core/view.js.map +1 -0
- package/libsql/driver-core.cjs +22 -5
- package/libsql/driver-core.cjs.map +1 -1
- package/libsql/driver-core.d.cts +2 -1
- package/libsql/driver-core.d.ts +2 -1
- package/libsql/driver-core.js +12 -8
- package/libsql/driver-core.js.map +1 -1
- package/libsql/driver.cjs.map +1 -1
- package/libsql/driver.d.cts +6 -5
- package/libsql/driver.d.ts +6 -5
- package/libsql/driver.js.map +1 -1
- package/libsql/http/index.cjs.map +1 -1
- package/libsql/http/index.d.cts +6 -5
- package/libsql/http/index.d.ts +6 -5
- package/libsql/http/index.js.map +1 -1
- package/libsql/migrator.cjs.map +1 -1
- package/libsql/migrator.d.cts +2 -1
- package/libsql/migrator.d.ts +2 -1
- package/libsql/migrator.js.map +1 -1
- package/libsql/node/index.cjs.map +1 -1
- package/libsql/node/index.d.cts +6 -5
- package/libsql/node/index.d.ts +6 -5
- package/libsql/node/index.js.map +1 -1
- package/libsql/session.cjs +56 -4
- package/libsql/session.cjs.map +1 -1
- package/libsql/session.d.cts +15 -9
- package/libsql/session.d.ts +15 -9
- package/libsql/session.js +56 -4
- package/libsql/session.js.map +1 -1
- package/libsql/sqlite3/index.cjs.map +1 -1
- package/libsql/sqlite3/index.d.cts +6 -5
- package/libsql/sqlite3/index.d.ts +6 -5
- package/libsql/sqlite3/index.js.map +1 -1
- package/libsql/wasm/index.cjs.map +1 -1
- package/libsql/wasm/index.d.cts +6 -5
- package/libsql/wasm/index.d.ts +6 -5
- package/libsql/wasm/index.js.map +1 -1
- package/libsql/web/index.cjs.map +1 -1
- package/libsql/web/index.d.cts +6 -5
- package/libsql/web/index.d.ts +6 -5
- package/libsql/web/index.js.map +1 -1
- package/libsql/ws/index.cjs.map +1 -1
- package/libsql/ws/index.d.cts +6 -5
- package/libsql/ws/index.d.ts +6 -5
- package/libsql/ws/index.js.map +1 -1
- package/mysql-core/db.cjs +30 -6
- package/mysql-core/db.cjs.map +1 -1
- package/mysql-core/db.d.cts +15 -8
- package/mysql-core/db.d.ts +15 -8
- package/mysql-core/db.js +29 -5
- package/mysql-core/db.js.map +1 -1
- package/mysql-core/dialect.cjs +198 -15
- package/mysql-core/dialect.cjs.map +1 -1
- package/mysql-core/dialect.d.cts +36 -13
- package/mysql-core/dialect.d.ts +36 -13
- package/mysql-core/dialect.js +196 -22
- package/mysql-core/dialect.js.map +1 -1
- package/mysql-core/query-builders/_query.cjs +149 -0
- package/mysql-core/query-builders/_query.cjs.map +1 -0
- package/mysql-core/query-builders/_query.d.cts +44 -0
- package/mysql-core/query-builders/_query.d.ts +44 -0
- package/mysql-core/query-builders/_query.js +114 -0
- package/mysql-core/query-builders/_query.js.map +1 -0
- package/mysql-core/query-builders/count.cjs.map +1 -1
- package/mysql-core/query-builders/count.d.cts +1 -1
- package/mysql-core/query-builders/count.d.ts +1 -1
- package/mysql-core/query-builders/count.js.map +1 -1
- package/mysql-core/query-builders/query.cjs +18 -31
- package/mysql-core/query-builders/query.cjs.map +1 -1
- package/mysql-core/query-builders/query.d.cts +8 -10
- package/mysql-core/query-builders/query.d.ts +8 -10
- package/mysql-core/query-builders/query.js +18 -31
- package/mysql-core/query-builders/query.js.map +1 -1
- package/mysql-core/session.cjs +3 -2
- package/mysql-core/session.cjs.map +1 -1
- package/mysql-core/session.d.cts +10 -7
- package/mysql-core/session.d.ts +10 -7
- package/mysql-core/session.js +3 -2
- package/mysql-core/session.js.map +1 -1
- package/mysql-proxy/driver.cjs +22 -5
- package/mysql-proxy/driver.cjs.map +1 -1
- package/mysql-proxy/driver.d.cts +3 -2
- package/mysql-proxy/driver.d.ts +3 -2
- package/mysql-proxy/driver.js +12 -8
- package/mysql-proxy/driver.js.map +1 -1
- package/mysql-proxy/migrator.cjs.map +1 -1
- package/mysql-proxy/migrator.d.cts +2 -1
- package/mysql-proxy/migrator.d.ts +2 -1
- package/mysql-proxy/migrator.js.map +1 -1
- package/mysql-proxy/session.cjs +27 -2
- package/mysql-proxy/session.cjs.map +1 -1
- package/mysql-proxy/session.d.cts +13 -8
- package/mysql-proxy/session.d.ts +13 -8
- package/mysql-proxy/session.js +27 -2
- package/mysql-proxy/session.js.map +1 -1
- package/mysql2/driver.cjs +24 -7
- package/mysql2/driver.cjs.map +1 -1
- package/mysql2/driver.d.cts +10 -9
- package/mysql2/driver.d.ts +10 -9
- package/mysql2/driver.js +14 -10
- package/mysql2/driver.js.map +1 -1
- package/mysql2/migrator.cjs.map +1 -1
- package/mysql2/migrator.d.cts +2 -1
- package/mysql2/migrator.d.ts +2 -1
- package/mysql2/migrator.js.map +1 -1
- package/mysql2/session.cjs +30 -2
- package/mysql2/session.cjs.map +1 -1
- package/mysql2/session.d.cts +13 -8
- package/mysql2/session.d.ts +13 -8
- package/mysql2/session.js +30 -2
- package/mysql2/session.js.map +1 -1
- package/neon-http/driver.cjs +21 -7
- package/neon-http/driver.cjs.map +1 -1
- package/neon-http/driver.d.cts +10 -9
- package/neon-http/driver.d.ts +10 -9
- package/neon-http/driver.js +11 -7
- package/neon-http/driver.js.map +1 -1
- package/neon-http/migrator.cjs.map +1 -1
- package/neon-http/migrator.d.cts +2 -1
- package/neon-http/migrator.d.ts +2 -1
- package/neon-http/migrator.js.map +1 -1
- package/neon-http/session.cjs +32 -2
- package/neon-http/session.cjs.map +1 -1
- package/neon-http/session.d.cts +13 -8
- package/neon-http/session.d.ts +13 -8
- package/neon-http/session.js +32 -2
- package/neon-http/session.js.map +1 -1
- package/neon-serverless/driver.cjs +18 -7
- package/neon-serverless/driver.cjs.map +1 -1
- package/neon-serverless/driver.d.cts +9 -8
- package/neon-serverless/driver.d.ts +9 -8
- package/neon-serverless/driver.js +8 -10
- package/neon-serverless/driver.js.map +1 -1
- package/neon-serverless/migrator.cjs.map +1 -1
- package/neon-serverless/migrator.d.cts +2 -1
- package/neon-serverless/migrator.d.ts +2 -1
- package/neon-serverless/migrator.js.map +1 -1
- package/neon-serverless/session.cjs +40 -5
- package/neon-serverless/session.cjs.map +1 -1
- package/neon-serverless/session.d.cts +13 -8
- package/neon-serverless/session.d.ts +13 -8
- package/neon-serverless/session.js +40 -5
- package/neon-serverless/session.js.map +1 -1
- package/node-postgres/driver.cjs +13 -7
- package/node-postgres/driver.cjs.map +1 -1
- package/node-postgres/driver.d.cts +9 -8
- package/node-postgres/driver.d.ts +9 -8
- package/node-postgres/driver.js +13 -10
- package/node-postgres/driver.js.map +1 -1
- package/node-postgres/migrator.cjs.map +1 -1
- package/node-postgres/migrator.d.cts +2 -1
- package/node-postgres/migrator.d.ts +2 -1
- package/node-postgres/migrator.js.map +1 -1
- package/node-postgres/session.cjs +45 -4
- package/node-postgres/session.cjs.map +1 -1
- package/node-postgres/session.d.cts +13 -8
- package/node-postgres/session.d.ts +13 -8
- package/node-postgres/session.js +45 -4
- package/node-postgres/session.js.map +1 -1
- package/op-sqlite/driver.cjs +22 -5
- package/op-sqlite/driver.cjs.map +1 -1
- package/op-sqlite/driver.d.cts +3 -2
- package/op-sqlite/driver.d.ts +3 -2
- package/op-sqlite/driver.js +12 -8
- package/op-sqlite/driver.js.map +1 -1
- package/op-sqlite/migrator.cjs.map +1 -1
- package/op-sqlite/migrator.d.cts +3 -2
- package/op-sqlite/migrator.d.ts +3 -2
- package/op-sqlite/migrator.js.map +1 -1
- package/op-sqlite/session.cjs +47 -4
- package/op-sqlite/session.cjs.map +1 -1
- package/op-sqlite/session.d.cts +14 -8
- package/op-sqlite/session.d.ts +14 -8
- package/op-sqlite/session.js +47 -4
- package/op-sqlite/session.js.map +1 -1
- package/package.json +801 -4
- package/pg-core/db.cjs +32 -5
- package/pg-core/db.cjs.map +1 -1
- package/pg-core/db.d.cts +16 -9
- package/pg-core/db.d.ts +16 -9
- package/pg-core/db.js +31 -4
- package/pg-core/db.js.map +1 -1
- package/pg-core/dialect.cjs +176 -488
- package/pg-core/dialect.cjs.map +1 -1
- package/pg-core/dialect.d.cts +27 -8
- package/pg-core/dialect.d.ts +27 -8
- package/pg-core/dialect.js +174 -495
- package/pg-core/dialect.js.map +1 -1
- package/pg-core/query-builders/_query.cjs +155 -0
- package/pg-core/query-builders/_query.cjs.map +1 -0
- package/pg-core/query-builders/_query.d.cts +47 -0
- package/pg-core/query-builders/_query.d.ts +47 -0
- package/pg-core/query-builders/_query.js +120 -0
- package/pg-core/query-builders/_query.js.map +1 -0
- package/pg-core/query-builders/count.cjs.map +1 -1
- package/pg-core/query-builders/count.d.cts +1 -1
- package/pg-core/query-builders/count.d.ts +1 -1
- package/pg-core/query-builders/count.js.map +1 -1
- package/pg-core/query-builders/query.cjs +15 -18
- package/pg-core/query-builders/query.cjs.map +1 -1
- package/pg-core/query-builders/query.d.cts +6 -6
- package/pg-core/query-builders/query.d.ts +6 -6
- package/pg-core/query-builders/query.js +15 -18
- package/pg-core/query-builders/query.js.map +1 -1
- package/pg-core/session.cjs +3 -2
- package/pg-core/session.cjs.map +1 -1
- package/pg-core/session.d.cts +9 -6
- package/pg-core/session.d.ts +9 -6
- package/pg-core/session.js +3 -2
- package/pg-core/session.js.map +1 -1
- package/pg-core/table.cjs +2 -0
- package/pg-core/table.cjs.map +1 -1
- package/pg-core/table.js +2 -0
- package/pg-core/table.js.map +1 -1
- package/pg-proxy/driver.cjs +21 -5
- package/pg-proxy/driver.cjs.map +1 -1
- package/pg-proxy/driver.d.cts +3 -2
- package/pg-proxy/driver.d.ts +3 -2
- package/pg-proxy/driver.js +11 -8
- package/pg-proxy/driver.js.map +1 -1
- package/pg-proxy/migrator.cjs.map +1 -1
- package/pg-proxy/migrator.d.cts +2 -1
- package/pg-proxy/migrator.d.ts +2 -1
- package/pg-proxy/migrator.js.map +1 -1
- package/pg-proxy/session.cjs +37 -2
- package/pg-proxy/session.cjs.map +1 -1
- package/pg-proxy/session.d.cts +13 -8
- package/pg-proxy/session.d.ts +13 -8
- package/pg-proxy/session.js +37 -2
- package/pg-proxy/session.js.map +1 -1
- package/pglite/driver.cjs +23 -7
- package/pglite/driver.cjs.map +1 -1
- package/pglite/driver.d.cts +9 -8
- package/pglite/driver.d.ts +9 -8
- package/pglite/driver.js +13 -10
- package/pglite/driver.js.map +1 -1
- package/pglite/migrator.cjs.map +1 -1
- package/pglite/migrator.d.cts +2 -1
- package/pglite/migrator.d.ts +2 -1
- package/pglite/migrator.js.map +1 -1
- package/pglite/session.cjs +34 -3
- package/pglite/session.cjs.map +1 -1
- package/pglite/session.d.cts +13 -8
- package/pglite/session.d.ts +13 -8
- package/pglite/session.js +34 -3
- package/pglite/session.js.map +1 -1
- package/planetscale-serverless/driver.cjs +22 -5
- package/planetscale-serverless/driver.cjs.map +1 -1
- package/planetscale-serverless/driver.d.cts +7 -6
- package/planetscale-serverless/driver.d.ts +7 -6
- package/planetscale-serverless/driver.js +12 -8
- package/planetscale-serverless/driver.js.map +1 -1
- package/planetscale-serverless/migrator.cjs.map +1 -1
- package/planetscale-serverless/migrator.d.cts +2 -1
- package/planetscale-serverless/migrator.d.ts +2 -1
- package/planetscale-serverless/migrator.js.map +1 -1
- package/planetscale-serverless/session.cjs +45 -5
- package/planetscale-serverless/session.cjs.map +1 -1
- package/planetscale-serverless/session.d.cts +14 -9
- package/planetscale-serverless/session.d.ts +14 -9
- package/planetscale-serverless/session.js +45 -5
- package/planetscale-serverless/session.js.map +1 -1
- package/postgres-js/driver.cjs +6 -5
- package/postgres-js/driver.cjs.map +1 -1
- package/postgres-js/driver.d.cts +7 -6
- package/postgres-js/driver.d.ts +7 -6
- package/postgres-js/driver.js +6 -8
- package/postgres-js/driver.js.map +1 -1
- package/postgres-js/migrator.cjs.map +1 -1
- package/postgres-js/migrator.d.cts +2 -1
- package/postgres-js/migrator.d.ts +2 -1
- package/postgres-js/migrator.js.map +1 -1
- package/postgres-js/session.cjs +51 -6
- package/postgres-js/session.cjs.map +1 -1
- package/postgres-js/session.d.cts +15 -9
- package/postgres-js/session.d.ts +15 -9
- package/postgres-js/session.js +51 -6
- package/postgres-js/session.js.map +1 -1
- package/prisma/mysql/driver.cjs +1 -1
- package/prisma/mysql/driver.cjs.map +1 -1
- package/prisma/mysql/driver.js +1 -1
- package/prisma/mysql/driver.js.map +1 -1
- package/prisma/mysql/session.cjs +3 -0
- package/prisma/mysql/session.cjs.map +1 -1
- package/prisma/mysql/session.d.cts +3 -1
- package/prisma/mysql/session.d.ts +3 -1
- package/prisma/mysql/session.js +3 -0
- package/prisma/mysql/session.js.map +1 -1
- package/prisma/pg/driver.cjs +1 -1
- package/prisma/pg/driver.cjs.map +1 -1
- package/prisma/pg/driver.js +1 -1
- package/prisma/pg/driver.js.map +1 -1
- package/prisma/pg/session.cjs +3 -0
- package/prisma/pg/session.cjs.map +1 -1
- package/prisma/pg/session.d.cts +3 -1
- package/prisma/pg/session.d.ts +3 -1
- package/prisma/pg/session.js +3 -0
- package/prisma/pg/session.js.map +1 -1
- package/prisma/sqlite/driver.cjs +1 -1
- package/prisma/sqlite/driver.cjs.map +1 -1
- package/prisma/sqlite/driver.js +1 -1
- package/prisma/sqlite/driver.js.map +1 -1
- package/prisma/sqlite/session.cjs +3 -0
- package/prisma/sqlite/session.cjs.map +1 -1
- package/prisma/sqlite/session.d.cts +4 -2
- package/prisma/sqlite/session.d.ts +4 -2
- package/prisma/sqlite/session.js +3 -0
- package/prisma/sqlite/session.js.map +1 -1
- package/relations.cjs +657 -245
- package/relations.cjs.map +1 -1
- package/relations.d.cts +339 -140
- package/relations.d.ts +339 -140
- package/relations.js +643 -240
- package/relations.js.map +1 -1
- package/singlestore/driver.cjs +1 -1
- package/singlestore/driver.cjs.map +1 -1
- package/singlestore/driver.d.cts +1 -1
- package/singlestore/driver.d.ts +1 -1
- package/singlestore/driver.js +3 -3
- package/singlestore/driver.js.map +1 -1
- package/singlestore/session.cjs.map +1 -1
- package/singlestore/session.d.cts +4 -4
- package/singlestore/session.d.ts +4 -4
- package/singlestore/session.js.map +1 -1
- package/singlestore-core/db.cjs.map +1 -1
- package/singlestore-core/db.d.cts +3 -3
- package/singlestore-core/db.d.ts +3 -3
- package/singlestore-core/db.js.map +1 -1
- package/singlestore-core/dialect.cjs +16 -6
- package/singlestore-core/dialect.cjs.map +1 -1
- package/singlestore-core/dialect.d.cts +6 -6
- package/singlestore-core/dialect.d.ts +6 -6
- package/singlestore-core/dialect.js +6 -12
- package/singlestore-core/dialect.js.map +1 -1
- package/singlestore-core/query-builders/query.cjs +12 -2
- package/singlestore-core/query-builders/query.cjs.map +1 -1
- package/singlestore-core/query-builders/query.d.cts +6 -6
- package/singlestore-core/query-builders/query.d.ts +6 -6
- package/singlestore-core/query-builders/query.js +2 -4
- package/singlestore-core/query-builders/query.js.map +1 -1
- package/singlestore-core/session.cjs.map +1 -1
- package/singlestore-core/session.d.cts +5 -5
- package/singlestore-core/session.d.ts +5 -5
- package/singlestore-core/session.js.map +1 -1
- package/singlestore-proxy/driver.cjs +1 -1
- package/singlestore-proxy/driver.cjs.map +1 -1
- package/singlestore-proxy/driver.js +3 -3
- package/singlestore-proxy/driver.js.map +1 -1
- package/singlestore-proxy/session.cjs.map +1 -1
- package/singlestore-proxy/session.d.cts +4 -4
- package/singlestore-proxy/session.d.ts +4 -4
- package/singlestore-proxy/session.js.map +1 -1
- package/sql/expressions/conditions.cjs.map +1 -1
- package/sql/expressions/conditions.d.cts +4 -4
- package/sql/expressions/conditions.d.ts +4 -4
- package/sql/expressions/conditions.js.map +1 -1
- package/sql/sql.cjs +21 -0
- package/sql/sql.cjs.map +1 -1
- package/sql/sql.d.cts +8 -8
- package/sql/sql.d.ts +8 -8
- package/sql/sql.js +22 -1
- package/sql/sql.js.map +1 -1
- package/sql-js/driver.cjs +16 -5
- package/sql-js/driver.cjs.map +1 -1
- package/sql-js/driver.d.cts +3 -2
- package/sql-js/driver.d.ts +3 -2
- package/sql-js/driver.js +6 -8
- package/sql-js/driver.js.map +1 -1
- package/sql-js/migrator.cjs.map +1 -1
- package/sql-js/migrator.d.cts +2 -1
- package/sql-js/migrator.d.ts +2 -1
- package/sql-js/migrator.js.map +1 -1
- package/sql-js/session.cjs +71 -36
- package/sql-js/session.cjs.map +1 -1
- package/sql-js/session.d.cts +16 -13
- package/sql-js/session.d.ts +16 -13
- package/sql-js/session.js +71 -36
- package/sql-js/session.js.map +1 -1
- package/sqlite-core/db.cjs +39 -12
- package/sqlite-core/db.cjs.map +1 -1
- package/sqlite-core/db.d.cts +16 -8
- package/sqlite-core/db.d.ts +16 -8
- package/sqlite-core/db.js +38 -11
- package/sqlite-core/db.js.map +1 -1
- package/sqlite-core/dialect.cjs +187 -7
- package/sqlite-core/dialect.cjs.map +1 -1
- package/sqlite-core/dialect.d.cts +31 -9
- package/sqlite-core/dialect.d.ts +31 -9
- package/sqlite-core/dialect.js +185 -14
- package/sqlite-core/dialect.js.map +1 -1
- package/sqlite-core/query-builders/_query.cjs +187 -0
- package/sqlite-core/query-builders/_query.cjs.map +1 -0
- package/sqlite-core/query-builders/_query.d.cts +55 -0
- package/sqlite-core/query-builders/_query.d.ts +55 -0
- package/sqlite-core/query-builders/_query.js +151 -0
- package/sqlite-core/query-builders/_query.js.map +1 -0
- package/sqlite-core/query-builders/count.cjs.map +1 -1
- package/sqlite-core/query-builders/count.d.cts +1 -1
- package/sqlite-core/query-builders/count.d.ts +1 -1
- package/sqlite-core/query-builders/count.js.map +1 -1
- package/sqlite-core/query-builders/delete.cjs.map +1 -1
- package/sqlite-core/query-builders/delete.d.cts +1 -1
- package/sqlite-core/query-builders/delete.d.ts +1 -1
- package/sqlite-core/query-builders/delete.js.map +1 -1
- package/sqlite-core/query-builders/insert.cjs.map +1 -1
- package/sqlite-core/query-builders/insert.d.cts +3 -3
- package/sqlite-core/query-builders/insert.d.ts +3 -3
- package/sqlite-core/query-builders/insert.js.map +1 -1
- package/sqlite-core/query-builders/query.cjs +56 -35
- package/sqlite-core/query-builders/query.cjs.map +1 -1
- package/sqlite-core/query-builders/query.d.cts +18 -17
- package/sqlite-core/query-builders/query.d.ts +18 -17
- package/sqlite-core/query-builders/query.js +56 -35
- package/sqlite-core/query-builders/query.js.map +1 -1
- package/sqlite-core/query-builders/select.cjs.map +1 -1
- package/sqlite-core/query-builders/select.d.cts +3 -3
- package/sqlite-core/query-builders/select.d.ts +3 -3
- package/sqlite-core/query-builders/select.js.map +1 -1
- package/sqlite-core/query-builders/update.cjs.map +1 -1
- package/sqlite-core/query-builders/update.d.cts +3 -3
- package/sqlite-core/query-builders/update.d.ts +3 -3
- package/sqlite-core/query-builders/update.js.map +1 -1
- package/sqlite-core/session.cjs +6 -2
- package/sqlite-core/session.cjs.map +1 -1
- package/sqlite-core/session.d.cts +15 -7
- package/sqlite-core/session.d.ts +15 -7
- package/sqlite-core/session.js +6 -2
- package/sqlite-core/session.js.map +1 -1
- package/sqlite-proxy/driver.cjs +23 -5
- package/sqlite-proxy/driver.cjs.map +1 -1
- package/sqlite-proxy/driver.d.cts +4 -3
- package/sqlite-proxy/driver.d.ts +4 -3
- package/sqlite-proxy/driver.js +13 -5
- package/sqlite-proxy/driver.js.map +1 -1
- package/sqlite-proxy/migrator.cjs.map +1 -1
- package/sqlite-proxy/migrator.d.cts +2 -1
- package/sqlite-proxy/migrator.d.ts +2 -1
- package/sqlite-proxy/migrator.js.map +1 -1
- package/sqlite-proxy/session.cjs +50 -6
- package/sqlite-proxy/session.cjs.map +1 -1
- package/sqlite-proxy/session.d.cts +14 -8
- package/sqlite-proxy/session.d.ts +14 -8
- package/sqlite-proxy/session.js +50 -6
- package/sqlite-proxy/session.js.map +1 -1
- package/table.cjs.map +1 -1
- package/table.d.cts +2 -2
- package/table.d.ts +2 -2
- package/table.js.map +1 -1
- package/tidb-serverless/driver.cjs +22 -5
- package/tidb-serverless/driver.cjs.map +1 -1
- package/tidb-serverless/driver.d.cts +7 -6
- package/tidb-serverless/driver.d.ts +7 -6
- package/tidb-serverless/driver.js +12 -8
- package/tidb-serverless/driver.js.map +1 -1
- package/tidb-serverless/migrator.cjs.map +1 -1
- package/tidb-serverless/migrator.d.cts +2 -1
- package/tidb-serverless/migrator.d.ts +2 -1
- package/tidb-serverless/migrator.js.map +1 -1
- package/tidb-serverless/session.cjs +62 -5
- package/tidb-serverless/session.cjs.map +1 -1
- package/tidb-serverless/session.d.cts +14 -9
- package/tidb-serverless/session.d.ts +14 -9
- package/tidb-serverless/session.js +62 -5
- package/tidb-serverless/session.js.map +1 -1
- package/utils.cjs +2 -2
- package/utils.cjs.map +1 -1
- package/utils.d.cts +3 -1
- package/utils.d.ts +3 -1
- package/utils.js +2 -2
- package/utils.js.map +1 -1
- package/vercel-postgres/driver.cjs +23 -7
- package/vercel-postgres/driver.cjs.map +1 -1
- package/vercel-postgres/driver.d.cts +9 -8
- package/vercel-postgres/driver.d.ts +9 -8
- package/vercel-postgres/driver.js +13 -10
- package/vercel-postgres/driver.js.map +1 -1
- package/vercel-postgres/migrator.cjs.map +1 -1
- package/vercel-postgres/migrator.d.cts +2 -1
- package/vercel-postgres/migrator.d.ts +2 -1
- package/vercel-postgres/migrator.js.map +1 -1
- package/vercel-postgres/session.cjs +34 -4
- package/vercel-postgres/session.cjs.map +1 -1
- package/vercel-postgres/session.d.cts +13 -8
- package/vercel-postgres/session.d.ts +13 -8
- package/vercel-postgres/session.js +34 -4
- package/vercel-postgres/session.js.map +1 -1
- package/version.cjs +1 -1
- package/version.d.cts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/xata-http/driver.cjs +17 -5
- package/xata-http/driver.cjs.map +1 -1
- package/xata-http/driver.d.cts +5 -4
- package/xata-http/driver.d.ts +5 -4
- package/xata-http/driver.js +7 -5
- package/xata-http/driver.js.map +1 -1
- package/xata-http/migrator.cjs.map +1 -1
- package/xata-http/migrator.d.cts +2 -1
- package/xata-http/migrator.d.ts +2 -1
- package/xata-http/migrator.js.map +1 -1
- package/xata-http/session.cjs +30 -2
- package/xata-http/session.cjs.map +1 -1
- package/xata-http/session.d.cts +13 -8
- package/xata-http/session.d.ts +13 -8
- package/xata-http/session.js +30 -2
- package/xata-http/session.js.map +1 -1
|
@@ -0,0 +1,803 @@
|
|
|
1
|
+
import * as V1 from "../_relations.js";
|
|
2
|
+
import { aliasedTable, aliasedTableColumn, mapColumnsInAliasedSQLToAlias, mapColumnsInSQLToAlias } from "../alias.js";
|
|
3
|
+
import { CasingCache } from "../casing.js";
|
|
4
|
+
import { Column } from "../column.js";
|
|
5
|
+
import { entityKind, is } from "../entity.js";
|
|
6
|
+
import { DrizzleError } from "../errors.js";
|
|
7
|
+
import { GelColumn, GelDecimal, GelJson, GelUUID } from "./columns/index.js";
|
|
8
|
+
import { GelTable } from "./table.js";
|
|
9
|
+
import {
|
|
10
|
+
getTableAsAliasSQL,
|
|
11
|
+
One,
|
|
12
|
+
relationExtrasToSQL,
|
|
13
|
+
relationsFilterToSQL,
|
|
14
|
+
relationsOrderToSQL,
|
|
15
|
+
relationToSQL
|
|
16
|
+
} from "../relations.js";
|
|
17
|
+
import { and, eq, isSQLWrapper, View } from "../sql/index.js";
|
|
18
|
+
import {
|
|
19
|
+
Param,
|
|
20
|
+
SQL,
|
|
21
|
+
sql
|
|
22
|
+
} from "../sql/sql.js";
|
|
23
|
+
import { Subquery } from "../subquery.js";
|
|
24
|
+
import { Columns, getTableName, getTableUniqueName, Table } from "../table.js";
|
|
25
|
+
import { orderSelectedFields } from "../utils.js";
|
|
26
|
+
import { ViewBaseConfig } from "../view-common.js";
|
|
27
|
+
import { GelTimestamp } from "./columns/timestamp.js";
|
|
28
|
+
import { GelViewBase } from "./view-base.js";
|
|
29
|
+
class GelDialect {
|
|
30
|
+
static [entityKind] = "GelDialect";
|
|
31
|
+
/** @internal */
|
|
32
|
+
casing;
|
|
33
|
+
constructor(config) {
|
|
34
|
+
this.casing = new CasingCache(config?.casing);
|
|
35
|
+
}
|
|
36
|
+
// TODO can not migrate gel with drizzle
|
|
37
|
+
// async migrate(migrations: MigrationMeta[], session: GelSession, config: string | MigrationConfig): Promise<void> {
|
|
38
|
+
// const migrationsTable = typeof config === 'string'
|
|
39
|
+
// ? '__drizzle_migrations'
|
|
40
|
+
// : config.migrationsTable ?? '__drizzle_migrations';
|
|
41
|
+
// const migrationsSchema = typeof config === 'string' ? 'drizzle' : config.migrationsSchema ?? 'drizzle';
|
|
42
|
+
// const migrationTableCreate = sql`
|
|
43
|
+
// CREATE TABLE IF NOT EXISTS ${sql.identifier(migrationsSchema)}.${sql.identifier(migrationsTable)} (
|
|
44
|
+
// id SERIAL PRIMARY KEY,
|
|
45
|
+
// hash text NOT NULL,
|
|
46
|
+
// created_at bigint
|
|
47
|
+
// )
|
|
48
|
+
// `;
|
|
49
|
+
// await session.execute(sql`CREATE SCHEMA IF NOT EXISTS ${sql.identifier(migrationsSchema)}`);
|
|
50
|
+
// await session.execute(migrationTableCreate);
|
|
51
|
+
// const dbMigrations = await session.all<{ id: number; hash: string; created_at: string }>(
|
|
52
|
+
// sql`select id, hash, created_at from ${sql.identifier(migrationsSchema)}.${
|
|
53
|
+
// sql.identifier(migrationsTable)
|
|
54
|
+
// } order by created_at desc limit 1`,
|
|
55
|
+
// );
|
|
56
|
+
// const lastDbMigration = dbMigrations[0];
|
|
57
|
+
// await session.transaction(async (tx) => {
|
|
58
|
+
// for await (const migration of migrations) {
|
|
59
|
+
// if (
|
|
60
|
+
// !lastDbMigration
|
|
61
|
+
// || Number(lastDbMigration.created_at) < migration.folderMillis
|
|
62
|
+
// ) {
|
|
63
|
+
// for (const stmt of migration.sql) {
|
|
64
|
+
// await tx.execute(sql.raw(stmt));
|
|
65
|
+
// }
|
|
66
|
+
// await tx.execute(
|
|
67
|
+
// sql`insert into ${sql.identifier(migrationsSchema)}.${
|
|
68
|
+
// sql.identifier(migrationsTable)
|
|
69
|
+
// } ("hash", "created_at") values(${migration.hash}, ${migration.folderMillis})`,
|
|
70
|
+
// );
|
|
71
|
+
// }
|
|
72
|
+
// }
|
|
73
|
+
// });
|
|
74
|
+
// }
|
|
75
|
+
escapeName(name) {
|
|
76
|
+
return `"${name}"`;
|
|
77
|
+
}
|
|
78
|
+
escapeParam(num) {
|
|
79
|
+
return `$${num + 1}`;
|
|
80
|
+
}
|
|
81
|
+
escapeString(str) {
|
|
82
|
+
return `'${str.replace(/'/g, "''")}'`;
|
|
83
|
+
}
|
|
84
|
+
buildWithCTE(queries) {
|
|
85
|
+
if (!queries?.length)
|
|
86
|
+
return void 0;
|
|
87
|
+
const withSqlChunks = [sql`with `];
|
|
88
|
+
for (const [i, w] of queries.entries()) {
|
|
89
|
+
withSqlChunks.push(sql`${sql.identifier(w._.alias)} as (${w._.sql})`);
|
|
90
|
+
if (i < queries.length - 1) {
|
|
91
|
+
withSqlChunks.push(sql`, `);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
withSqlChunks.push(sql` `);
|
|
95
|
+
return sql.join(withSqlChunks);
|
|
96
|
+
}
|
|
97
|
+
buildDeleteQuery({ table, where, returning, withList }) {
|
|
98
|
+
const withSql = this.buildWithCTE(withList);
|
|
99
|
+
const returningSql = returning ? sql` returning ${this.buildSelection(returning, { isSingleTable: true })}` : void 0;
|
|
100
|
+
const whereSql = where ? sql` where ${where}` : void 0;
|
|
101
|
+
return sql`${withSql}delete from ${table}${whereSql}${returningSql}`;
|
|
102
|
+
}
|
|
103
|
+
buildUpdateSet(table, set) {
|
|
104
|
+
const tableColumns = table[Table.Symbol.Columns];
|
|
105
|
+
const columnNames = Object.keys(tableColumns).filter(
|
|
106
|
+
(colName) => set[colName] !== void 0 || tableColumns[colName]?.onUpdateFn !== void 0
|
|
107
|
+
);
|
|
108
|
+
const setSize = columnNames.length;
|
|
109
|
+
return sql.join(columnNames.flatMap((colName, i) => {
|
|
110
|
+
const col = tableColumns[colName];
|
|
111
|
+
const value = set[colName] ?? sql.param(col.onUpdateFn(), col);
|
|
112
|
+
const res = sql`${sql.identifier(this.casing.getColumnCasing(col))} = ${value}`;
|
|
113
|
+
if (i < setSize - 1) {
|
|
114
|
+
return [res, sql.raw(", ")];
|
|
115
|
+
}
|
|
116
|
+
return [res];
|
|
117
|
+
}));
|
|
118
|
+
}
|
|
119
|
+
buildUpdateQuery({ table, set, where, returning, withList, from, joins }) {
|
|
120
|
+
const withSql = this.buildWithCTE(withList);
|
|
121
|
+
const tableName = table[GelTable.Symbol.Name];
|
|
122
|
+
const tableSchema = table[GelTable.Symbol.Schema];
|
|
123
|
+
const origTableName = table[GelTable.Symbol.OriginalName];
|
|
124
|
+
const alias = tableName === origTableName ? void 0 : tableName;
|
|
125
|
+
const tableSql = sql`${tableSchema ? sql`${sql.identifier(tableSchema)}.` : void 0}${sql.identifier(origTableName)}${alias && sql` ${sql.identifier(alias)}`}`;
|
|
126
|
+
const setSql = this.buildUpdateSet(table, set);
|
|
127
|
+
const fromSql = from && sql.join([sql.raw(" from "), this.buildFromTable(from)]);
|
|
128
|
+
const joinsSql = this.buildJoins(joins);
|
|
129
|
+
const returningSql = returning ? sql` returning ${this.buildSelection(returning, { isSingleTable: !from })}` : void 0;
|
|
130
|
+
const whereSql = where ? sql` where ${where}` : void 0;
|
|
131
|
+
return sql`${withSql}update ${tableSql} set ${setSql}${fromSql}${joinsSql}${whereSql}${returningSql}`;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Builds selection SQL with provided fields/expressions
|
|
135
|
+
*
|
|
136
|
+
* Examples:
|
|
137
|
+
*
|
|
138
|
+
* `select <selection> from`
|
|
139
|
+
*
|
|
140
|
+
* `insert ... returning <selection>`
|
|
141
|
+
*
|
|
142
|
+
* If `isSingleTable` is true, then columns won't be prefixed with table name
|
|
143
|
+
*/
|
|
144
|
+
buildSelection(fields, { isSingleTable = false } = {}) {
|
|
145
|
+
const columnsLen = fields.length;
|
|
146
|
+
const chunks = fields.flatMap(({ field }, i) => {
|
|
147
|
+
const chunk = [];
|
|
148
|
+
if (is(field, SQL.Aliased) && field.isSelectionField) {
|
|
149
|
+
chunk.push(sql.identifier(field.fieldAlias));
|
|
150
|
+
} else if (is(field, SQL.Aliased) || is(field, SQL)) {
|
|
151
|
+
const query = is(field, SQL.Aliased) ? field.sql : field;
|
|
152
|
+
if (isSingleTable) {
|
|
153
|
+
chunk.push(
|
|
154
|
+
new SQL(
|
|
155
|
+
query.queryChunks.map((c) => {
|
|
156
|
+
if (is(c, GelColumn)) {
|
|
157
|
+
return sql.identifier(this.casing.getColumnCasing(c));
|
|
158
|
+
}
|
|
159
|
+
return c;
|
|
160
|
+
})
|
|
161
|
+
)
|
|
162
|
+
);
|
|
163
|
+
} else {
|
|
164
|
+
chunk.push(query);
|
|
165
|
+
}
|
|
166
|
+
if (is(field, SQL.Aliased)) {
|
|
167
|
+
chunk.push(sql` as ${sql.identifier(field.fieldAlias)}`);
|
|
168
|
+
}
|
|
169
|
+
} else if (is(field, Column)) {
|
|
170
|
+
if (isSingleTable) {
|
|
171
|
+
chunk.push(sql.identifier(this.casing.getColumnCasing(field)));
|
|
172
|
+
} else {
|
|
173
|
+
chunk.push(field);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
if (i < columnsLen - 1) {
|
|
177
|
+
chunk.push(sql`, `);
|
|
178
|
+
}
|
|
179
|
+
return chunk;
|
|
180
|
+
});
|
|
181
|
+
return sql.join(chunks);
|
|
182
|
+
}
|
|
183
|
+
buildJoins(joins) {
|
|
184
|
+
if (!joins || joins.length === 0) {
|
|
185
|
+
return void 0;
|
|
186
|
+
}
|
|
187
|
+
const joinsArray = [];
|
|
188
|
+
for (const [index, joinMeta] of joins.entries()) {
|
|
189
|
+
if (index === 0) {
|
|
190
|
+
joinsArray.push(sql` `);
|
|
191
|
+
}
|
|
192
|
+
const table = joinMeta.table;
|
|
193
|
+
const lateralSql = joinMeta.lateral ? sql` lateral` : void 0;
|
|
194
|
+
if (is(table, GelTable)) {
|
|
195
|
+
const tableName = table[GelTable.Symbol.Name];
|
|
196
|
+
const tableSchema = table[GelTable.Symbol.Schema];
|
|
197
|
+
const origTableName = table[GelTable.Symbol.OriginalName];
|
|
198
|
+
const alias = tableName === origTableName ? void 0 : joinMeta.alias;
|
|
199
|
+
joinsArray.push(
|
|
200
|
+
sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${tableSchema ? sql`${sql.identifier(tableSchema)}.` : void 0}${sql.identifier(origTableName)}${alias && sql` ${sql.identifier(alias)}`} on ${joinMeta.on}`
|
|
201
|
+
);
|
|
202
|
+
} else if (is(table, View)) {
|
|
203
|
+
const viewName = table[ViewBaseConfig].name;
|
|
204
|
+
const viewSchema = table[ViewBaseConfig].schema;
|
|
205
|
+
const origViewName = table[ViewBaseConfig].originalName;
|
|
206
|
+
const alias = viewName === origViewName ? void 0 : joinMeta.alias;
|
|
207
|
+
joinsArray.push(
|
|
208
|
+
sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${viewSchema ? sql`${sql.identifier(viewSchema)}.` : void 0}${sql.identifier(origViewName)}${alias && sql` ${sql.identifier(alias)}`} on ${joinMeta.on}`
|
|
209
|
+
);
|
|
210
|
+
} else {
|
|
211
|
+
joinsArray.push(
|
|
212
|
+
sql`${sql.raw(joinMeta.joinType)} join${lateralSql} ${table} on ${joinMeta.on}`
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
if (index < joins.length - 1) {
|
|
216
|
+
joinsArray.push(sql` `);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
return sql.join(joinsArray);
|
|
220
|
+
}
|
|
221
|
+
buildFromTable(table) {
|
|
222
|
+
if (is(table, Table) && table[Table.Symbol.OriginalName] !== table[Table.Symbol.Name]) {
|
|
223
|
+
let fullName = sql`${sql.identifier(table[Table.Symbol.OriginalName])}`;
|
|
224
|
+
if (table[Table.Symbol.Schema]) {
|
|
225
|
+
fullName = sql`${sql.identifier(table[Table.Symbol.Schema])}.${fullName}`;
|
|
226
|
+
}
|
|
227
|
+
return sql`${fullName} ${sql.identifier(table[Table.Symbol.Name])}`;
|
|
228
|
+
}
|
|
229
|
+
return table;
|
|
230
|
+
}
|
|
231
|
+
buildSelectQuery({
|
|
232
|
+
withList,
|
|
233
|
+
fields,
|
|
234
|
+
fieldsFlat,
|
|
235
|
+
where,
|
|
236
|
+
having,
|
|
237
|
+
table,
|
|
238
|
+
joins,
|
|
239
|
+
orderBy,
|
|
240
|
+
groupBy,
|
|
241
|
+
limit,
|
|
242
|
+
offset,
|
|
243
|
+
lockingClause,
|
|
244
|
+
distinct,
|
|
245
|
+
setOperators
|
|
246
|
+
}) {
|
|
247
|
+
const fieldsList = fieldsFlat ?? orderSelectedFields(fields);
|
|
248
|
+
for (const f of fieldsList) {
|
|
249
|
+
if (is(f.field, Column) && getTableName(f.field.table) !== (is(table, Subquery) ? table._.alias : is(table, GelViewBase) ? table[ViewBaseConfig].name : is(table, SQL) ? void 0 : getTableName(table)) && !((table2) => joins?.some(
|
|
250
|
+
({ alias }) => alias === (table2[Table.Symbol.IsAlias] ? getTableName(table2) : table2[Table.Symbol.BaseName])
|
|
251
|
+
))(f.field.table)) {
|
|
252
|
+
const tableName = getTableName(f.field.table);
|
|
253
|
+
throw new Error(
|
|
254
|
+
`Your "${f.path.join("->")}" field references a column "${tableName}"."${f.field.name}", but the table "${tableName}" is not part of the query! Did you forget to join it?`
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
const isSingleTable = !joins || joins.length === 0;
|
|
259
|
+
const withSql = this.buildWithCTE(withList);
|
|
260
|
+
let distinctSql;
|
|
261
|
+
if (distinct) {
|
|
262
|
+
distinctSql = distinct === true ? sql` distinct` : sql` distinct on (${sql.join(distinct.on, sql`, `)})`;
|
|
263
|
+
}
|
|
264
|
+
const selection = this.buildSelection(fieldsList, { isSingleTable });
|
|
265
|
+
const tableSql = this.buildFromTable(table);
|
|
266
|
+
const joinsSql = this.buildJoins(joins);
|
|
267
|
+
const whereSql = where ? sql` where ${where}` : void 0;
|
|
268
|
+
const havingSql = having ? sql` having ${having}` : void 0;
|
|
269
|
+
let orderBySql;
|
|
270
|
+
if (orderBy && orderBy.length > 0) {
|
|
271
|
+
orderBySql = sql` order by ${sql.join(orderBy, sql`, `)}`;
|
|
272
|
+
}
|
|
273
|
+
let groupBySql;
|
|
274
|
+
if (groupBy && groupBy.length > 0) {
|
|
275
|
+
groupBySql = sql` group by ${sql.join(groupBy, sql`, `)}`;
|
|
276
|
+
}
|
|
277
|
+
const limitSql = typeof limit === "object" || typeof limit === "number" && limit >= 0 ? sql` limit ${limit}` : void 0;
|
|
278
|
+
const offsetSql = offset ? sql` offset ${offset}` : void 0;
|
|
279
|
+
const lockingClauseSql = sql.empty();
|
|
280
|
+
if (lockingClause) {
|
|
281
|
+
const clauseSql = sql` for ${sql.raw(lockingClause.strength)}`;
|
|
282
|
+
if (lockingClause.config.of) {
|
|
283
|
+
clauseSql.append(
|
|
284
|
+
sql` of ${sql.join(
|
|
285
|
+
Array.isArray(lockingClause.config.of) ? lockingClause.config.of : [lockingClause.config.of],
|
|
286
|
+
sql`, `
|
|
287
|
+
)}`
|
|
288
|
+
);
|
|
289
|
+
}
|
|
290
|
+
if (lockingClause.config.noWait) {
|
|
291
|
+
clauseSql.append(sql` no wait`);
|
|
292
|
+
} else if (lockingClause.config.skipLocked) {
|
|
293
|
+
clauseSql.append(sql` skip locked`);
|
|
294
|
+
}
|
|
295
|
+
lockingClauseSql.append(clauseSql);
|
|
296
|
+
}
|
|
297
|
+
const finalQuery = sql`${withSql}select${distinctSql} ${selection} from ${tableSql}${joinsSql}${whereSql}${groupBySql}${havingSql}${orderBySql}${limitSql}${offsetSql}${lockingClauseSql}`;
|
|
298
|
+
if (setOperators.length > 0) {
|
|
299
|
+
return this.buildSetOperations(finalQuery, setOperators);
|
|
300
|
+
}
|
|
301
|
+
return finalQuery;
|
|
302
|
+
}
|
|
303
|
+
buildSetOperations(leftSelect, setOperators) {
|
|
304
|
+
const [setOperator, ...rest] = setOperators;
|
|
305
|
+
if (!setOperator) {
|
|
306
|
+
throw new Error("Cannot pass undefined values to any set operator");
|
|
307
|
+
}
|
|
308
|
+
if (rest.length === 0) {
|
|
309
|
+
return this.buildSetOperationQuery({ leftSelect, setOperator });
|
|
310
|
+
}
|
|
311
|
+
return this.buildSetOperations(
|
|
312
|
+
this.buildSetOperationQuery({ leftSelect, setOperator }),
|
|
313
|
+
rest
|
|
314
|
+
);
|
|
315
|
+
}
|
|
316
|
+
buildSetOperationQuery({
|
|
317
|
+
leftSelect,
|
|
318
|
+
setOperator: { type, isAll, rightSelect, limit, orderBy, offset }
|
|
319
|
+
}) {
|
|
320
|
+
const leftChunk = sql`(${leftSelect.getSQL()}) `;
|
|
321
|
+
const rightChunk = sql`(${rightSelect.getSQL()})`;
|
|
322
|
+
let orderBySql;
|
|
323
|
+
if (orderBy && orderBy.length > 0) {
|
|
324
|
+
const orderByValues = [];
|
|
325
|
+
for (const singleOrderBy of orderBy) {
|
|
326
|
+
if (is(singleOrderBy, GelColumn)) {
|
|
327
|
+
orderByValues.push(sql.identifier(singleOrderBy.name));
|
|
328
|
+
} else if (is(singleOrderBy, SQL)) {
|
|
329
|
+
for (let i = 0; i < singleOrderBy.queryChunks.length; i++) {
|
|
330
|
+
const chunk = singleOrderBy.queryChunks[i];
|
|
331
|
+
if (is(chunk, GelColumn)) {
|
|
332
|
+
singleOrderBy.queryChunks[i] = sql.identifier(chunk.name);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
orderByValues.push(sql`${singleOrderBy}`);
|
|
336
|
+
} else {
|
|
337
|
+
orderByValues.push(sql`${singleOrderBy}`);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
orderBySql = sql` order by ${sql.join(orderByValues, sql`, `)} `;
|
|
341
|
+
}
|
|
342
|
+
const limitSql = typeof limit === "object" || typeof limit === "number" && limit >= 0 ? sql` limit ${limit}` : void 0;
|
|
343
|
+
const operatorChunk = sql.raw(`${type} ${isAll ? "all " : ""}`);
|
|
344
|
+
const offsetSql = offset ? sql` offset ${offset}` : void 0;
|
|
345
|
+
return sql`${leftChunk}${operatorChunk}${rightChunk}${orderBySql}${limitSql}${offsetSql}`;
|
|
346
|
+
}
|
|
347
|
+
buildInsertQuery({ table, values: valuesOrSelect, onConflict, returning, withList, select, overridingSystemValue_ }) {
|
|
348
|
+
const valuesSqlList = [];
|
|
349
|
+
const columns = table[Table.Symbol.Columns];
|
|
350
|
+
const colEntries = Object.entries(columns).filter(([_, col]) => !col.shouldDisableInsert());
|
|
351
|
+
const insertOrder = colEntries.map(
|
|
352
|
+
([, column]) => sql.identifier(this.casing.getColumnCasing(column))
|
|
353
|
+
);
|
|
354
|
+
if (select) {
|
|
355
|
+
const select2 = valuesOrSelect;
|
|
356
|
+
if (is(select2, SQL)) {
|
|
357
|
+
valuesSqlList.push(select2);
|
|
358
|
+
} else {
|
|
359
|
+
valuesSqlList.push(select2.getSQL());
|
|
360
|
+
}
|
|
361
|
+
} else {
|
|
362
|
+
const values = valuesOrSelect;
|
|
363
|
+
valuesSqlList.push(sql.raw("values "));
|
|
364
|
+
for (const [valueIndex, value] of values.entries()) {
|
|
365
|
+
const valueList = [];
|
|
366
|
+
for (const [fieldName, col] of colEntries) {
|
|
367
|
+
const colValue = value[fieldName];
|
|
368
|
+
if (colValue === void 0 || is(colValue, Param) && colValue.value === void 0) {
|
|
369
|
+
if (col.defaultFn !== void 0) {
|
|
370
|
+
const defaultFnResult = col.defaultFn();
|
|
371
|
+
const defaultValue = is(defaultFnResult, SQL) ? defaultFnResult : sql.param(defaultFnResult, col);
|
|
372
|
+
valueList.push(defaultValue);
|
|
373
|
+
} else if (!col.default && col.onUpdateFn !== void 0) {
|
|
374
|
+
const onUpdateFnResult = col.onUpdateFn();
|
|
375
|
+
const newValue = is(onUpdateFnResult, SQL) ? onUpdateFnResult : sql.param(onUpdateFnResult, col);
|
|
376
|
+
valueList.push(newValue);
|
|
377
|
+
} else {
|
|
378
|
+
valueList.push(sql`default`);
|
|
379
|
+
}
|
|
380
|
+
} else {
|
|
381
|
+
valueList.push(colValue);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
valuesSqlList.push(valueList);
|
|
385
|
+
if (valueIndex < values.length - 1) {
|
|
386
|
+
valuesSqlList.push(sql`, `);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
const withSql = this.buildWithCTE(withList);
|
|
391
|
+
const valuesSql = sql.join(valuesSqlList);
|
|
392
|
+
const returningSql = returning ? sql` returning ${this.buildSelection(returning, { isSingleTable: true })}` : void 0;
|
|
393
|
+
const onConflictSql = onConflict ? sql` on conflict ${onConflict}` : void 0;
|
|
394
|
+
const overridingSql = overridingSystemValue_ === true ? sql`overriding system value ` : void 0;
|
|
395
|
+
return sql`${withSql}insert into ${table} ${insertOrder} ${overridingSql}${valuesSql}${onConflictSql}${returningSql}`;
|
|
396
|
+
}
|
|
397
|
+
buildRefreshMaterializedViewQuery({ view, concurrently, withNoData }) {
|
|
398
|
+
const concurrentlySql = concurrently ? sql` concurrently` : void 0;
|
|
399
|
+
const withNoDataSql = withNoData ? sql` with no data` : void 0;
|
|
400
|
+
return sql`refresh materialized view${concurrentlySql} ${view}${withNoDataSql}`;
|
|
401
|
+
}
|
|
402
|
+
prepareTyping(encoder) {
|
|
403
|
+
if (is(encoder, GelJson)) {
|
|
404
|
+
return "json";
|
|
405
|
+
} else if (is(encoder, GelDecimal)) {
|
|
406
|
+
return "decimal";
|
|
407
|
+
} else if (is(encoder, GelTimestamp)) {
|
|
408
|
+
return "timestamp";
|
|
409
|
+
} else if (is(encoder, GelUUID)) {
|
|
410
|
+
return "uuid";
|
|
411
|
+
} else {
|
|
412
|
+
return "none";
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
sqlToQuery(sql2, invokeSource) {
|
|
416
|
+
return sql2.toQuery({
|
|
417
|
+
casing: this.casing,
|
|
418
|
+
escapeName: this.escapeName,
|
|
419
|
+
escapeParam: this.escapeParam,
|
|
420
|
+
escapeString: this.escapeString,
|
|
421
|
+
prepareTyping: this.prepareTyping,
|
|
422
|
+
invokeSource
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
_buildRelationalQuery({
|
|
426
|
+
fullSchema,
|
|
427
|
+
schema,
|
|
428
|
+
tableNamesMap,
|
|
429
|
+
table,
|
|
430
|
+
tableConfig,
|
|
431
|
+
queryConfig: config,
|
|
432
|
+
tableAlias,
|
|
433
|
+
nestedQueryRelation,
|
|
434
|
+
joinOn
|
|
435
|
+
}) {
|
|
436
|
+
let selection = [];
|
|
437
|
+
let limit, offset, orderBy = [], where;
|
|
438
|
+
const joins = [];
|
|
439
|
+
if (config === true) {
|
|
440
|
+
const selectionEntries = Object.entries(tableConfig.columns);
|
|
441
|
+
selection = selectionEntries.map(([key, value]) => ({
|
|
442
|
+
dbKey: value.name,
|
|
443
|
+
tsKey: key,
|
|
444
|
+
field: aliasedTableColumn(value, tableAlias),
|
|
445
|
+
relationTableTsKey: void 0,
|
|
446
|
+
isJson: false,
|
|
447
|
+
selection: []
|
|
448
|
+
}));
|
|
449
|
+
} else {
|
|
450
|
+
const aliasedColumns = Object.fromEntries(
|
|
451
|
+
Object.entries(tableConfig.columns).map(([key, value]) => [key, aliasedTableColumn(value, tableAlias)])
|
|
452
|
+
);
|
|
453
|
+
if (config.where) {
|
|
454
|
+
const whereSql = typeof config.where === "function" ? config.where(aliasedColumns, V1.getOperators()) : config.where;
|
|
455
|
+
where = whereSql && mapColumnsInSQLToAlias(whereSql, tableAlias);
|
|
456
|
+
}
|
|
457
|
+
const fieldsSelection = [];
|
|
458
|
+
let selectedColumns = [];
|
|
459
|
+
if (config.columns) {
|
|
460
|
+
let isIncludeMode = false;
|
|
461
|
+
for (const [field, value] of Object.entries(config.columns)) {
|
|
462
|
+
if (value === void 0) {
|
|
463
|
+
continue;
|
|
464
|
+
}
|
|
465
|
+
if (field in tableConfig.columns) {
|
|
466
|
+
if (!isIncludeMode && value === true) {
|
|
467
|
+
isIncludeMode = true;
|
|
468
|
+
}
|
|
469
|
+
selectedColumns.push(field);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
if (selectedColumns.length > 0) {
|
|
473
|
+
selectedColumns = isIncludeMode ? selectedColumns.filter((c) => config.columns?.[c] === true) : Object.keys(tableConfig.columns).filter((key) => !selectedColumns.includes(key));
|
|
474
|
+
}
|
|
475
|
+
} else {
|
|
476
|
+
selectedColumns = Object.keys(tableConfig.columns);
|
|
477
|
+
}
|
|
478
|
+
for (const field of selectedColumns) {
|
|
479
|
+
const column = tableConfig.columns[field];
|
|
480
|
+
fieldsSelection.push({ tsKey: field, value: column });
|
|
481
|
+
}
|
|
482
|
+
let selectedRelations = [];
|
|
483
|
+
if (config.with) {
|
|
484
|
+
selectedRelations = Object.entries(config.with).filter((entry) => !!entry[1]).map(([tsKey, queryConfig]) => ({ tsKey, queryConfig, relation: tableConfig.relations[tsKey] }));
|
|
485
|
+
}
|
|
486
|
+
let extras;
|
|
487
|
+
if (config.extras) {
|
|
488
|
+
extras = typeof config.extras === "function" ? config.extras(aliasedColumns, { sql }) : config.extras;
|
|
489
|
+
for (const [tsKey, value] of Object.entries(extras)) {
|
|
490
|
+
fieldsSelection.push({
|
|
491
|
+
tsKey,
|
|
492
|
+
value: mapColumnsInAliasedSQLToAlias(value, tableAlias)
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
for (const { tsKey, value } of fieldsSelection) {
|
|
497
|
+
selection.push({
|
|
498
|
+
dbKey: is(value, SQL.Aliased) ? value.fieldAlias : tableConfig.columns[tsKey].name,
|
|
499
|
+
tsKey,
|
|
500
|
+
field: is(value, Column) ? aliasedTableColumn(value, tableAlias) : value,
|
|
501
|
+
relationTableTsKey: void 0,
|
|
502
|
+
isJson: false,
|
|
503
|
+
selection: []
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
let orderByOrig = typeof config.orderBy === "function" ? config.orderBy(aliasedColumns, V1.getOrderByOperators()) : config.orderBy ?? [];
|
|
507
|
+
if (!Array.isArray(orderByOrig)) {
|
|
508
|
+
orderByOrig = [orderByOrig];
|
|
509
|
+
}
|
|
510
|
+
orderBy = orderByOrig.map((orderByValue) => {
|
|
511
|
+
if (is(orderByValue, Column)) {
|
|
512
|
+
return aliasedTableColumn(orderByValue, tableAlias);
|
|
513
|
+
}
|
|
514
|
+
return mapColumnsInSQLToAlias(orderByValue, tableAlias);
|
|
515
|
+
});
|
|
516
|
+
limit = config.limit;
|
|
517
|
+
offset = config.offset;
|
|
518
|
+
for (const {
|
|
519
|
+
tsKey: selectedRelationTsKey,
|
|
520
|
+
queryConfig: selectedRelationConfigValue,
|
|
521
|
+
relation
|
|
522
|
+
} of selectedRelations) {
|
|
523
|
+
const normalizedRelation = V1.normalizeRelation(schema, tableNamesMap, relation);
|
|
524
|
+
const relationTableName = getTableUniqueName(relation.referencedTable);
|
|
525
|
+
const relationTableTsName = tableNamesMap[relationTableName];
|
|
526
|
+
const relationTableAlias = `${tableAlias}_${selectedRelationTsKey}`;
|
|
527
|
+
const joinOn2 = and(
|
|
528
|
+
...normalizedRelation.fields.map(
|
|
529
|
+
(field2, i) => eq(
|
|
530
|
+
aliasedTableColumn(normalizedRelation.references[i], relationTableAlias),
|
|
531
|
+
aliasedTableColumn(field2, tableAlias)
|
|
532
|
+
)
|
|
533
|
+
)
|
|
534
|
+
);
|
|
535
|
+
const builtRelation = this._buildRelationalQuery({
|
|
536
|
+
fullSchema,
|
|
537
|
+
schema,
|
|
538
|
+
tableNamesMap,
|
|
539
|
+
table: fullSchema[relationTableTsName],
|
|
540
|
+
tableConfig: schema[relationTableTsName],
|
|
541
|
+
queryConfig: is(relation, V1.One) ? selectedRelationConfigValue === true ? { limit: 1 } : { ...selectedRelationConfigValue, limit: 1 } : selectedRelationConfigValue,
|
|
542
|
+
tableAlias: relationTableAlias,
|
|
543
|
+
joinOn: joinOn2,
|
|
544
|
+
nestedQueryRelation: relation
|
|
545
|
+
});
|
|
546
|
+
const field = sql`${sql.identifier(relationTableAlias)}.${sql.identifier("data")}`.as(selectedRelationTsKey);
|
|
547
|
+
joins.push({
|
|
548
|
+
on: sql`true`,
|
|
549
|
+
table: new Subquery(builtRelation.sql, {}, relationTableAlias),
|
|
550
|
+
alias: relationTableAlias,
|
|
551
|
+
joinType: "left",
|
|
552
|
+
lateral: true
|
|
553
|
+
});
|
|
554
|
+
selection.push({
|
|
555
|
+
dbKey: selectedRelationTsKey,
|
|
556
|
+
tsKey: selectedRelationTsKey,
|
|
557
|
+
field,
|
|
558
|
+
relationTableTsKey: relationTableTsName,
|
|
559
|
+
isJson: true,
|
|
560
|
+
selection: builtRelation.selection
|
|
561
|
+
});
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
if (selection.length === 0) {
|
|
565
|
+
throw new DrizzleError({ message: `No fields selected for table "${tableConfig.tsName}" ("${tableAlias}")` });
|
|
566
|
+
}
|
|
567
|
+
let result;
|
|
568
|
+
where = and(joinOn, where);
|
|
569
|
+
if (nestedQueryRelation) {
|
|
570
|
+
let field = sql`json_build_array(${sql.join(
|
|
571
|
+
selection.map(
|
|
572
|
+
({ field: field2, tsKey, isJson }) => isJson ? sql`${sql.identifier(`${tableAlias}_${tsKey}`)}.${sql.identifier("data")}` : is(field2, SQL.Aliased) ? field2.sql : field2
|
|
573
|
+
),
|
|
574
|
+
sql`, `
|
|
575
|
+
)})`;
|
|
576
|
+
if (is(nestedQueryRelation, V1.Many)) {
|
|
577
|
+
field = sql`coalesce(json_agg(${field}${orderBy.length > 0 ? sql` order by ${sql.join(orderBy, sql`, `)}` : void 0}), '[]'::json)`;
|
|
578
|
+
}
|
|
579
|
+
const nestedSelection = [{
|
|
580
|
+
dbKey: "data",
|
|
581
|
+
tsKey: "data",
|
|
582
|
+
field: field.as("data"),
|
|
583
|
+
isJson: true,
|
|
584
|
+
relationTableTsKey: tableConfig.tsName,
|
|
585
|
+
selection
|
|
586
|
+
}];
|
|
587
|
+
const needsSubquery = limit !== void 0 || offset !== void 0 || orderBy.length > 0;
|
|
588
|
+
if (needsSubquery) {
|
|
589
|
+
result = this.buildSelectQuery({
|
|
590
|
+
table: aliasedTable(table, tableAlias),
|
|
591
|
+
fields: {},
|
|
592
|
+
fieldsFlat: [{
|
|
593
|
+
path: [],
|
|
594
|
+
field: sql.raw("*")
|
|
595
|
+
}],
|
|
596
|
+
where,
|
|
597
|
+
limit,
|
|
598
|
+
offset,
|
|
599
|
+
orderBy,
|
|
600
|
+
setOperators: []
|
|
601
|
+
});
|
|
602
|
+
where = void 0;
|
|
603
|
+
limit = void 0;
|
|
604
|
+
offset = void 0;
|
|
605
|
+
orderBy = [];
|
|
606
|
+
} else {
|
|
607
|
+
result = aliasedTable(table, tableAlias);
|
|
608
|
+
}
|
|
609
|
+
result = this.buildSelectQuery({
|
|
610
|
+
table: is(result, GelTable) ? result : new Subquery(result, {}, tableAlias),
|
|
611
|
+
fields: {},
|
|
612
|
+
fieldsFlat: nestedSelection.map(({ field: field2 }) => ({
|
|
613
|
+
path: [],
|
|
614
|
+
field: is(field2, Column) ? aliasedTableColumn(field2, tableAlias) : field2
|
|
615
|
+
})),
|
|
616
|
+
joins,
|
|
617
|
+
where,
|
|
618
|
+
limit,
|
|
619
|
+
offset,
|
|
620
|
+
orderBy,
|
|
621
|
+
setOperators: []
|
|
622
|
+
});
|
|
623
|
+
} else {
|
|
624
|
+
result = this.buildSelectQuery({
|
|
625
|
+
table: aliasedTable(table, tableAlias),
|
|
626
|
+
fields: {},
|
|
627
|
+
fieldsFlat: selection.map(({ field }) => ({
|
|
628
|
+
path: [],
|
|
629
|
+
field: is(field, Column) ? aliasedTableColumn(field, tableAlias) : field
|
|
630
|
+
})),
|
|
631
|
+
joins,
|
|
632
|
+
where,
|
|
633
|
+
limit,
|
|
634
|
+
offset,
|
|
635
|
+
orderBy,
|
|
636
|
+
setOperators: []
|
|
637
|
+
});
|
|
638
|
+
}
|
|
639
|
+
return {
|
|
640
|
+
tableTsKey: tableConfig.tsName,
|
|
641
|
+
sql: result,
|
|
642
|
+
selection
|
|
643
|
+
};
|
|
644
|
+
}
|
|
645
|
+
nestedSelectionerror() {
|
|
646
|
+
throw new DrizzleError({
|
|
647
|
+
message: `Views with nested selections are not supported by the relational query builder`
|
|
648
|
+
});
|
|
649
|
+
}
|
|
650
|
+
buildRqbColumn(table, column, key) {
|
|
651
|
+
if (is(column, Column)) {
|
|
652
|
+
switch (column.columnType) {
|
|
653
|
+
default: {
|
|
654
|
+
return sql`${table}.${sql.identifier(this.casing.getColumnCasing(column))} as ${sql.identifier(key)}`;
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
return sql`${table}.${is(column, SQL.Aliased) ? sql.identifier(column.fieldAlias) : isSQLWrapper(column) ? sql.identifier(key) : this.nestedSelectionerror()} as ${sql.identifier(key)}`;
|
|
659
|
+
}
|
|
660
|
+
unwrapAllColumns = (table, selection) => {
|
|
661
|
+
return sql.join(
|
|
662
|
+
Object.entries(table[Columns]).map(([k, v]) => {
|
|
663
|
+
selection.push({
|
|
664
|
+
key: k,
|
|
665
|
+
field: v
|
|
666
|
+
});
|
|
667
|
+
return this.buildRqbColumn(table, v, k);
|
|
668
|
+
}),
|
|
669
|
+
sql`, `
|
|
670
|
+
);
|
|
671
|
+
};
|
|
672
|
+
buildColumns = (table, selection, config) => config?.columns ? (() => {
|
|
673
|
+
const entries = Object.entries(config.columns);
|
|
674
|
+
const columnContainer = table[Columns];
|
|
675
|
+
const columnIdentifiers = [];
|
|
676
|
+
let colSelectionMode;
|
|
677
|
+
for (const [k, v] of entries) {
|
|
678
|
+
if (v === void 0)
|
|
679
|
+
continue;
|
|
680
|
+
colSelectionMode = colSelectionMode || v;
|
|
681
|
+
if (v) {
|
|
682
|
+
const column = columnContainer[k];
|
|
683
|
+
columnIdentifiers.push(
|
|
684
|
+
this.buildRqbColumn(table, column, k)
|
|
685
|
+
);
|
|
686
|
+
selection.push({
|
|
687
|
+
key: k,
|
|
688
|
+
field: column
|
|
689
|
+
});
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
if (colSelectionMode === false) {
|
|
693
|
+
for (const [k, v] of Object.entries(columnContainer)) {
|
|
694
|
+
if (config.columns[k] === false)
|
|
695
|
+
continue;
|
|
696
|
+
columnIdentifiers.push(this.buildRqbColumn(table, v, k));
|
|
697
|
+
selection.push({
|
|
698
|
+
key: k,
|
|
699
|
+
field: v
|
|
700
|
+
});
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
return columnIdentifiers.length ? sql.join(columnIdentifiers, sql`, `) : void 0;
|
|
704
|
+
})() : this.unwrapAllColumns(table, selection);
|
|
705
|
+
buildRelationalQuery({
|
|
706
|
+
tables,
|
|
707
|
+
schema,
|
|
708
|
+
tableNamesMap,
|
|
709
|
+
table,
|
|
710
|
+
tableConfig,
|
|
711
|
+
queryConfig: config,
|
|
712
|
+
relationWhere,
|
|
713
|
+
mode,
|
|
714
|
+
errorPath,
|
|
715
|
+
depth,
|
|
716
|
+
throughJoin
|
|
717
|
+
}) {
|
|
718
|
+
const selection = [];
|
|
719
|
+
const isSingle = mode === "first";
|
|
720
|
+
const params = config === true ? void 0 : config;
|
|
721
|
+
const currentPath = errorPath ?? "";
|
|
722
|
+
const currentDepth = depth ?? 0;
|
|
723
|
+
if (!currentDepth)
|
|
724
|
+
table = aliasedTable(table, `d${currentDepth}`);
|
|
725
|
+
const limit = isSingle ? 1 : params?.limit;
|
|
726
|
+
const offset = params?.offset;
|
|
727
|
+
const where = params?.where && relationWhere ? and(
|
|
728
|
+
relationsFilterToSQL(table, params.where, tableConfig.relations, schema, tableNamesMap, this.casing),
|
|
729
|
+
relationWhere
|
|
730
|
+
) : params?.where ? relationsFilterToSQL(table, params.where, tableConfig.relations, schema, tableNamesMap, this.casing) : relationWhere;
|
|
731
|
+
const order = params?.orderBy ? relationsOrderToSQL(table, params.orderBy) : void 0;
|
|
732
|
+
const columns = this.buildColumns(table, selection, params);
|
|
733
|
+
const extras = params?.extras ? relationExtrasToSQL(table, params.extras) : void 0;
|
|
734
|
+
if (extras)
|
|
735
|
+
selection.push(...extras.selection);
|
|
736
|
+
const selectionArr = columns ? [columns] : [];
|
|
737
|
+
const joins = params ? (() => {
|
|
738
|
+
const { with: joins2 } = params;
|
|
739
|
+
if (!joins2)
|
|
740
|
+
return;
|
|
741
|
+
const withEntries = Object.entries(joins2).filter(([_, v]) => v);
|
|
742
|
+
if (!withEntries.length)
|
|
743
|
+
return;
|
|
744
|
+
return sql.join(
|
|
745
|
+
withEntries.map(([k, join]) => {
|
|
746
|
+
const relation = tableConfig.relations[k];
|
|
747
|
+
const isSingle2 = is(relation, One);
|
|
748
|
+
const targetTable = aliasedTable(relation.targetTable, `d${currentDepth + 1}`);
|
|
749
|
+
const throughTable = relation.throughTable ? aliasedTable(relation.throughTable, `tr${currentDepth}`) : void 0;
|
|
750
|
+
const { filter, joinCondition } = relationToSQL(
|
|
751
|
+
this.casing,
|
|
752
|
+
relation,
|
|
753
|
+
table,
|
|
754
|
+
targetTable,
|
|
755
|
+
throughTable
|
|
756
|
+
);
|
|
757
|
+
selectionArr.push(sql`${sql.identifier(k)}.${sql.identifier("r")} as ${sql.identifier(k)}`);
|
|
758
|
+
const throughJoin2 = throughTable ? sql` inner join ${getTableAsAliasSQL(throughTable)} on ${joinCondition}` : void 0;
|
|
759
|
+
const innerQuery = this.buildRelationalQuery({
|
|
760
|
+
table: targetTable,
|
|
761
|
+
mode: isSingle2 ? "first" : "many",
|
|
762
|
+
schema,
|
|
763
|
+
queryConfig: join,
|
|
764
|
+
tableConfig: schema[tableNamesMap[getTableUniqueName(relation.targetTable)]],
|
|
765
|
+
tableNamesMap,
|
|
766
|
+
tables,
|
|
767
|
+
relationWhere: filter,
|
|
768
|
+
errorPath: `${currentPath.length ? `${currentPath}.` : ""}${k}`,
|
|
769
|
+
depth: currentDepth + 1,
|
|
770
|
+
throughJoin: throughJoin2
|
|
771
|
+
});
|
|
772
|
+
selection.push({
|
|
773
|
+
field: targetTable,
|
|
774
|
+
key: k,
|
|
775
|
+
selection: innerQuery.selection,
|
|
776
|
+
isArray: !isSingle2,
|
|
777
|
+
isOptional: (relation.optional ?? false) || join !== true && !!join.where
|
|
778
|
+
});
|
|
779
|
+
const joinQuery = sql`left join lateral(select ${isSingle2 ? sql`row_to_json(${sql.identifier("t")}.*) ${sql.identifier("r")}` : sql`coalesce(json_agg(row_to_json(${sql.identifier("t")}.*)), '[]') as ${sql.identifier("r")}`} from (${innerQuery.sql}) as ${sql.identifier("t")}) as ${sql.identifier(k)} on true`;
|
|
780
|
+
return joinQuery;
|
|
781
|
+
}),
|
|
782
|
+
sql` `
|
|
783
|
+
);
|
|
784
|
+
})() : void 0;
|
|
785
|
+
if (extras?.sql)
|
|
786
|
+
selectionArr.push(extras.sql);
|
|
787
|
+
if (!selectionArr.length) {
|
|
788
|
+
throw new DrizzleError({
|
|
789
|
+
message: `No fields selected for table "${tableConfig.tsName}"${currentPath ? ` ("${currentPath}")` : ""}`
|
|
790
|
+
});
|
|
791
|
+
}
|
|
792
|
+
const selectionSet = sql.join(selectionArr.filter((e) => e !== void 0), sql`, `);
|
|
793
|
+
const query = sql`select ${selectionSet} from ${getTableAsAliasSQL(table)}${throughJoin}${sql` ${joins}`.if(joins)}${sql` where ${where}`.if(where)}${sql` order by ${order}`.if(order)}${sql` limit ${limit}`.if(limit !== void 0)}${sql` offset ${offset}`.if(offset !== void 0)}`;
|
|
794
|
+
return {
|
|
795
|
+
sql: query,
|
|
796
|
+
selection
|
|
797
|
+
};
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
export {
|
|
801
|
+
GelDialect
|
|
802
|
+
};
|
|
803
|
+
//# sourceMappingURL=dialect.js.map
|