drizzle-orm 0.36.4 → 0.37.0-0c27176
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/column-builder.cjs.map +1 -1
- package/column-builder.d.cts +4 -3
- package/column-builder.d.ts +4 -3
- package/column-builder.js.map +1 -1
- package/durable-sqlite/driver.cjs +64 -0
- package/durable-sqlite/driver.cjs.map +1 -0
- package/durable-sqlite/driver.d.cts +9 -0
- package/durable-sqlite/driver.d.ts +9 -0
- package/durable-sqlite/driver.js +42 -0
- package/durable-sqlite/driver.js.map +1 -0
- package/durable-sqlite/index.cjs +25 -0
- package/durable-sqlite/index.cjs.map +1 -0
- package/durable-sqlite/index.d.cts +2 -0
- package/durable-sqlite/index.d.ts +2 -0
- package/durable-sqlite/index.js +3 -0
- package/durable-sqlite/index.js.map +1 -0
- package/durable-sqlite/migrator.cjs +85 -0
- package/durable-sqlite/migrator.cjs.map +1 -0
- package/durable-sqlite/migrator.d.cts +14 -0
- package/durable-sqlite/migrator.d.ts +14 -0
- package/durable-sqlite/migrator.js +61 -0
- package/durable-sqlite/migrator.js.map +1 -0
- package/durable-sqlite/session.cjs +131 -0
- package/durable-sqlite/session.cjs.map +1 -0
- package/durable-sqlite/session.d.cts +46 -0
- package/durable-sqlite/session.d.ts +46 -0
- package/durable-sqlite/session.js +107 -0
- package/durable-sqlite/session.js.map +1 -0
- package/mysql-core/columns/all.cjs +4 -1
- package/mysql-core/columns/all.cjs.map +1 -1
- package/mysql-core/columns/all.d.cts +4 -1
- package/mysql-core/columns/all.d.ts +4 -1
- package/mysql-core/columns/all.js +5 -2
- package/mysql-core/columns/all.js.map +1 -1
- package/mysql-core/columns/char.cjs.map +1 -1
- package/mysql-core/columns/char.d.cts +19 -10
- package/mysql-core/columns/char.d.ts +19 -10
- package/mysql-core/columns/char.js.map +1 -1
- package/mysql-core/columns/common.cjs.map +1 -1
- package/mysql-core/columns/common.d.cts +1 -1
- package/mysql-core/columns/common.d.ts +1 -1
- package/mysql-core/columns/common.js.map +1 -1
- package/mysql-core/columns/text.cjs.map +1 -1
- package/mysql-core/columns/text.d.cts +1 -1
- package/mysql-core/columns/text.d.ts +1 -1
- package/mysql-core/columns/text.js.map +1 -1
- package/mysql-core/columns/varchar.cjs.map +1 -1
- package/mysql-core/columns/varchar.d.cts +14 -7
- package/mysql-core/columns/varchar.d.ts +14 -7
- package/mysql-core/columns/varchar.js.map +1 -1
- package/mysql-core/utils.d.cts +2 -3
- package/mysql-core/utils.d.ts +2 -3
- package/mysql-core/view.cjs.map +1 -1
- package/mysql-core/view.d.cts +2 -3
- package/mysql-core/view.d.ts +2 -3
- package/mysql-core/view.js.map +1 -1
- package/neon-http/driver.cjs +1 -1
- package/neon-http/driver.cjs.map +1 -1
- package/neon-http/driver.d.cts +2 -2
- package/neon-http/driver.d.ts +2 -2
- package/neon-http/driver.js +1 -1
- package/neon-http/driver.js.map +1 -1
- package/neon-http/session.cjs.map +1 -1
- package/neon-http/session.js.map +1 -1
- package/package.json +784 -3
- package/pg-core/columns/char.cjs +4 -1
- package/pg-core/columns/char.cjs.map +1 -1
- package/pg-core/columns/char.d.cts +21 -12
- package/pg-core/columns/char.d.ts +21 -12
- package/pg-core/columns/char.js +4 -1
- package/pg-core/columns/char.js.map +1 -1
- package/pg-core/columns/common.cjs.map +1 -1
- package/pg-core/columns/common.d.cts +25 -8
- package/pg-core/columns/common.d.ts +25 -8
- package/pg-core/columns/common.js.map +1 -1
- package/pg-core/columns/varchar.cjs +4 -1
- package/pg-core/columns/varchar.cjs.map +1 -1
- package/pg-core/columns/varchar.d.cts +21 -12
- package/pg-core/columns/varchar.d.ts +21 -12
- package/pg-core/columns/varchar.js +4 -1
- package/pg-core/columns/varchar.js.map +1 -1
- package/pg-core/columns/vector_extension/bit.cjs.map +1 -1
- package/pg-core/columns/vector_extension/bit.d.cts +18 -11
- package/pg-core/columns/vector_extension/bit.d.ts +18 -11
- package/pg-core/columns/vector_extension/bit.js.map +1 -1
- package/pg-core/columns/vector_extension/halfvec.cjs.map +1 -1
- package/pg-core/columns/vector_extension/halfvec.d.cts +20 -11
- package/pg-core/columns/vector_extension/halfvec.d.ts +20 -11
- package/pg-core/columns/vector_extension/halfvec.js.map +1 -1
- package/pg-core/columns/vector_extension/vector.cjs +4 -1
- package/pg-core/columns/vector_extension/vector.cjs.map +1 -1
- package/pg-core/columns/vector_extension/vector.d.cts +19 -10
- package/pg-core/columns/vector_extension/vector.d.ts +19 -10
- package/pg-core/columns/vector_extension/vector.js +4 -1
- package/pg-core/columns/vector_extension/vector.js.map +1 -1
- package/pg-core/db.cjs +4 -2
- package/pg-core/db.cjs.map +1 -1
- package/pg-core/db.d.cts +2 -2
- package/pg-core/db.d.ts +2 -2
- package/pg-core/db.js +4 -2
- package/pg-core/db.js.map +1 -1
- package/pg-core/query-builders/count.cjs +1 -0
- package/pg-core/query-builders/count.cjs.map +1 -1
- package/pg-core/query-builders/count.d.cts +2 -1
- package/pg-core/query-builders/count.d.ts +2 -1
- package/pg-core/query-builders/count.js +1 -0
- package/pg-core/query-builders/count.js.map +1 -1
- package/pg-core/query-builders/delete.cjs.map +1 -1
- package/pg-core/query-builders/delete.js.map +1 -1
- package/pg-core/query-builders/insert.cjs +1 -9
- package/pg-core/query-builders/insert.cjs.map +1 -1
- package/pg-core/query-builders/insert.js +1 -9
- package/pg-core/query-builders/insert.js.map +1 -1
- package/pg-core/query-builders/query.cjs.map +1 -1
- package/pg-core/query-builders/query.js.map +1 -1
- package/pg-core/query-builders/refresh-materialized-view.cjs.map +1 -1
- package/pg-core/query-builders/refresh-materialized-view.js.map +1 -1
- package/pg-core/query-builders/select.cjs +2 -10
- package/pg-core/query-builders/select.cjs.map +1 -1
- package/pg-core/query-builders/select.js +8 -11
- package/pg-core/query-builders/select.js.map +1 -1
- package/pg-core/query-builders/update.cjs +1 -7
- package/pg-core/query-builders/update.cjs.map +1 -1
- package/pg-core/query-builders/update.d.cts +2 -2
- package/pg-core/query-builders/update.d.ts +2 -2
- package/pg-core/query-builders/update.js +6 -8
- package/pg-core/query-builders/update.js.map +1 -1
- package/pg-core/session.cjs.map +1 -1
- package/pg-core/session.d.cts +2 -1
- package/pg-core/session.d.ts +2 -1
- package/pg-core/session.js.map +1 -1
- package/pg-core/utils.d.cts +2 -3
- package/pg-core/utils.d.ts +2 -3
- package/pg-core/view.cjs.map +1 -1
- package/pg-core/view.d.cts +4 -5
- package/pg-core/view.d.ts +4 -5
- package/pg-core/view.js.map +1 -1
- package/query-builders/select.types.cjs.map +1 -1
- package/query-builders/select.types.d.cts +2 -2
- package/query-builders/select.types.d.ts +2 -2
- package/singlestore/driver.cjs +113 -0
- package/singlestore/driver.cjs.map +1 -0
- package/singlestore/driver.d.cts +52 -0
- package/singlestore/driver.d.ts +52 -0
- package/singlestore/driver.js +89 -0
- package/singlestore/driver.js.map +1 -0
- package/singlestore/index.cjs +25 -0
- package/singlestore/index.cjs.map +1 -0
- package/singlestore/index.d.cts +2 -0
- package/singlestore/index.d.ts +2 -0
- package/singlestore/index.js +3 -0
- package/singlestore/index.js.map +1 -0
- package/singlestore/migrator.cjs +33 -0
- package/singlestore/migrator.cjs.map +1 -0
- package/singlestore/migrator.d.cts +3 -0
- package/singlestore/migrator.d.ts +3 -0
- package/singlestore/migrator.js +9 -0
- package/singlestore/migrator.js.map +1 -0
- package/singlestore/session.cjs +258 -0
- package/singlestore/session.cjs.map +1 -0
- package/singlestore/session.d.cts +52 -0
- package/singlestore/session.d.ts +52 -0
- package/singlestore/session.js +236 -0
- package/singlestore/session.js.map +1 -0
- package/singlestore-core/alias.cjs +32 -0
- package/singlestore-core/alias.cjs.map +1 -0
- package/singlestore-core/alias.d.cts +4 -0
- package/singlestore-core/alias.d.ts +4 -0
- package/singlestore-core/alias.js +8 -0
- package/singlestore-core/alias.js.map +1 -0
- package/singlestore-core/columns/all.cjs +80 -0
- package/singlestore-core/columns/all.cjs.map +1 -0
- package/singlestore-core/columns/all.d.cts +51 -0
- package/singlestore-core/columns/all.d.ts +51 -0
- package/singlestore-core/columns/all.js +56 -0
- package/singlestore-core/columns/all.js.map +1 -0
- package/singlestore-core/columns/bigint.cjs +96 -0
- package/singlestore-core/columns/bigint.cjs.map +1 -0
- package/singlestore-core/columns/bigint.d.cts +53 -0
- package/singlestore-core/columns/bigint.d.ts +53 -0
- package/singlestore-core/columns/bigint.js +68 -0
- package/singlestore-core/columns/bigint.js.map +1 -0
- package/singlestore-core/columns/binary.cjs +60 -0
- package/singlestore-core/columns/binary.cjs.map +1 -0
- package/singlestore-core/columns/binary.d.cts +28 -0
- package/singlestore-core/columns/binary.d.ts +28 -0
- package/singlestore-core/columns/binary.js +34 -0
- package/singlestore-core/columns/binary.js.map +1 -0
- package/singlestore-core/columns/boolean.cjs +62 -0
- package/singlestore-core/columns/boolean.cjs.map +1 -0
- package/singlestore-core/columns/boolean.d.cts +24 -0
- package/singlestore-core/columns/boolean.d.ts +24 -0
- package/singlestore-core/columns/boolean.js +36 -0
- package/singlestore-core/columns/boolean.js.map +1 -0
- package/singlestore-core/columns/char.cjs +62 -0
- package/singlestore-core/columns/char.cjs.map +1 -0
- package/singlestore-core/columns/char.d.cts +31 -0
- package/singlestore-core/columns/char.d.ts +31 -0
- package/singlestore-core/columns/char.js +36 -0
- package/singlestore-core/columns/char.js.map +1 -0
- package/singlestore-core/columns/common.cjs +82 -0
- package/singlestore-core/columns/common.cjs.map +1 -0
- package/singlestore-core/columns/common.d.cts +42 -0
- package/singlestore-core/columns/common.d.ts +42 -0
- package/singlestore-core/columns/common.js +55 -0
- package/singlestore-core/columns/common.js.map +1 -0
- package/singlestore-core/columns/custom.cjs +77 -0
- package/singlestore-core/columns/custom.cjs.map +1 -0
- package/singlestore-core/columns/custom.d.cts +156 -0
- package/singlestore-core/columns/custom.d.ts +156 -0
- package/singlestore-core/columns/custom.js +51 -0
- package/singlestore-core/columns/custom.js.map +1 -0
- package/singlestore-core/columns/date.cjs +93 -0
- package/singlestore-core/columns/date.cjs.map +1 -0
- package/singlestore-core/columns/date.common.cjs +48 -0
- package/singlestore-core/columns/date.common.cjs.map +1 -0
- package/singlestore-core/columns/date.common.d.cts +16 -0
- package/singlestore-core/columns/date.common.d.ts +16 -0
- package/singlestore-core/columns/date.common.js +23 -0
- package/singlestore-core/columns/date.common.js.map +1 -0
- package/singlestore-core/columns/date.d.cts +53 -0
- package/singlestore-core/columns/date.d.ts +53 -0
- package/singlestore-core/columns/date.js +65 -0
- package/singlestore-core/columns/date.js.map +1 -0
- package/singlestore-core/columns/datetime.cjs +106 -0
- package/singlestore-core/columns/datetime.cjs.map +1 -0
- package/singlestore-core/columns/datetime.d.cts +54 -0
- package/singlestore-core/columns/datetime.d.ts +54 -0
- package/singlestore-core/columns/datetime.js +78 -0
- package/singlestore-core/columns/datetime.js.map +1 -0
- package/singlestore-core/columns/decimal.cjs +76 -0
- package/singlestore-core/columns/decimal.cjs.map +1 -0
- package/singlestore-core/columns/decimal.d.cts +32 -0
- package/singlestore-core/columns/decimal.d.ts +32 -0
- package/singlestore-core/columns/decimal.js +50 -0
- package/singlestore-core/columns/decimal.js.map +1 -0
- package/singlestore-core/columns/double.cjs +72 -0
- package/singlestore-core/columns/double.cjs.map +1 -0
- package/singlestore-core/columns/double.d.cts +32 -0
- package/singlestore-core/columns/double.d.ts +32 -0
- package/singlestore-core/columns/double.js +46 -0
- package/singlestore-core/columns/double.js.map +1 -0
- package/singlestore-core/columns/enum.cjs +67 -0
- package/singlestore-core/columns/enum.cjs.map +1 -0
- package/singlestore-core/columns/enum.d.cts +31 -0
- package/singlestore-core/columns/enum.d.ts +31 -0
- package/singlestore-core/columns/enum.js +41 -0
- package/singlestore-core/columns/enum.js.map +1 -0
- package/singlestore-core/columns/float.cjs +72 -0
- package/singlestore-core/columns/float.cjs.map +1 -0
- package/singlestore-core/columns/float.d.cts +32 -0
- package/singlestore-core/columns/float.d.ts +32 -0
- package/singlestore-core/columns/float.js +46 -0
- package/singlestore-core/columns/float.js.map +1 -0
- package/singlestore-core/columns/index.cjs +71 -0
- package/singlestore-core/columns/index.cjs.map +1 -0
- package/singlestore-core/columns/index.d.cts +25 -0
- package/singlestore-core/columns/index.d.ts +25 -0
- package/singlestore-core/columns/index.js +26 -0
- package/singlestore-core/columns/index.js.map +1 -0
- package/singlestore-core/columns/int.cjs +65 -0
- package/singlestore-core/columns/int.cjs.map +1 -0
- package/singlestore-core/columns/int.d.cts +28 -0
- package/singlestore-core/columns/int.d.ts +28 -0
- package/singlestore-core/columns/int.js +39 -0
- package/singlestore-core/columns/int.js.map +1 -0
- package/singlestore-core/columns/json.cjs +59 -0
- package/singlestore-core/columns/json.cjs.map +1 -0
- package/singlestore-core/columns/json.d.cts +24 -0
- package/singlestore-core/columns/json.d.ts +24 -0
- package/singlestore-core/columns/json.js +33 -0
- package/singlestore-core/columns/json.js.map +1 -0
- package/singlestore-core/columns/mediumint.cjs +65 -0
- package/singlestore-core/columns/mediumint.cjs.map +1 -0
- package/singlestore-core/columns/mediumint.d.cts +26 -0
- package/singlestore-core/columns/mediumint.d.ts +26 -0
- package/singlestore-core/columns/mediumint.js +39 -0
- package/singlestore-core/columns/mediumint.js.map +1 -0
- package/singlestore-core/columns/real.cjs +68 -0
- package/singlestore-core/columns/real.cjs.map +1 -0
- package/singlestore-core/columns/real.d.cts +30 -0
- package/singlestore-core/columns/real.d.ts +30 -0
- package/singlestore-core/columns/real.js +42 -0
- package/singlestore-core/columns/real.js.map +1 -0
- package/singlestore-core/columns/serial.cjs +64 -0
- package/singlestore-core/columns/serial.cjs.map +1 -0
- package/singlestore-core/columns/serial.d.cts +24 -0
- package/singlestore-core/columns/serial.d.ts +24 -0
- package/singlestore-core/columns/serial.js +38 -0
- package/singlestore-core/columns/serial.js.map +1 -0
- package/singlestore-core/columns/smallint.cjs +65 -0
- package/singlestore-core/columns/smallint.cjs.map +1 -0
- package/singlestore-core/columns/smallint.d.cts +26 -0
- package/singlestore-core/columns/smallint.d.ts +26 -0
- package/singlestore-core/columns/smallint.js +39 -0
- package/singlestore-core/columns/smallint.js.map +1 -0
- package/singlestore-core/columns/text.cjs +80 -0
- package/singlestore-core/columns/text.cjs.map +1 -0
- package/singlestore-core/columns/text.d.cts +46 -0
- package/singlestore-core/columns/text.d.ts +46 -0
- package/singlestore-core/columns/text.js +51 -0
- package/singlestore-core/columns/text.js.map +1 -0
- package/singlestore-core/columns/time.cjs +56 -0
- package/singlestore-core/columns/time.cjs.map +1 -0
- package/singlestore-core/columns/time.d.cts +23 -0
- package/singlestore-core/columns/time.d.ts +23 -0
- package/singlestore-core/columns/time.js +30 -0
- package/singlestore-core/columns/time.js.map +1 -0
- package/singlestore-core/columns/timestamp.cjs +97 -0
- package/singlestore-core/columns/timestamp.cjs.map +1 -0
- package/singlestore-core/columns/timestamp.d.cts +49 -0
- package/singlestore-core/columns/timestamp.d.ts +49 -0
- package/singlestore-core/columns/timestamp.js +69 -0
- package/singlestore-core/columns/timestamp.js.map +1 -0
- package/singlestore-core/columns/tinyint.cjs +65 -0
- package/singlestore-core/columns/tinyint.cjs.map +1 -0
- package/singlestore-core/columns/tinyint.d.cts +26 -0
- package/singlestore-core/columns/tinyint.d.ts +26 -0
- package/singlestore-core/columns/tinyint.js +39 -0
- package/singlestore-core/columns/tinyint.js.map +1 -0
- package/singlestore-core/columns/varbinary.cjs +61 -0
- package/singlestore-core/columns/varbinary.cjs.map +1 -0
- package/singlestore-core/columns/varbinary.d.cts +26 -0
- package/singlestore-core/columns/varbinary.d.ts +26 -0
- package/singlestore-core/columns/varbinary.js +35 -0
- package/singlestore-core/columns/varbinary.js.map +1 -0
- package/singlestore-core/columns/varchar.cjs +63 -0
- package/singlestore-core/columns/varchar.cjs.map +1 -0
- package/singlestore-core/columns/varchar.d.cts +29 -0
- package/singlestore-core/columns/varchar.d.ts +29 -0
- package/singlestore-core/columns/varchar.js +37 -0
- package/singlestore-core/columns/varchar.js.map +1 -0
- package/singlestore-core/columns/year.cjs +56 -0
- package/singlestore-core/columns/year.cjs.map +1 -0
- package/singlestore-core/columns/year.d.cts +23 -0
- package/singlestore-core/columns/year.d.ts +23 -0
- package/singlestore-core/columns/year.js +30 -0
- package/singlestore-core/columns/year.js.map +1 -0
- package/singlestore-core/db.cjs +261 -0
- package/singlestore-core/db.cjs.map +1 -0
- package/singlestore-core/db.d.cts +231 -0
- package/singlestore-core/db.d.ts +231 -0
- package/singlestore-core/db.js +242 -0
- package/singlestore-core/db.js.map +1 -0
- package/singlestore-core/dialect.cjs +607 -0
- package/singlestore-core/dialect.cjs.map +1 -0
- package/singlestore-core/dialect.d.cts +64 -0
- package/singlestore-core/dialect.d.ts +64 -0
- package/singlestore-core/dialect.js +589 -0
- package/singlestore-core/dialect.js.map +1 -0
- package/singlestore-core/expressions.cjs +49 -0
- package/singlestore-core/expressions.cjs.map +1 -0
- package/singlestore-core/expressions.d.cts +8 -0
- package/singlestore-core/expressions.d.ts +8 -0
- package/singlestore-core/expressions.js +22 -0
- package/singlestore-core/expressions.js.map +1 -0
- package/singlestore-core/index.cjs +47 -0
- package/singlestore-core/index.cjs.map +1 -0
- package/singlestore-core/index.d.cts +13 -0
- package/singlestore-core/index.d.ts +13 -0
- package/singlestore-core/index.js +14 -0
- package/singlestore-core/index.js.map +1 -0
- package/singlestore-core/indexes.cjs +88 -0
- package/singlestore-core/indexes.cjs.map +1 -0
- package/singlestore-core/indexes.d.cts +62 -0
- package/singlestore-core/indexes.d.ts +62 -0
- package/singlestore-core/indexes.js +60 -0
- package/singlestore-core/indexes.js.map +1 -0
- package/singlestore-core/primary-keys.cjs +68 -0
- package/singlestore-core/primary-keys.cjs.map +1 -0
- package/singlestore-core/primary-keys.d.cts +30 -0
- package/singlestore-core/primary-keys.d.ts +30 -0
- package/singlestore-core/primary-keys.js +42 -0
- package/singlestore-core/primary-keys.js.map +1 -0
- package/singlestore-core/query-builders/count.cjs +73 -0
- package/singlestore-core/query-builders/count.cjs.map +1 -0
- package/singlestore-core/query-builders/count.d.cts +25 -0
- package/singlestore-core/query-builders/count.d.ts +25 -0
- package/singlestore-core/query-builders/count.js +49 -0
- package/singlestore-core/query-builders/count.js.map +1 -0
- package/singlestore-core/query-builders/delete.cjs +123 -0
- package/singlestore-core/query-builders/delete.cjs.map +1 -0
- package/singlestore-core/query-builders/delete.d.cts +83 -0
- package/singlestore-core/query-builders/delete.d.ts +83 -0
- package/singlestore-core/query-builders/delete.js +99 -0
- package/singlestore-core/query-builders/delete.js.map +1 -0
- package/singlestore-core/query-builders/index.cjs +33 -0
- package/singlestore-core/query-builders/index.cjs.map +1 -0
- package/singlestore-core/query-builders/index.d.cts +6 -0
- package/singlestore-core/query-builders/index.d.ts +6 -0
- package/singlestore-core/query-builders/index.js +7 -0
- package/singlestore-core/query-builders/index.js.map +1 -0
- package/singlestore-core/query-builders/insert.cjs +146 -0
- package/singlestore-core/query-builders/insert.cjs.map +1 -0
- package/singlestore-core/query-builders/insert.d.cts +106 -0
- package/singlestore-core/query-builders/insert.d.ts +106 -0
- package/singlestore-core/query-builders/insert.js +121 -0
- package/singlestore-core/query-builders/insert.js.map +1 -0
- package/singlestore-core/query-builders/query-builder.cjs +99 -0
- package/singlestore-core/query-builders/query-builder.cjs.map +1 -0
- package/singlestore-core/query-builders/query-builder.d.cts +33 -0
- package/singlestore-core/query-builders/query-builder.d.ts +33 -0
- package/singlestore-core/query-builders/query-builder.js +75 -0
- package/singlestore-core/query-builders/query-builder.js.map +1 -0
- package/singlestore-core/query-builders/query.cjs +126 -0
- package/singlestore-core/query-builders/query.cjs.map +1 -0
- package/singlestore-core/query-builders/query.d.cts +42 -0
- package/singlestore-core/query-builders/query.d.ts +42 -0
- package/singlestore-core/query-builders/query.js +103 -0
- package/singlestore-core/query-builders/query.js.map +1 -0
- package/singlestore-core/query-builders/select.cjs +687 -0
- package/singlestore-core/query-builders/select.cjs.map +1 -0
- package/singlestore-core/query-builders/select.d.cts +585 -0
- package/singlestore-core/query-builders/select.d.ts +585 -0
- package/singlestore-core/query-builders/select.js +662 -0
- package/singlestore-core/query-builders/select.js.map +1 -0
- package/singlestore-core/query-builders/select.types.cjs +17 -0
- package/singlestore-core/query-builders/select.types.cjs.map +1 -0
- package/singlestore-core/query-builders/select.types.d.cts +137 -0
- package/singlestore-core/query-builders/select.types.d.ts +137 -0
- package/singlestore-core/query-builders/select.types.js +1 -0
- package/singlestore-core/query-builders/select.types.js.map +1 -0
- package/singlestore-core/query-builders/update.cjs +147 -0
- package/singlestore-core/query-builders/update.cjs.map +1 -0
- package/singlestore-core/query-builders/update.d.cts +102 -0
- package/singlestore-core/query-builders/update.d.ts +102 -0
- package/singlestore-core/query-builders/update.js +122 -0
- package/singlestore-core/query-builders/update.js.map +1 -0
- package/singlestore-core/schema.cjs +56 -0
- package/singlestore-core/schema.cjs.map +1 -0
- package/singlestore-core/schema.d.cts +22 -0
- package/singlestore-core/schema.d.ts +22 -0
- package/singlestore-core/schema.js +29 -0
- package/singlestore-core/schema.js.map +1 -0
- package/singlestore-core/session.cjs +87 -0
- package/singlestore-core/session.cjs.map +1 -0
- package/singlestore-core/session.d.cts +66 -0
- package/singlestore-core/session.d.ts +66 -0
- package/singlestore-core/session.js +61 -0
- package/singlestore-core/session.js.map +1 -0
- package/singlestore-core/subquery.cjs +17 -0
- package/singlestore-core/subquery.cjs.map +1 -0
- package/singlestore-core/subquery.d.cts +5 -0
- package/singlestore-core/subquery.d.ts +5 -0
- package/singlestore-core/subquery.js +1 -0
- package/singlestore-core/subquery.js.map +1 -0
- package/singlestore-core/table.cjs +73 -0
- package/singlestore-core/table.cjs.map +1 -0
- package/singlestore-core/table.d.cts +40 -0
- package/singlestore-core/table.d.ts +40 -0
- package/singlestore-core/table.js +46 -0
- package/singlestore-core/table.js.map +1 -0
- package/singlestore-core/unique-constraint.cjs +82 -0
- package/singlestore-core/unique-constraint.cjs.map +1 -0
- package/singlestore-core/unique-constraint.d.cts +24 -0
- package/singlestore-core/unique-constraint.d.ts +24 -0
- package/singlestore-core/unique-constraint.js +54 -0
- package/singlestore-core/unique-constraint.js.map +1 -0
- package/singlestore-core/utils.cjs +65 -0
- package/singlestore-core/utils.cjs.map +1 -0
- package/singlestore-core/utils.d.cts +13 -0
- package/singlestore-core/utils.d.ts +13 -0
- package/singlestore-core/utils.js +41 -0
- package/singlestore-core/utils.js.map +1 -0
- package/singlestore-core/view-base.cjs +33 -0
- package/singlestore-core/view-base.cjs.map +1 -0
- package/singlestore-core/view-base.d.cts +9 -0
- package/singlestore-core/view-base.d.ts +9 -0
- package/singlestore-core/view-base.js +9 -0
- package/singlestore-core/view-base.js.map +1 -0
- package/singlestore-core/view-common.cjs +29 -0
- package/singlestore-core/view-common.cjs.map +1 -0
- package/singlestore-core/view-common.d.cts +1 -0
- package/singlestore-core/view-common.d.ts +1 -0
- package/singlestore-core/view-common.js +5 -0
- package/singlestore-core/view-common.js.map +1 -0
- package/singlestore-core/view.cjs +146 -0
- package/singlestore-core/view.cjs.map +1 -0
- package/singlestore-core/view.d.cts +65 -0
- package/singlestore-core/view.d.ts +65 -0
- package/singlestore-core/view.js +119 -0
- package/singlestore-core/view.js.map +1 -0
- package/singlestore-proxy/driver.cjs +62 -0
- package/singlestore-proxy/driver.cjs.map +1 -0
- package/singlestore-proxy/driver.d.cts +13 -0
- package/singlestore-proxy/driver.d.ts +13 -0
- package/singlestore-proxy/driver.js +42 -0
- package/singlestore-proxy/driver.js.map +1 -0
- package/singlestore-proxy/index.cjs +25 -0
- package/singlestore-proxy/index.cjs.map +1 -0
- package/singlestore-proxy/index.d.cts +2 -0
- package/singlestore-proxy/index.d.ts +2 -0
- package/singlestore-proxy/index.js +3 -0
- package/singlestore-proxy/index.js.map +1 -0
- package/singlestore-proxy/migrator.cjs +60 -0
- package/singlestore-proxy/migrator.cjs.map +1 -0
- package/singlestore-proxy/migrator.d.cts +4 -0
- package/singlestore-proxy/migrator.d.ts +4 -0
- package/singlestore-proxy/migrator.js +36 -0
- package/singlestore-proxy/migrator.js.map +1 -0
- package/singlestore-proxy/session.cjs +127 -0
- package/singlestore-proxy/session.cjs.map +1 -0
- package/singlestore-proxy/session.d.cts +50 -0
- package/singlestore-proxy/session.d.ts +50 -0
- package/singlestore-proxy/session.js +101 -0
- package/singlestore-proxy/session.js.map +1 -0
- package/sql/sql.cjs +8 -0
- package/sql/sql.cjs.map +1 -1
- package/sql/sql.d.cts +10 -2
- package/sql/sql.d.ts +10 -2
- package/sql/sql.js +7 -0
- package/sql/sql.js.map +1 -1
- package/sqlite-core/columns/blob.cjs +16 -2
- package/sqlite-core/columns/blob.cjs.map +1 -1
- package/sqlite-core/columns/blob.d.cts +2 -2
- package/sqlite-core/columns/blob.d.ts +2 -2
- package/sqlite-core/columns/blob.js +16 -2
- package/sqlite-core/columns/blob.js.map +1 -1
- package/sqlite-core/columns/common.cjs.map +1 -1
- package/sqlite-core/columns/common.d.cts +1 -1
- package/sqlite-core/columns/common.d.ts +1 -1
- package/sqlite-core/columns/common.js.map +1 -1
- package/sqlite-core/columns/text.cjs +4 -1
- package/sqlite-core/columns/text.cjs.map +1 -1
- package/sqlite-core/columns/text.d.cts +19 -12
- package/sqlite-core/columns/text.d.ts +19 -12
- package/sqlite-core/columns/text.js +4 -1
- package/sqlite-core/columns/text.js.map +1 -1
- package/sqlite-core/utils.d.cts +2 -3
- package/sqlite-core/utils.d.ts +2 -3
- package/sqlite-core/view.cjs.map +1 -1
- package/sqlite-core/view.d.cts +2 -3
- package/sqlite-core/view.d.ts +2 -3
- package/sqlite-core/view.js.map +1 -1
- package/supabase/rls.d.cts +3 -1
- package/supabase/rls.d.ts +3 -1
- package/utils.cjs +5 -0
- package/utils.cjs.map +1 -1
- package/utils.d.cts +3 -1
- package/utils.d.ts +3 -1
- package/utils.js +4 -0
- package/utils.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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/singlestore-core/query-builders/update.ts"],"sourcesContent":["import type { GetColumnData } from '~/column.ts';\nimport { entityKind } from '~/entity.ts';\nimport { QueryPromise } from '~/query-promise.ts';\nimport { SelectionProxyHandler } from '~/selection-proxy.ts';\nimport type { SingleStoreDialect } from '~/singlestore-core/dialect.ts';\nimport type {\n\tAnySingleStoreQueryResultHKT,\n\tPreparedQueryHKTBase,\n\tPreparedQueryKind,\n\tSingleStorePreparedQueryConfig,\n\tSingleStoreQueryResultHKT,\n\tSingleStoreQueryResultKind,\n\tSingleStoreSession,\n} from '~/singlestore-core/session.ts';\nimport type { SingleStoreTable } from '~/singlestore-core/table.ts';\nimport type { Placeholder, Query, SQL, SQLWrapper } from '~/sql/sql.ts';\nimport type { Subquery } from '~/subquery.ts';\nimport { Table } from '~/table.ts';\nimport { mapUpdateSet, type UpdateSet, type ValueOrArray } from '~/utils.ts';\nimport type { SingleStoreColumn } from '../columns/common.ts';\nimport type { SelectedFieldsOrdered } from './select.types.ts';\n\nexport interface SingleStoreUpdateConfig {\n\twhere?: SQL | undefined;\n\tlimit?: number | Placeholder;\n\torderBy?: (SingleStoreColumn | SQL | SQL.Aliased)[];\n\tset: UpdateSet;\n\ttable: SingleStoreTable;\n\treturning?: SelectedFieldsOrdered;\n\twithList?: Subquery[];\n}\n\nexport type SingleStoreUpdateSetSource<TTable extends SingleStoreTable> =\n\t& {\n\t\t[Key in keyof TTable['$inferInsert']]?:\n\t\t\t| GetColumnData<TTable['_']['columns'][Key], 'query'>\n\t\t\t| SQL;\n\t}\n\t& {};\n\nexport class SingleStoreUpdateBuilder<\n\tTTable extends SingleStoreTable,\n\tTQueryResult extends SingleStoreQueryResultHKT,\n\tTPreparedQueryHKT extends PreparedQueryHKTBase,\n> {\n\tstatic readonly [entityKind]: string = 'SingleStoreUpdateBuilder';\n\n\tdeclare readonly _: {\n\t\treadonly table: TTable;\n\t};\n\n\tconstructor(\n\t\tprivate table: TTable,\n\t\tprivate session: SingleStoreSession,\n\t\tprivate dialect: SingleStoreDialect,\n\t\tprivate withList?: Subquery[],\n\t) {}\n\n\tset(values: SingleStoreUpdateSetSource<TTable>): SingleStoreUpdateBase<TTable, TQueryResult, TPreparedQueryHKT> {\n\t\treturn new SingleStoreUpdateBase(\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 SingleStoreUpdateWithout<\n\tT extends AnySingleStoreUpdateBase,\n\tTDynamic extends boolean,\n\tK extends keyof T & string,\n> = TDynamic extends true ? T : Omit<\n\tSingleStoreUpdateBase<\n\t\tT['_']['table'],\n\t\tT['_']['queryResult'],\n\t\tT['_']['preparedQueryHKT'],\n\t\tTDynamic,\n\t\tT['_']['excludedMethods'] | K\n\t>,\n\tT['_']['excludedMethods'] | K\n>;\n\nexport type SingleStoreUpdatePrepare<T extends AnySingleStoreUpdateBase> = PreparedQueryKind<\n\tT['_']['preparedQueryHKT'],\n\tSingleStorePreparedQueryConfig & {\n\t\texecute: SingleStoreQueryResultKind<T['_']['queryResult'], never>;\n\t\titerator: never;\n\t},\n\ttrue\n>;\n\nexport type SingleStoreUpdateDynamic<T extends AnySingleStoreUpdateBase> = SingleStoreUpdate<\n\tT['_']['table'],\n\tT['_']['queryResult'],\n\tT['_']['preparedQueryHKT']\n>;\n\nexport type SingleStoreUpdate<\n\tTTable extends SingleStoreTable = SingleStoreTable,\n\tTQueryResult extends SingleStoreQueryResultHKT = AnySingleStoreQueryResultHKT,\n\tTPreparedQueryHKT extends PreparedQueryHKTBase = PreparedQueryHKTBase,\n> = SingleStoreUpdateBase<TTable, TQueryResult, TPreparedQueryHKT, true, never>;\n\nexport type AnySingleStoreUpdateBase = SingleStoreUpdateBase<any, any, any, any, any>;\n\nexport interface SingleStoreUpdateBase<\n\tTTable extends SingleStoreTable,\n\tTQueryResult extends SingleStoreQueryResultHKT,\n\tTPreparedQueryHKT extends PreparedQueryHKTBase,\n\tTDynamic extends boolean = false,\n\tTExcludedMethods extends string = never,\n> extends QueryPromise<SingleStoreQueryResultKind<TQueryResult, never>>, SQLWrapper {\n\treadonly _: {\n\t\treadonly table: TTable;\n\t\treadonly queryResult: TQueryResult;\n\t\treadonly preparedQueryHKT: TPreparedQueryHKT;\n\t\treadonly dynamic: TDynamic;\n\t\treadonly excludedMethods: TExcludedMethods;\n\t};\n}\n\nexport class SingleStoreUpdateBase<\n\tTTable extends SingleStoreTable,\n\tTQueryResult extends SingleStoreQueryResultHKT,\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\tTPreparedQueryHKT extends PreparedQueryHKTBase,\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<SingleStoreQueryResultKind<TQueryResult, never>> implements SQLWrapper {\n\tstatic override readonly [entityKind]: string = 'SingleStoreUpdate';\n\n\tprivate config: SingleStoreUpdateConfig;\n\n\tconstructor(\n\t\ttable: TTable,\n\t\tset: UpdateSet,\n\t\tprivate session: SingleStoreSession,\n\t\tprivate dialect: SingleStoreDialect,\n\t\twithList?: Subquery[],\n\t) {\n\t\tsuper();\n\t\tthis.config = { set, table, withList };\n\t}\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 * db.update(cars).set({ color: 'red' })\n\t * .where(eq(cars.color, 'green'));\n\t * // or\n\t * 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 * 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 * 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): SingleStoreUpdateWithout<this, TDynamic, 'where'> {\n\t\tthis.config.where = where;\n\t\treturn this as any;\n\t}\n\n\torderBy(\n\t\tbuilder: (updateTable: TTable) => ValueOrArray<SingleStoreColumn | SQL | SQL.Aliased>,\n\t): SingleStoreUpdateWithout<this, TDynamic, 'orderBy'>;\n\torderBy(...columns: (SingleStoreColumn | SQL | SQL.Aliased)[]): SingleStoreUpdateWithout<this, TDynamic, 'orderBy'>;\n\torderBy(\n\t\t...columns:\n\t\t\t| [(updateTable: TTable) => ValueOrArray<SingleStoreColumn | SQL | SQL.Aliased>]\n\t\t\t| (SingleStoreColumn | SQL | SQL.Aliased)[]\n\t): SingleStoreUpdateWithout<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.table[Table.Symbol.Columns],\n\t\t\t\t\tnew SelectionProxyHandler({ sqlAliasedBehavior: 'alias', sqlBehavior: 'sql' }),\n\t\t\t\t) as any,\n\t\t\t);\n\n\t\t\tconst orderByArray = Array.isArray(orderBy) ? orderBy : [orderBy];\n\t\t\tthis.config.orderBy = orderByArray;\n\t\t} else {\n\t\t\tconst orderByArray = columns as (SingleStoreColumn | SQL | SQL.Aliased)[];\n\t\t\tthis.config.orderBy = orderByArray;\n\t\t}\n\t\treturn this as any;\n\t}\n\n\tlimit(limit: number | Placeholder): SingleStoreUpdateWithout<this, TDynamic, 'limit'> {\n\t\tthis.config.limit = limit;\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\tprepare(): SingleStoreUpdatePrepare<this> {\n\t\treturn this.session.prepareQuery(\n\t\t\tthis.dialect.sqlToQuery(this.getSQL()),\n\t\t\tthis.config.returning,\n\t\t) as SingleStoreUpdatePrepare<this>;\n\t}\n\n\toverride execute: ReturnType<this['prepare']>['execute'] = (placeholderValues) => {\n\t\treturn this.prepare().execute(placeholderValues);\n\t};\n\n\tprivate createIterator = (): ReturnType<this['prepare']>['iterator'] => {\n\t\tconst self = this;\n\t\treturn async function*(placeholderValues) {\n\t\t\tyield* self.prepare().iterator(placeholderValues);\n\t\t};\n\t};\n\n\titerator = this.createIterator();\n\n\t$dynamic(): SingleStoreUpdateDynamic<this> {\n\t\treturn this as any;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAA2B;AAC3B,2BAA6B;AAC7B,6BAAsC;AActC,mBAAsB;AACtB,mBAAgE;AAsBzD,MAAM,yBAIX;AAAA,EAOD,YACS,OACA,SACA,SACA,UACP;AAJO;AACA;AACA;AACA;AAAA,EACN;AAAA,EAXH,QAAiB,wBAAU,IAAY;AAAA,EAavC,IAAI,QAA4G;AAC/G,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;AAwDO,MAAM,8BASH,kCAAoF;AAAA,EAK7F,YACC,OACA,KACQ,SACA,SACR,UACC;AACD,UAAM;AAJE;AACA;AAIR,SAAK,SAAS,EAAE,KAAK,OAAO,SAAS;AAAA,EACtC;AAAA,EAbA,QAA0B,wBAAU,IAAY;AAAA,EAExC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA8CR,MAAM,OAA2E;AAChF,SAAK,OAAO,QAAQ;AACpB,WAAO;AAAA,EACR;AAAA,EAMA,WACI,SAGmD;AACtD,QAAI,OAAO,QAAQ,CAAC,MAAM,YAAY;AACrC,YAAM,UAAU,QAAQ,CAAC;AAAA,QACxB,IAAI;AAAA,UACH,KAAK,OAAO,MAAM,mBAAM,OAAO,OAAO;AAAA,UACtC,IAAI,6CAAsB,EAAE,oBAAoB,SAAS,aAAa,MAAM,CAAC;AAAA,QAC9E;AAAA,MACD;AAEA,YAAM,eAAe,MAAM,QAAQ,OAAO,IAAI,UAAU,CAAC,OAAO;AAChE,WAAK,OAAO,UAAU;AAAA,IACvB,OAAO;AACN,YAAM,eAAe;AACrB,WAAK,OAAO,UAAU;AAAA,IACvB;AACA,WAAO;AAAA,EACR;AAAA,EAEA,MAAM,OAAgF;AACrF,SAAK,OAAO,QAAQ;AACpB,WAAO;AAAA,EACR;AAAA;AAAA,EAGA,SAAc;AACb,WAAO,KAAK,QAAQ,iBAAiB,KAAK,MAAM;AAAA,EACjD;AAAA,EAEA,QAAe;AACd,UAAM,EAAE,SAAS,UAAU,GAAG,KAAK,IAAI,KAAK,QAAQ,WAAW,KAAK,OAAO,CAAC;AAC5E,WAAO;AAAA,EACR;AAAA,EAEA,UAA0C;AACzC,WAAO,KAAK,QAAQ;AAAA,MACnB,KAAK,QAAQ,WAAW,KAAK,OAAO,CAAC;AAAA,MACrC,KAAK,OAAO;AAAA,IACb;AAAA,EACD;AAAA,EAES,UAAkD,CAAC,sBAAsB;AACjF,WAAO,KAAK,QAAQ,EAAE,QAAQ,iBAAiB;AAAA,EAChD;AAAA,EAEQ,iBAAiB,MAA+C;AACvE,UAAM,OAAO;AACb,WAAO,iBAAgB,mBAAmB;AACzC,aAAO,KAAK,QAAQ,EAAE,SAAS,iBAAiB;AAAA,IACjD;AAAA,EACD;AAAA,EAEA,WAAW,KAAK,eAAe;AAAA,EAE/B,WAA2C;AAC1C,WAAO;AAAA,EACR;AACD;","names":[]}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type { GetColumnData } from "../../column.cjs";
|
|
2
|
+
import { entityKind } from "../../entity.cjs";
|
|
3
|
+
import { QueryPromise } from "../../query-promise.cjs";
|
|
4
|
+
import type { SingleStoreDialect } from "../dialect.cjs";
|
|
5
|
+
import type { AnySingleStoreQueryResultHKT, PreparedQueryHKTBase, PreparedQueryKind, SingleStorePreparedQueryConfig, SingleStoreQueryResultHKT, SingleStoreQueryResultKind, SingleStoreSession } from "../session.cjs";
|
|
6
|
+
import type { SingleStoreTable } from "../table.cjs";
|
|
7
|
+
import type { Placeholder, Query, SQL, SQLWrapper } from "../../sql/sql.cjs";
|
|
8
|
+
import type { Subquery } from "../../subquery.cjs";
|
|
9
|
+
import { type UpdateSet, type ValueOrArray } from "../../utils.cjs";
|
|
10
|
+
import type { SingleStoreColumn } from "../columns/common.cjs";
|
|
11
|
+
import type { SelectedFieldsOrdered } from "./select.types.cjs";
|
|
12
|
+
export interface SingleStoreUpdateConfig {
|
|
13
|
+
where?: SQL | undefined;
|
|
14
|
+
limit?: number | Placeholder;
|
|
15
|
+
orderBy?: (SingleStoreColumn | SQL | SQL.Aliased)[];
|
|
16
|
+
set: UpdateSet;
|
|
17
|
+
table: SingleStoreTable;
|
|
18
|
+
returning?: SelectedFieldsOrdered;
|
|
19
|
+
withList?: Subquery[];
|
|
20
|
+
}
|
|
21
|
+
export type SingleStoreUpdateSetSource<TTable extends SingleStoreTable> = {
|
|
22
|
+
[Key in keyof TTable['$inferInsert']]?: GetColumnData<TTable['_']['columns'][Key], 'query'> | SQL;
|
|
23
|
+
} & {};
|
|
24
|
+
export declare class SingleStoreUpdateBuilder<TTable extends SingleStoreTable, TQueryResult extends SingleStoreQueryResultHKT, TPreparedQueryHKT extends PreparedQueryHKTBase> {
|
|
25
|
+
private table;
|
|
26
|
+
private session;
|
|
27
|
+
private dialect;
|
|
28
|
+
private withList?;
|
|
29
|
+
static readonly [entityKind]: string;
|
|
30
|
+
readonly _: {
|
|
31
|
+
readonly table: TTable;
|
|
32
|
+
};
|
|
33
|
+
constructor(table: TTable, session: SingleStoreSession, dialect: SingleStoreDialect, withList?: Subquery[] | undefined);
|
|
34
|
+
set(values: SingleStoreUpdateSetSource<TTable>): SingleStoreUpdateBase<TTable, TQueryResult, TPreparedQueryHKT>;
|
|
35
|
+
}
|
|
36
|
+
export type SingleStoreUpdateWithout<T extends AnySingleStoreUpdateBase, TDynamic extends boolean, K extends keyof T & string> = TDynamic extends true ? T : Omit<SingleStoreUpdateBase<T['_']['table'], T['_']['queryResult'], T['_']['preparedQueryHKT'], TDynamic, T['_']['excludedMethods'] | K>, T['_']['excludedMethods'] | K>;
|
|
37
|
+
export type SingleStoreUpdatePrepare<T extends AnySingleStoreUpdateBase> = PreparedQueryKind<T['_']['preparedQueryHKT'], SingleStorePreparedQueryConfig & {
|
|
38
|
+
execute: SingleStoreQueryResultKind<T['_']['queryResult'], never>;
|
|
39
|
+
iterator: never;
|
|
40
|
+
}, true>;
|
|
41
|
+
export type SingleStoreUpdateDynamic<T extends AnySingleStoreUpdateBase> = SingleStoreUpdate<T['_']['table'], T['_']['queryResult'], T['_']['preparedQueryHKT']>;
|
|
42
|
+
export type SingleStoreUpdate<TTable extends SingleStoreTable = SingleStoreTable, TQueryResult extends SingleStoreQueryResultHKT = AnySingleStoreQueryResultHKT, TPreparedQueryHKT extends PreparedQueryHKTBase = PreparedQueryHKTBase> = SingleStoreUpdateBase<TTable, TQueryResult, TPreparedQueryHKT, true, never>;
|
|
43
|
+
export type AnySingleStoreUpdateBase = SingleStoreUpdateBase<any, any, any, any, any>;
|
|
44
|
+
export interface SingleStoreUpdateBase<TTable extends SingleStoreTable, TQueryResult extends SingleStoreQueryResultHKT, TPreparedQueryHKT extends PreparedQueryHKTBase, TDynamic extends boolean = false, TExcludedMethods extends string = never> extends QueryPromise<SingleStoreQueryResultKind<TQueryResult, never>>, SQLWrapper {
|
|
45
|
+
readonly _: {
|
|
46
|
+
readonly table: TTable;
|
|
47
|
+
readonly queryResult: TQueryResult;
|
|
48
|
+
readonly preparedQueryHKT: TPreparedQueryHKT;
|
|
49
|
+
readonly dynamic: TDynamic;
|
|
50
|
+
readonly excludedMethods: TExcludedMethods;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
export declare class SingleStoreUpdateBase<TTable extends SingleStoreTable, TQueryResult extends SingleStoreQueryResultHKT, TPreparedQueryHKT extends PreparedQueryHKTBase, TDynamic extends boolean = false, TExcludedMethods extends string = never> extends QueryPromise<SingleStoreQueryResultKind<TQueryResult, never>> implements SQLWrapper {
|
|
54
|
+
private session;
|
|
55
|
+
private dialect;
|
|
56
|
+
static readonly [entityKind]: string;
|
|
57
|
+
private config;
|
|
58
|
+
constructor(table: TTable, set: UpdateSet, session: SingleStoreSession, dialect: SingleStoreDialect, withList?: Subquery[]);
|
|
59
|
+
/**
|
|
60
|
+
* Adds a 'where' clause to the query.
|
|
61
|
+
*
|
|
62
|
+
* Calling this method will update only those rows that fulfill a specified condition.
|
|
63
|
+
*
|
|
64
|
+
* See docs: {@link https://orm.drizzle.team/docs/update}
|
|
65
|
+
*
|
|
66
|
+
* @param where the 'where' clause.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* You can use conditional operators and `sql function` to filter the rows to be updated.
|
|
70
|
+
*
|
|
71
|
+
* ```ts
|
|
72
|
+
* // Update all cars with green color
|
|
73
|
+
* db.update(cars).set({ color: 'red' })
|
|
74
|
+
* .where(eq(cars.color, 'green'));
|
|
75
|
+
* // or
|
|
76
|
+
* db.update(cars).set({ color: 'red' })
|
|
77
|
+
* .where(sql`${cars.color} = 'green'`)
|
|
78
|
+
* ```
|
|
79
|
+
*
|
|
80
|
+
* You can logically combine conditional operators with `and()` and `or()` operators:
|
|
81
|
+
*
|
|
82
|
+
* ```ts
|
|
83
|
+
* // Update all BMW cars with a green color
|
|
84
|
+
* db.update(cars).set({ color: 'red' })
|
|
85
|
+
* .where(and(eq(cars.color, 'green'), eq(cars.brand, 'BMW')));
|
|
86
|
+
*
|
|
87
|
+
* // Update all cars with the green or blue color
|
|
88
|
+
* db.update(cars).set({ color: 'red' })
|
|
89
|
+
* .where(or(eq(cars.color, 'green'), eq(cars.color, 'blue')));
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
where(where: SQL | undefined): SingleStoreUpdateWithout<this, TDynamic, 'where'>;
|
|
93
|
+
orderBy(builder: (updateTable: TTable) => ValueOrArray<SingleStoreColumn | SQL | SQL.Aliased>): SingleStoreUpdateWithout<this, TDynamic, 'orderBy'>;
|
|
94
|
+
orderBy(...columns: (SingleStoreColumn | SQL | SQL.Aliased)[]): SingleStoreUpdateWithout<this, TDynamic, 'orderBy'>;
|
|
95
|
+
limit(limit: number | Placeholder): SingleStoreUpdateWithout<this, TDynamic, 'limit'>;
|
|
96
|
+
toSQL(): Query;
|
|
97
|
+
prepare(): SingleStoreUpdatePrepare<this>;
|
|
98
|
+
execute: ReturnType<this['prepare']>['execute'];
|
|
99
|
+
private createIterator;
|
|
100
|
+
iterator: ReturnType<this["prepare"]>["iterator"];
|
|
101
|
+
$dynamic(): SingleStoreUpdateDynamic<this>;
|
|
102
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type { GetColumnData } from "../../column.js";
|
|
2
|
+
import { entityKind } from "../../entity.js";
|
|
3
|
+
import { QueryPromise } from "../../query-promise.js";
|
|
4
|
+
import type { SingleStoreDialect } from "../dialect.js";
|
|
5
|
+
import type { AnySingleStoreQueryResultHKT, PreparedQueryHKTBase, PreparedQueryKind, SingleStorePreparedQueryConfig, SingleStoreQueryResultHKT, SingleStoreQueryResultKind, SingleStoreSession } from "../session.js";
|
|
6
|
+
import type { SingleStoreTable } from "../table.js";
|
|
7
|
+
import type { Placeholder, Query, SQL, SQLWrapper } from "../../sql/sql.js";
|
|
8
|
+
import type { Subquery } from "../../subquery.js";
|
|
9
|
+
import { type UpdateSet, type ValueOrArray } from "../../utils.js";
|
|
10
|
+
import type { SingleStoreColumn } from "../columns/common.js";
|
|
11
|
+
import type { SelectedFieldsOrdered } from "./select.types.js";
|
|
12
|
+
export interface SingleStoreUpdateConfig {
|
|
13
|
+
where?: SQL | undefined;
|
|
14
|
+
limit?: number | Placeholder;
|
|
15
|
+
orderBy?: (SingleStoreColumn | SQL | SQL.Aliased)[];
|
|
16
|
+
set: UpdateSet;
|
|
17
|
+
table: SingleStoreTable;
|
|
18
|
+
returning?: SelectedFieldsOrdered;
|
|
19
|
+
withList?: Subquery[];
|
|
20
|
+
}
|
|
21
|
+
export type SingleStoreUpdateSetSource<TTable extends SingleStoreTable> = {
|
|
22
|
+
[Key in keyof TTable['$inferInsert']]?: GetColumnData<TTable['_']['columns'][Key], 'query'> | SQL;
|
|
23
|
+
} & {};
|
|
24
|
+
export declare class SingleStoreUpdateBuilder<TTable extends SingleStoreTable, TQueryResult extends SingleStoreQueryResultHKT, TPreparedQueryHKT extends PreparedQueryHKTBase> {
|
|
25
|
+
private table;
|
|
26
|
+
private session;
|
|
27
|
+
private dialect;
|
|
28
|
+
private withList?;
|
|
29
|
+
static readonly [entityKind]: string;
|
|
30
|
+
readonly _: {
|
|
31
|
+
readonly table: TTable;
|
|
32
|
+
};
|
|
33
|
+
constructor(table: TTable, session: SingleStoreSession, dialect: SingleStoreDialect, withList?: Subquery[] | undefined);
|
|
34
|
+
set(values: SingleStoreUpdateSetSource<TTable>): SingleStoreUpdateBase<TTable, TQueryResult, TPreparedQueryHKT>;
|
|
35
|
+
}
|
|
36
|
+
export type SingleStoreUpdateWithout<T extends AnySingleStoreUpdateBase, TDynamic extends boolean, K extends keyof T & string> = TDynamic extends true ? T : Omit<SingleStoreUpdateBase<T['_']['table'], T['_']['queryResult'], T['_']['preparedQueryHKT'], TDynamic, T['_']['excludedMethods'] | K>, T['_']['excludedMethods'] | K>;
|
|
37
|
+
export type SingleStoreUpdatePrepare<T extends AnySingleStoreUpdateBase> = PreparedQueryKind<T['_']['preparedQueryHKT'], SingleStorePreparedQueryConfig & {
|
|
38
|
+
execute: SingleStoreQueryResultKind<T['_']['queryResult'], never>;
|
|
39
|
+
iterator: never;
|
|
40
|
+
}, true>;
|
|
41
|
+
export type SingleStoreUpdateDynamic<T extends AnySingleStoreUpdateBase> = SingleStoreUpdate<T['_']['table'], T['_']['queryResult'], T['_']['preparedQueryHKT']>;
|
|
42
|
+
export type SingleStoreUpdate<TTable extends SingleStoreTable = SingleStoreTable, TQueryResult extends SingleStoreQueryResultHKT = AnySingleStoreQueryResultHKT, TPreparedQueryHKT extends PreparedQueryHKTBase = PreparedQueryHKTBase> = SingleStoreUpdateBase<TTable, TQueryResult, TPreparedQueryHKT, true, never>;
|
|
43
|
+
export type AnySingleStoreUpdateBase = SingleStoreUpdateBase<any, any, any, any, any>;
|
|
44
|
+
export interface SingleStoreUpdateBase<TTable extends SingleStoreTable, TQueryResult extends SingleStoreQueryResultHKT, TPreparedQueryHKT extends PreparedQueryHKTBase, TDynamic extends boolean = false, TExcludedMethods extends string = never> extends QueryPromise<SingleStoreQueryResultKind<TQueryResult, never>>, SQLWrapper {
|
|
45
|
+
readonly _: {
|
|
46
|
+
readonly table: TTable;
|
|
47
|
+
readonly queryResult: TQueryResult;
|
|
48
|
+
readonly preparedQueryHKT: TPreparedQueryHKT;
|
|
49
|
+
readonly dynamic: TDynamic;
|
|
50
|
+
readonly excludedMethods: TExcludedMethods;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
export declare class SingleStoreUpdateBase<TTable extends SingleStoreTable, TQueryResult extends SingleStoreQueryResultHKT, TPreparedQueryHKT extends PreparedQueryHKTBase, TDynamic extends boolean = false, TExcludedMethods extends string = never> extends QueryPromise<SingleStoreQueryResultKind<TQueryResult, never>> implements SQLWrapper {
|
|
54
|
+
private session;
|
|
55
|
+
private dialect;
|
|
56
|
+
static readonly [entityKind]: string;
|
|
57
|
+
private config;
|
|
58
|
+
constructor(table: TTable, set: UpdateSet, session: SingleStoreSession, dialect: SingleStoreDialect, withList?: Subquery[]);
|
|
59
|
+
/**
|
|
60
|
+
* Adds a 'where' clause to the query.
|
|
61
|
+
*
|
|
62
|
+
* Calling this method will update only those rows that fulfill a specified condition.
|
|
63
|
+
*
|
|
64
|
+
* See docs: {@link https://orm.drizzle.team/docs/update}
|
|
65
|
+
*
|
|
66
|
+
* @param where the 'where' clause.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* You can use conditional operators and `sql function` to filter the rows to be updated.
|
|
70
|
+
*
|
|
71
|
+
* ```ts
|
|
72
|
+
* // Update all cars with green color
|
|
73
|
+
* db.update(cars).set({ color: 'red' })
|
|
74
|
+
* .where(eq(cars.color, 'green'));
|
|
75
|
+
* // or
|
|
76
|
+
* db.update(cars).set({ color: 'red' })
|
|
77
|
+
* .where(sql`${cars.color} = 'green'`)
|
|
78
|
+
* ```
|
|
79
|
+
*
|
|
80
|
+
* You can logically combine conditional operators with `and()` and `or()` operators:
|
|
81
|
+
*
|
|
82
|
+
* ```ts
|
|
83
|
+
* // Update all BMW cars with a green color
|
|
84
|
+
* db.update(cars).set({ color: 'red' })
|
|
85
|
+
* .where(and(eq(cars.color, 'green'), eq(cars.brand, 'BMW')));
|
|
86
|
+
*
|
|
87
|
+
* // Update all cars with the green or blue color
|
|
88
|
+
* db.update(cars).set({ color: 'red' })
|
|
89
|
+
* .where(or(eq(cars.color, 'green'), eq(cars.color, 'blue')));
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
where(where: SQL | undefined): SingleStoreUpdateWithout<this, TDynamic, 'where'>;
|
|
93
|
+
orderBy(builder: (updateTable: TTable) => ValueOrArray<SingleStoreColumn | SQL | SQL.Aliased>): SingleStoreUpdateWithout<this, TDynamic, 'orderBy'>;
|
|
94
|
+
orderBy(...columns: (SingleStoreColumn | SQL | SQL.Aliased)[]): SingleStoreUpdateWithout<this, TDynamic, 'orderBy'>;
|
|
95
|
+
limit(limit: number | Placeholder): SingleStoreUpdateWithout<this, TDynamic, 'limit'>;
|
|
96
|
+
toSQL(): Query;
|
|
97
|
+
prepare(): SingleStoreUpdatePrepare<this>;
|
|
98
|
+
execute: ReturnType<this['prepare']>['execute'];
|
|
99
|
+
private createIterator;
|
|
100
|
+
iterator: ReturnType<this["prepare"]>["iterator"];
|
|
101
|
+
$dynamic(): SingleStoreUpdateDynamic<this>;
|
|
102
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { entityKind } from "../../entity.js";
|
|
2
|
+
import { QueryPromise } from "../../query-promise.js";
|
|
3
|
+
import { SelectionProxyHandler } from "../../selection-proxy.js";
|
|
4
|
+
import { Table } from "../../table.js";
|
|
5
|
+
import { mapUpdateSet } from "../../utils.js";
|
|
6
|
+
class SingleStoreUpdateBuilder {
|
|
7
|
+
constructor(table, session, dialect, withList) {
|
|
8
|
+
this.table = table;
|
|
9
|
+
this.session = session;
|
|
10
|
+
this.dialect = dialect;
|
|
11
|
+
this.withList = withList;
|
|
12
|
+
}
|
|
13
|
+
static [entityKind] = "SingleStoreUpdateBuilder";
|
|
14
|
+
set(values) {
|
|
15
|
+
return new SingleStoreUpdateBase(
|
|
16
|
+
this.table,
|
|
17
|
+
mapUpdateSet(this.table, values),
|
|
18
|
+
this.session,
|
|
19
|
+
this.dialect,
|
|
20
|
+
this.withList
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
class SingleStoreUpdateBase extends QueryPromise {
|
|
25
|
+
constructor(table, set, session, dialect, withList) {
|
|
26
|
+
super();
|
|
27
|
+
this.session = session;
|
|
28
|
+
this.dialect = dialect;
|
|
29
|
+
this.config = { set, table, withList };
|
|
30
|
+
}
|
|
31
|
+
static [entityKind] = "SingleStoreUpdate";
|
|
32
|
+
config;
|
|
33
|
+
/**
|
|
34
|
+
* Adds a 'where' clause to the query.
|
|
35
|
+
*
|
|
36
|
+
* Calling this method will update only those rows that fulfill a specified condition.
|
|
37
|
+
*
|
|
38
|
+
* See docs: {@link https://orm.drizzle.team/docs/update}
|
|
39
|
+
*
|
|
40
|
+
* @param where the 'where' clause.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* You can use conditional operators and `sql function` to filter the rows to be updated.
|
|
44
|
+
*
|
|
45
|
+
* ```ts
|
|
46
|
+
* // Update all cars with green color
|
|
47
|
+
* db.update(cars).set({ color: 'red' })
|
|
48
|
+
* .where(eq(cars.color, 'green'));
|
|
49
|
+
* // or
|
|
50
|
+
* db.update(cars).set({ color: 'red' })
|
|
51
|
+
* .where(sql`${cars.color} = 'green'`)
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
54
|
+
* You can logically combine conditional operators with `and()` and `or()` operators:
|
|
55
|
+
*
|
|
56
|
+
* ```ts
|
|
57
|
+
* // Update all BMW cars with a green color
|
|
58
|
+
* db.update(cars).set({ color: 'red' })
|
|
59
|
+
* .where(and(eq(cars.color, 'green'), eq(cars.brand, 'BMW')));
|
|
60
|
+
*
|
|
61
|
+
* // Update all cars with the green or blue color
|
|
62
|
+
* db.update(cars).set({ color: 'red' })
|
|
63
|
+
* .where(or(eq(cars.color, 'green'), eq(cars.color, 'blue')));
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
where(where) {
|
|
67
|
+
this.config.where = where;
|
|
68
|
+
return this;
|
|
69
|
+
}
|
|
70
|
+
orderBy(...columns) {
|
|
71
|
+
if (typeof columns[0] === "function") {
|
|
72
|
+
const orderBy = columns[0](
|
|
73
|
+
new Proxy(
|
|
74
|
+
this.config.table[Table.Symbol.Columns],
|
|
75
|
+
new SelectionProxyHandler({ sqlAliasedBehavior: "alias", sqlBehavior: "sql" })
|
|
76
|
+
)
|
|
77
|
+
);
|
|
78
|
+
const orderByArray = Array.isArray(orderBy) ? orderBy : [orderBy];
|
|
79
|
+
this.config.orderBy = orderByArray;
|
|
80
|
+
} else {
|
|
81
|
+
const orderByArray = columns;
|
|
82
|
+
this.config.orderBy = orderByArray;
|
|
83
|
+
}
|
|
84
|
+
return this;
|
|
85
|
+
}
|
|
86
|
+
limit(limit) {
|
|
87
|
+
this.config.limit = limit;
|
|
88
|
+
return this;
|
|
89
|
+
}
|
|
90
|
+
/** @internal */
|
|
91
|
+
getSQL() {
|
|
92
|
+
return this.dialect.buildUpdateQuery(this.config);
|
|
93
|
+
}
|
|
94
|
+
toSQL() {
|
|
95
|
+
const { typings: _typings, ...rest } = this.dialect.sqlToQuery(this.getSQL());
|
|
96
|
+
return rest;
|
|
97
|
+
}
|
|
98
|
+
prepare() {
|
|
99
|
+
return this.session.prepareQuery(
|
|
100
|
+
this.dialect.sqlToQuery(this.getSQL()),
|
|
101
|
+
this.config.returning
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
execute = (placeholderValues) => {
|
|
105
|
+
return this.prepare().execute(placeholderValues);
|
|
106
|
+
};
|
|
107
|
+
createIterator = () => {
|
|
108
|
+
const self = this;
|
|
109
|
+
return async function* (placeholderValues) {
|
|
110
|
+
yield* self.prepare().iterator(placeholderValues);
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
iterator = this.createIterator();
|
|
114
|
+
$dynamic() {
|
|
115
|
+
return this;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
export {
|
|
119
|
+
SingleStoreUpdateBase,
|
|
120
|
+
SingleStoreUpdateBuilder
|
|
121
|
+
};
|
|
122
|
+
//# sourceMappingURL=update.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/singlestore-core/query-builders/update.ts"],"sourcesContent":["import type { GetColumnData } from '~/column.ts';\nimport { entityKind } from '~/entity.ts';\nimport { QueryPromise } from '~/query-promise.ts';\nimport { SelectionProxyHandler } from '~/selection-proxy.ts';\nimport type { SingleStoreDialect } from '~/singlestore-core/dialect.ts';\nimport type {\n\tAnySingleStoreQueryResultHKT,\n\tPreparedQueryHKTBase,\n\tPreparedQueryKind,\n\tSingleStorePreparedQueryConfig,\n\tSingleStoreQueryResultHKT,\n\tSingleStoreQueryResultKind,\n\tSingleStoreSession,\n} from '~/singlestore-core/session.ts';\nimport type { SingleStoreTable } from '~/singlestore-core/table.ts';\nimport type { Placeholder, Query, SQL, SQLWrapper } from '~/sql/sql.ts';\nimport type { Subquery } from '~/subquery.ts';\nimport { Table } from '~/table.ts';\nimport { mapUpdateSet, type UpdateSet, type ValueOrArray } from '~/utils.ts';\nimport type { SingleStoreColumn } from '../columns/common.ts';\nimport type { SelectedFieldsOrdered } from './select.types.ts';\n\nexport interface SingleStoreUpdateConfig {\n\twhere?: SQL | undefined;\n\tlimit?: number | Placeholder;\n\torderBy?: (SingleStoreColumn | SQL | SQL.Aliased)[];\n\tset: UpdateSet;\n\ttable: SingleStoreTable;\n\treturning?: SelectedFieldsOrdered;\n\twithList?: Subquery[];\n}\n\nexport type SingleStoreUpdateSetSource<TTable extends SingleStoreTable> =\n\t& {\n\t\t[Key in keyof TTable['$inferInsert']]?:\n\t\t\t| GetColumnData<TTable['_']['columns'][Key], 'query'>\n\t\t\t| SQL;\n\t}\n\t& {};\n\nexport class SingleStoreUpdateBuilder<\n\tTTable extends SingleStoreTable,\n\tTQueryResult extends SingleStoreQueryResultHKT,\n\tTPreparedQueryHKT extends PreparedQueryHKTBase,\n> {\n\tstatic readonly [entityKind]: string = 'SingleStoreUpdateBuilder';\n\n\tdeclare readonly _: {\n\t\treadonly table: TTable;\n\t};\n\n\tconstructor(\n\t\tprivate table: TTable,\n\t\tprivate session: SingleStoreSession,\n\t\tprivate dialect: SingleStoreDialect,\n\t\tprivate withList?: Subquery[],\n\t) {}\n\n\tset(values: SingleStoreUpdateSetSource<TTable>): SingleStoreUpdateBase<TTable, TQueryResult, TPreparedQueryHKT> {\n\t\treturn new SingleStoreUpdateBase(\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 SingleStoreUpdateWithout<\n\tT extends AnySingleStoreUpdateBase,\n\tTDynamic extends boolean,\n\tK extends keyof T & string,\n> = TDynamic extends true ? T : Omit<\n\tSingleStoreUpdateBase<\n\t\tT['_']['table'],\n\t\tT['_']['queryResult'],\n\t\tT['_']['preparedQueryHKT'],\n\t\tTDynamic,\n\t\tT['_']['excludedMethods'] | K\n\t>,\n\tT['_']['excludedMethods'] | K\n>;\n\nexport type SingleStoreUpdatePrepare<T extends AnySingleStoreUpdateBase> = PreparedQueryKind<\n\tT['_']['preparedQueryHKT'],\n\tSingleStorePreparedQueryConfig & {\n\t\texecute: SingleStoreQueryResultKind<T['_']['queryResult'], never>;\n\t\titerator: never;\n\t},\n\ttrue\n>;\n\nexport type SingleStoreUpdateDynamic<T extends AnySingleStoreUpdateBase> = SingleStoreUpdate<\n\tT['_']['table'],\n\tT['_']['queryResult'],\n\tT['_']['preparedQueryHKT']\n>;\n\nexport type SingleStoreUpdate<\n\tTTable extends SingleStoreTable = SingleStoreTable,\n\tTQueryResult extends SingleStoreQueryResultHKT = AnySingleStoreQueryResultHKT,\n\tTPreparedQueryHKT extends PreparedQueryHKTBase = PreparedQueryHKTBase,\n> = SingleStoreUpdateBase<TTable, TQueryResult, TPreparedQueryHKT, true, never>;\n\nexport type AnySingleStoreUpdateBase = SingleStoreUpdateBase<any, any, any, any, any>;\n\nexport interface SingleStoreUpdateBase<\n\tTTable extends SingleStoreTable,\n\tTQueryResult extends SingleStoreQueryResultHKT,\n\tTPreparedQueryHKT extends PreparedQueryHKTBase,\n\tTDynamic extends boolean = false,\n\tTExcludedMethods extends string = never,\n> extends QueryPromise<SingleStoreQueryResultKind<TQueryResult, never>>, SQLWrapper {\n\treadonly _: {\n\t\treadonly table: TTable;\n\t\treadonly queryResult: TQueryResult;\n\t\treadonly preparedQueryHKT: TPreparedQueryHKT;\n\t\treadonly dynamic: TDynamic;\n\t\treadonly excludedMethods: TExcludedMethods;\n\t};\n}\n\nexport class SingleStoreUpdateBase<\n\tTTable extends SingleStoreTable,\n\tTQueryResult extends SingleStoreQueryResultHKT,\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\tTPreparedQueryHKT extends PreparedQueryHKTBase,\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<SingleStoreQueryResultKind<TQueryResult, never>> implements SQLWrapper {\n\tstatic override readonly [entityKind]: string = 'SingleStoreUpdate';\n\n\tprivate config: SingleStoreUpdateConfig;\n\n\tconstructor(\n\t\ttable: TTable,\n\t\tset: UpdateSet,\n\t\tprivate session: SingleStoreSession,\n\t\tprivate dialect: SingleStoreDialect,\n\t\twithList?: Subquery[],\n\t) {\n\t\tsuper();\n\t\tthis.config = { set, table, withList };\n\t}\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 * db.update(cars).set({ color: 'red' })\n\t * .where(eq(cars.color, 'green'));\n\t * // or\n\t * 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 * 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 * 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): SingleStoreUpdateWithout<this, TDynamic, 'where'> {\n\t\tthis.config.where = where;\n\t\treturn this as any;\n\t}\n\n\torderBy(\n\t\tbuilder: (updateTable: TTable) => ValueOrArray<SingleStoreColumn | SQL | SQL.Aliased>,\n\t): SingleStoreUpdateWithout<this, TDynamic, 'orderBy'>;\n\torderBy(...columns: (SingleStoreColumn | SQL | SQL.Aliased)[]): SingleStoreUpdateWithout<this, TDynamic, 'orderBy'>;\n\torderBy(\n\t\t...columns:\n\t\t\t| [(updateTable: TTable) => ValueOrArray<SingleStoreColumn | SQL | SQL.Aliased>]\n\t\t\t| (SingleStoreColumn | SQL | SQL.Aliased)[]\n\t): SingleStoreUpdateWithout<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.table[Table.Symbol.Columns],\n\t\t\t\t\tnew SelectionProxyHandler({ sqlAliasedBehavior: 'alias', sqlBehavior: 'sql' }),\n\t\t\t\t) as any,\n\t\t\t);\n\n\t\t\tconst orderByArray = Array.isArray(orderBy) ? orderBy : [orderBy];\n\t\t\tthis.config.orderBy = orderByArray;\n\t\t} else {\n\t\t\tconst orderByArray = columns as (SingleStoreColumn | SQL | SQL.Aliased)[];\n\t\t\tthis.config.orderBy = orderByArray;\n\t\t}\n\t\treturn this as any;\n\t}\n\n\tlimit(limit: number | Placeholder): SingleStoreUpdateWithout<this, TDynamic, 'limit'> {\n\t\tthis.config.limit = limit;\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\tprepare(): SingleStoreUpdatePrepare<this> {\n\t\treturn this.session.prepareQuery(\n\t\t\tthis.dialect.sqlToQuery(this.getSQL()),\n\t\t\tthis.config.returning,\n\t\t) as SingleStoreUpdatePrepare<this>;\n\t}\n\n\toverride execute: ReturnType<this['prepare']>['execute'] = (placeholderValues) => {\n\t\treturn this.prepare().execute(placeholderValues);\n\t};\n\n\tprivate createIterator = (): ReturnType<this['prepare']>['iterator'] => {\n\t\tconst self = this;\n\t\treturn async function*(placeholderValues) {\n\t\t\tyield* self.prepare().iterator(placeholderValues);\n\t\t};\n\t};\n\n\titerator = this.createIterator();\n\n\t$dynamic(): SingleStoreUpdateDynamic<this> {\n\t\treturn this as any;\n\t}\n}\n"],"mappings":"AACA,SAAS,kBAAkB;AAC3B,SAAS,oBAAoB;AAC7B,SAAS,6BAA6B;AActC,SAAS,aAAa;AACtB,SAAS,oBAAuD;AAsBzD,MAAM,yBAIX;AAAA,EAOD,YACS,OACA,SACA,SACA,UACP;AAJO;AACA;AACA;AACA;AAAA,EACN;AAAA,EAXH,QAAiB,UAAU,IAAY;AAAA,EAavC,IAAI,QAA4G;AAC/G,WAAO,IAAI;AAAA,MACV,KAAK;AAAA,MACL,aAAa,KAAK,OAAO,MAAM;AAAA,MAC/B,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,IACN;AAAA,EACD;AACD;AAwDO,MAAM,8BASH,aAAoF;AAAA,EAK7F,YACC,OACA,KACQ,SACA,SACR,UACC;AACD,UAAM;AAJE;AACA;AAIR,SAAK,SAAS,EAAE,KAAK,OAAO,SAAS;AAAA,EACtC;AAAA,EAbA,QAA0B,UAAU,IAAY;AAAA,EAExC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA8CR,MAAM,OAA2E;AAChF,SAAK,OAAO,QAAQ;AACpB,WAAO;AAAA,EACR;AAAA,EAMA,WACI,SAGmD;AACtD,QAAI,OAAO,QAAQ,CAAC,MAAM,YAAY;AACrC,YAAM,UAAU,QAAQ,CAAC;AAAA,QACxB,IAAI;AAAA,UACH,KAAK,OAAO,MAAM,MAAM,OAAO,OAAO;AAAA,UACtC,IAAI,sBAAsB,EAAE,oBAAoB,SAAS,aAAa,MAAM,CAAC;AAAA,QAC9E;AAAA,MACD;AAEA,YAAM,eAAe,MAAM,QAAQ,OAAO,IAAI,UAAU,CAAC,OAAO;AAChE,WAAK,OAAO,UAAU;AAAA,IACvB,OAAO;AACN,YAAM,eAAe;AACrB,WAAK,OAAO,UAAU;AAAA,IACvB;AACA,WAAO;AAAA,EACR;AAAA,EAEA,MAAM,OAAgF;AACrF,SAAK,OAAO,QAAQ;AACpB,WAAO;AAAA,EACR;AAAA;AAAA,EAGA,SAAc;AACb,WAAO,KAAK,QAAQ,iBAAiB,KAAK,MAAM;AAAA,EACjD;AAAA,EAEA,QAAe;AACd,UAAM,EAAE,SAAS,UAAU,GAAG,KAAK,IAAI,KAAK,QAAQ,WAAW,KAAK,OAAO,CAAC;AAC5E,WAAO;AAAA,EACR;AAAA,EAEA,UAA0C;AACzC,WAAO,KAAK,QAAQ;AAAA,MACnB,KAAK,QAAQ,WAAW,KAAK,OAAO,CAAC;AAAA,MACrC,KAAK,OAAO;AAAA,IACb;AAAA,EACD;AAAA,EAES,UAAkD,CAAC,sBAAsB;AACjF,WAAO,KAAK,QAAQ,EAAE,QAAQ,iBAAiB;AAAA,EAChD;AAAA,EAEQ,iBAAiB,MAA+C;AACvE,UAAM,OAAO;AACb,WAAO,iBAAgB,mBAAmB;AACzC,aAAO,KAAK,QAAQ,EAAE,SAAS,iBAAiB;AAAA,IACjD;AAAA,EACD;AAAA,EAEA,WAAW,KAAK,eAAe;AAAA,EAE/B,WAA2C;AAC1C,WAAO;AAAA,EACR;AACD;","names":[]}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var schema_exports = {};
|
|
20
|
+
__export(schema_exports, {
|
|
21
|
+
SingleStoreSchema: () => SingleStoreSchema,
|
|
22
|
+
isSingleStoreSchema: () => isSingleStoreSchema,
|
|
23
|
+
singlestoreDatabase: () => singlestoreDatabase,
|
|
24
|
+
singlestoreSchema: () => singlestoreSchema
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(schema_exports);
|
|
27
|
+
var import_entity = require("../entity.cjs");
|
|
28
|
+
var import_table = require("./table.cjs");
|
|
29
|
+
class SingleStoreSchema {
|
|
30
|
+
constructor(schemaName) {
|
|
31
|
+
this.schemaName = schemaName;
|
|
32
|
+
}
|
|
33
|
+
static [import_entity.entityKind] = "SingleStoreSchema";
|
|
34
|
+
table = (name, columns, extraConfig) => {
|
|
35
|
+
return (0, import_table.singlestoreTableWithSchema)(name, columns, extraConfig, this.schemaName);
|
|
36
|
+
};
|
|
37
|
+
/*
|
|
38
|
+
view = ((name, columns) => {
|
|
39
|
+
return singlestoreViewWithSchema(name, columns, this.schemaName);
|
|
40
|
+
}) as typeof singlestoreView; */
|
|
41
|
+
}
|
|
42
|
+
function isSingleStoreSchema(obj) {
|
|
43
|
+
return (0, import_entity.is)(obj, SingleStoreSchema);
|
|
44
|
+
}
|
|
45
|
+
function singlestoreDatabase(name) {
|
|
46
|
+
return new SingleStoreSchema(name);
|
|
47
|
+
}
|
|
48
|
+
const singlestoreSchema = singlestoreDatabase;
|
|
49
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
50
|
+
0 && (module.exports = {
|
|
51
|
+
SingleStoreSchema,
|
|
52
|
+
isSingleStoreSchema,
|
|
53
|
+
singlestoreDatabase,
|
|
54
|
+
singlestoreSchema
|
|
55
|
+
});
|
|
56
|
+
//# sourceMappingURL=schema.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/singlestore-core/schema.ts"],"sourcesContent":["import { entityKind, is } from '~/entity.ts';\nimport { type SingleStoreTableFn, singlestoreTableWithSchema } from './table.ts';\n/* import { type singlestoreView, singlestoreViewWithSchema } from './view.ts'; */\n\nexport class SingleStoreSchema<TName extends string = string> {\n\tstatic readonly [entityKind]: string = 'SingleStoreSchema';\n\n\tconstructor(\n\t\tpublic readonly schemaName: TName,\n\t) {}\n\n\ttable: SingleStoreTableFn<TName> = (name, columns, extraConfig) => {\n\t\treturn singlestoreTableWithSchema(name, columns, extraConfig, this.schemaName);\n\t};\n\t/*\n\tview = ((name, columns) => {\n\t\treturn singlestoreViewWithSchema(name, columns, this.schemaName);\n\t}) as typeof singlestoreView; */\n}\n\n/** @deprecated - use `instanceof SingleStoreSchema` */\nexport function isSingleStoreSchema(obj: unknown): obj is SingleStoreSchema {\n\treturn is(obj, SingleStoreSchema);\n}\n\n/**\n * Create a SingleStore schema.\n * https://docs.singlestore.com/cloud/create-a-database/\n *\n * @param name singlestore use schema name\n * @returns SingleStore schema\n */\nexport function singlestoreDatabase<TName extends string>(name: TName) {\n\treturn new SingleStoreSchema(name);\n}\n\n/**\n * @see singlestoreDatabase\n */\nexport const singlestoreSchema = singlestoreDatabase;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA+B;AAC/B,mBAAoE;AAG7D,MAAM,kBAAiD;AAAA,EAG7D,YACiB,YACf;AADe;AAAA,EACd;AAAA,EAJH,QAAiB,wBAAU,IAAY;AAAA,EAMvC,QAAmC,CAAC,MAAM,SAAS,gBAAgB;AAClE,eAAO,yCAA2B,MAAM,SAAS,aAAa,KAAK,UAAU;AAAA,EAC9E;AAAA;AAAA;AAAA;AAAA;AAKD;AAGO,SAAS,oBAAoB,KAAwC;AAC3E,aAAO,kBAAG,KAAK,iBAAiB;AACjC;AASO,SAAS,oBAA0C,MAAa;AACtE,SAAO,IAAI,kBAAkB,IAAI;AAClC;AAKO,MAAM,oBAAoB;","names":[]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { entityKind } from "../entity.cjs";
|
|
2
|
+
import { type SingleStoreTableFn } from "./table.cjs";
|
|
3
|
+
export declare class SingleStoreSchema<TName extends string = string> {
|
|
4
|
+
readonly schemaName: TName;
|
|
5
|
+
static readonly [entityKind]: string;
|
|
6
|
+
constructor(schemaName: TName);
|
|
7
|
+
table: SingleStoreTableFn<TName>;
|
|
8
|
+
}
|
|
9
|
+
/** @deprecated - use `instanceof SingleStoreSchema` */
|
|
10
|
+
export declare function isSingleStoreSchema(obj: unknown): obj is SingleStoreSchema;
|
|
11
|
+
/**
|
|
12
|
+
* Create a SingleStore schema.
|
|
13
|
+
* https://docs.singlestore.com/cloud/create-a-database/
|
|
14
|
+
*
|
|
15
|
+
* @param name singlestore use schema name
|
|
16
|
+
* @returns SingleStore schema
|
|
17
|
+
*/
|
|
18
|
+
export declare function singlestoreDatabase<TName extends string>(name: TName): SingleStoreSchema<TName>;
|
|
19
|
+
/**
|
|
20
|
+
* @see singlestoreDatabase
|
|
21
|
+
*/
|
|
22
|
+
export declare const singlestoreSchema: typeof singlestoreDatabase;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { entityKind } from "../entity.js";
|
|
2
|
+
import { type SingleStoreTableFn } from "./table.js";
|
|
3
|
+
export declare class SingleStoreSchema<TName extends string = string> {
|
|
4
|
+
readonly schemaName: TName;
|
|
5
|
+
static readonly [entityKind]: string;
|
|
6
|
+
constructor(schemaName: TName);
|
|
7
|
+
table: SingleStoreTableFn<TName>;
|
|
8
|
+
}
|
|
9
|
+
/** @deprecated - use `instanceof SingleStoreSchema` */
|
|
10
|
+
export declare function isSingleStoreSchema(obj: unknown): obj is SingleStoreSchema;
|
|
11
|
+
/**
|
|
12
|
+
* Create a SingleStore schema.
|
|
13
|
+
* https://docs.singlestore.com/cloud/create-a-database/
|
|
14
|
+
*
|
|
15
|
+
* @param name singlestore use schema name
|
|
16
|
+
* @returns SingleStore schema
|
|
17
|
+
*/
|
|
18
|
+
export declare function singlestoreDatabase<TName extends string>(name: TName): SingleStoreSchema<TName>;
|
|
19
|
+
/**
|
|
20
|
+
* @see singlestoreDatabase
|
|
21
|
+
*/
|
|
22
|
+
export declare const singlestoreSchema: typeof singlestoreDatabase;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { entityKind, is } from "../entity.js";
|
|
2
|
+
import { singlestoreTableWithSchema } from "./table.js";
|
|
3
|
+
class SingleStoreSchema {
|
|
4
|
+
constructor(schemaName) {
|
|
5
|
+
this.schemaName = schemaName;
|
|
6
|
+
}
|
|
7
|
+
static [entityKind] = "SingleStoreSchema";
|
|
8
|
+
table = (name, columns, extraConfig) => {
|
|
9
|
+
return singlestoreTableWithSchema(name, columns, extraConfig, this.schemaName);
|
|
10
|
+
};
|
|
11
|
+
/*
|
|
12
|
+
view = ((name, columns) => {
|
|
13
|
+
return singlestoreViewWithSchema(name, columns, this.schemaName);
|
|
14
|
+
}) as typeof singlestoreView; */
|
|
15
|
+
}
|
|
16
|
+
function isSingleStoreSchema(obj) {
|
|
17
|
+
return is(obj, SingleStoreSchema);
|
|
18
|
+
}
|
|
19
|
+
function singlestoreDatabase(name) {
|
|
20
|
+
return new SingleStoreSchema(name);
|
|
21
|
+
}
|
|
22
|
+
const singlestoreSchema = singlestoreDatabase;
|
|
23
|
+
export {
|
|
24
|
+
SingleStoreSchema,
|
|
25
|
+
isSingleStoreSchema,
|
|
26
|
+
singlestoreDatabase,
|
|
27
|
+
singlestoreSchema
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/singlestore-core/schema.ts"],"sourcesContent":["import { entityKind, is } from '~/entity.ts';\nimport { type SingleStoreTableFn, singlestoreTableWithSchema } from './table.ts';\n/* import { type singlestoreView, singlestoreViewWithSchema } from './view.ts'; */\n\nexport class SingleStoreSchema<TName extends string = string> {\n\tstatic readonly [entityKind]: string = 'SingleStoreSchema';\n\n\tconstructor(\n\t\tpublic readonly schemaName: TName,\n\t) {}\n\n\ttable: SingleStoreTableFn<TName> = (name, columns, extraConfig) => {\n\t\treturn singlestoreTableWithSchema(name, columns, extraConfig, this.schemaName);\n\t};\n\t/*\n\tview = ((name, columns) => {\n\t\treturn singlestoreViewWithSchema(name, columns, this.schemaName);\n\t}) as typeof singlestoreView; */\n}\n\n/** @deprecated - use `instanceof SingleStoreSchema` */\nexport function isSingleStoreSchema(obj: unknown): obj is SingleStoreSchema {\n\treturn is(obj, SingleStoreSchema);\n}\n\n/**\n * Create a SingleStore schema.\n * https://docs.singlestore.com/cloud/create-a-database/\n *\n * @param name singlestore use schema name\n * @returns SingleStore schema\n */\nexport function singlestoreDatabase<TName extends string>(name: TName) {\n\treturn new SingleStoreSchema(name);\n}\n\n/**\n * @see singlestoreDatabase\n */\nexport const singlestoreSchema = singlestoreDatabase;\n"],"mappings":"AAAA,SAAS,YAAY,UAAU;AAC/B,SAAkC,kCAAkC;AAG7D,MAAM,kBAAiD;AAAA,EAG7D,YACiB,YACf;AADe;AAAA,EACd;AAAA,EAJH,QAAiB,UAAU,IAAY;AAAA,EAMvC,QAAmC,CAAC,MAAM,SAAS,gBAAgB;AAClE,WAAO,2BAA2B,MAAM,SAAS,aAAa,KAAK,UAAU;AAAA,EAC9E;AAAA;AAAA;AAAA;AAAA;AAKD;AAGO,SAAS,oBAAoB,KAAwC;AAC3E,SAAO,GAAG,KAAK,iBAAiB;AACjC;AASO,SAAS,oBAA0C,MAAa;AACtE,SAAO,IAAI,kBAAkB,IAAI;AAClC;AAKO,MAAM,oBAAoB;","names":[]}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var session_exports = {};
|
|
20
|
+
__export(session_exports, {
|
|
21
|
+
SingleStorePreparedQuery: () => SingleStorePreparedQuery,
|
|
22
|
+
SingleStoreSession: () => SingleStoreSession,
|
|
23
|
+
SingleStoreTransaction: () => SingleStoreTransaction
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(session_exports);
|
|
26
|
+
var import_entity = require("../entity.cjs");
|
|
27
|
+
var import_errors = require("../errors.cjs");
|
|
28
|
+
var import_sql = require("../sql/sql.cjs");
|
|
29
|
+
var import_db = require("./db.cjs");
|
|
30
|
+
class SingleStorePreparedQuery {
|
|
31
|
+
static [import_entity.entityKind] = "SingleStorePreparedQuery";
|
|
32
|
+
/** @internal */
|
|
33
|
+
joinsNotNullableMap;
|
|
34
|
+
}
|
|
35
|
+
class SingleStoreSession {
|
|
36
|
+
constructor(dialect) {
|
|
37
|
+
this.dialect = dialect;
|
|
38
|
+
}
|
|
39
|
+
static [import_entity.entityKind] = "SingleStoreSession";
|
|
40
|
+
execute(query) {
|
|
41
|
+
return this.prepareQuery(
|
|
42
|
+
this.dialect.sqlToQuery(query),
|
|
43
|
+
void 0
|
|
44
|
+
).execute();
|
|
45
|
+
}
|
|
46
|
+
async count(sql2) {
|
|
47
|
+
const res = await this.execute(sql2);
|
|
48
|
+
return Number(
|
|
49
|
+
res[0][0]["count"]
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
getSetTransactionSQL(config) {
|
|
53
|
+
const parts = [];
|
|
54
|
+
if (config.isolationLevel) {
|
|
55
|
+
parts.push(`isolation level ${config.isolationLevel}`);
|
|
56
|
+
}
|
|
57
|
+
return parts.length ? import_sql.sql`set transaction ${import_sql.sql.raw(parts.join(" "))}` : void 0;
|
|
58
|
+
}
|
|
59
|
+
getStartTransactionSQL(config) {
|
|
60
|
+
const parts = [];
|
|
61
|
+
if (config.withConsistentSnapshot) {
|
|
62
|
+
parts.push("with consistent snapshot");
|
|
63
|
+
}
|
|
64
|
+
if (config.accessMode) {
|
|
65
|
+
parts.push(config.accessMode);
|
|
66
|
+
}
|
|
67
|
+
return parts.length ? import_sql.sql`start transaction ${import_sql.sql.raw(parts.join(" "))}` : void 0;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
class SingleStoreTransaction extends import_db.SingleStoreDatabase {
|
|
71
|
+
constructor(dialect, session, schema, nestedIndex) {
|
|
72
|
+
super(dialect, session, schema);
|
|
73
|
+
this.schema = schema;
|
|
74
|
+
this.nestedIndex = nestedIndex;
|
|
75
|
+
}
|
|
76
|
+
static [import_entity.entityKind] = "SingleStoreTransaction";
|
|
77
|
+
rollback() {
|
|
78
|
+
throw new import_errors.TransactionRollbackError();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
82
|
+
0 && (module.exports = {
|
|
83
|
+
SingleStorePreparedQuery,
|
|
84
|
+
SingleStoreSession,
|
|
85
|
+
SingleStoreTransaction
|
|
86
|
+
});
|
|
87
|
+
//# sourceMappingURL=session.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/singlestore-core/session.ts"],"sourcesContent":["import { entityKind } from '~/entity.ts';\nimport { TransactionRollbackError } from '~/errors.ts';\nimport type { RelationalSchemaConfig, TablesRelationalConfig } from '~/relations.ts';\nimport { type Query, type SQL, sql } from '~/sql/sql.ts';\nimport type { Assume, Equal } from '~/utils.ts';\nimport { SingleStoreDatabase } from './db.ts';\nimport type { SingleStoreDialect } from './dialect.ts';\nimport type { SelectedFieldsOrdered } from './query-builders/select.types.ts';\n\nexport interface SingleStoreQueryResultHKT {\n\treadonly $brand: 'SingleStoreQueryResultHKT';\n\treadonly row: unknown;\n\treadonly type: unknown;\n}\n\nexport interface AnySingleStoreQueryResultHKT extends SingleStoreQueryResultHKT {\n\treadonly type: any;\n}\n\nexport type SingleStoreQueryResultKind<TKind extends SingleStoreQueryResultHKT, TRow> = (TKind & {\n\treadonly row: TRow;\n})['type'];\n\nexport interface SingleStorePreparedQueryConfig {\n\texecute: unknown;\n\titerator: unknown;\n}\n\nexport interface SingleStorePreparedQueryHKT {\n\treadonly $brand: 'SingleStorePreparedQueryHKT';\n\treadonly config: unknown;\n\treadonly type: unknown;\n}\n\nexport type PreparedQueryKind<\n\tTKind extends SingleStorePreparedQueryHKT,\n\tTConfig extends SingleStorePreparedQueryConfig,\n\tTAssume extends boolean = false,\n> = Equal<TAssume, true> extends true\n\t? Assume<(TKind & { readonly config: TConfig })['type'], SingleStorePreparedQuery<TConfig>>\n\t: (TKind & { readonly config: TConfig })['type'];\n\nexport abstract class SingleStorePreparedQuery<T extends SingleStorePreparedQueryConfig> {\n\tstatic readonly [entityKind]: string = 'SingleStorePreparedQuery';\n\n\t/** @internal */\n\tjoinsNotNullableMap?: Record<string, boolean>;\n\n\tabstract execute(placeholderValues?: Record<string, unknown>): Promise<T['execute']>;\n\n\tabstract iterator(placeholderValues?: Record<string, unknown>): AsyncGenerator<T['iterator']>;\n}\n\nexport interface SingleStoreTransactionConfig {\n\twithConsistentSnapshot?: boolean;\n\taccessMode?: 'read only' | 'read write';\n\tisolationLevel: 'read committed'; // SingleStore only supports read committed isolation level (https://docs.singlestore.com/db/v8.7/introduction/faqs/durability/)\n}\n\nexport abstract class SingleStoreSession<\n\tTQueryResult extends SingleStoreQueryResultHKT = SingleStoreQueryResultHKT,\n\tTPreparedQueryHKT extends PreparedQueryHKTBase = PreparedQueryHKTBase,\n\tTFullSchema extends Record<string, unknown> = Record<string, never>,\n\tTSchema extends TablesRelationalConfig = Record<string, never>,\n> {\n\tstatic readonly [entityKind]: string = 'SingleStoreSession';\n\n\tconstructor(protected dialect: SingleStoreDialect) {}\n\n\tabstract prepareQuery<\n\t\tT extends SingleStorePreparedQueryConfig,\n\t\tTPreparedQueryHKT extends SingleStorePreparedQueryHKT,\n\t>(\n\t\tquery: Query,\n\t\tfields: SelectedFieldsOrdered | undefined,\n\t\tcustomResultMapper?: (rows: unknown[][]) => T['execute'],\n\t\tgeneratedIds?: Record<string, unknown>[],\n\t\treturningIds?: SelectedFieldsOrdered,\n\t): PreparedQueryKind<TPreparedQueryHKT, T>;\n\n\texecute<T>(query: SQL): Promise<T> {\n\t\treturn this.prepareQuery<SingleStorePreparedQueryConfig & { execute: T }, PreparedQueryHKTBase>(\n\t\t\tthis.dialect.sqlToQuery(query),\n\t\t\tundefined,\n\t\t).execute();\n\t}\n\n\tabstract all<T = unknown>(query: SQL): Promise<T[]>;\n\n\tasync count(sql: SQL): Promise<number> {\n\t\tconst res = await this.execute<[[{ count: string }]]>(sql);\n\n\t\treturn Number(\n\t\t\tres[0][0]['count'],\n\t\t);\n\t}\n\n\tabstract transaction<T>(\n\t\ttransaction: (tx: SingleStoreTransaction<TQueryResult, TPreparedQueryHKT, TFullSchema, TSchema>) => Promise<T>,\n\t\tconfig?: SingleStoreTransactionConfig,\n\t): Promise<T>;\n\n\tprotected getSetTransactionSQL(config: SingleStoreTransactionConfig): SQL | undefined {\n\t\tconst parts: string[] = [];\n\n\t\tif (config.isolationLevel) {\n\t\t\tparts.push(`isolation level ${config.isolationLevel}`);\n\t\t}\n\n\t\treturn parts.length ? sql`set transaction ${sql.raw(parts.join(' '))}` : undefined;\n\t}\n\n\tprotected getStartTransactionSQL(config: SingleStoreTransactionConfig): SQL | undefined {\n\t\tconst parts: string[] = [];\n\n\t\tif (config.withConsistentSnapshot) {\n\t\t\tparts.push('with consistent snapshot');\n\t\t}\n\n\t\tif (config.accessMode) {\n\t\t\tparts.push(config.accessMode);\n\t\t}\n\n\t\treturn parts.length ? sql`start transaction ${sql.raw(parts.join(' '))}` : undefined;\n\t}\n}\n\nexport abstract class SingleStoreTransaction<\n\tTQueryResult extends SingleStoreQueryResultHKT,\n\tTPreparedQueryHKT extends PreparedQueryHKTBase,\n\tTFullSchema extends Record<string, unknown> = Record<string, never>,\n\tTSchema extends TablesRelationalConfig = Record<string, never>,\n> extends SingleStoreDatabase<TQueryResult, TPreparedQueryHKT, TFullSchema, TSchema> {\n\tstatic override readonly [entityKind]: string = 'SingleStoreTransaction';\n\n\tconstructor(\n\t\tdialect: SingleStoreDialect,\n\t\tsession: SingleStoreSession,\n\t\tprotected schema: RelationalSchemaConfig<TSchema> | undefined,\n\t\tprotected readonly nestedIndex: number,\n\t) {\n\t\tsuper(dialect, session, schema);\n\t}\n\n\trollback(): never {\n\t\tthrow new TransactionRollbackError();\n\t}\n\n\t/** Nested transactions (aka savepoints) only work with InnoDB engine. */\n\tabstract override transaction<T>(\n\t\ttransaction: (tx: SingleStoreTransaction<TQueryResult, TPreparedQueryHKT, TFullSchema, TSchema>) => Promise<T>,\n\t): Promise<T>;\n}\n\nexport interface PreparedQueryHKTBase extends SingleStorePreparedQueryHKT {\n\ttype: SingleStorePreparedQuery<Assume<this['config'], SingleStorePreparedQueryConfig>>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA2B;AAC3B,oBAAyC;AAEzC,iBAA0C;AAE1C,gBAAoC;AAqC7B,MAAe,yBAAmE;AAAA,EACxF,QAAiB,wBAAU,IAAY;AAAA;AAAA,EAGvC;AAKD;AAQO,MAAe,mBAKpB;AAAA,EAGD,YAAsB,SAA6B;AAA7B;AAAA,EAA8B;AAAA,EAFpD,QAAiB,wBAAU,IAAY;AAAA,EAevC,QAAW,OAAwB;AAClC,WAAO,KAAK;AAAA,MACX,KAAK,QAAQ,WAAW,KAAK;AAAA,MAC7B;AAAA,IACD,EAAE,QAAQ;AAAA,EACX;AAAA,EAIA,MAAM,MAAMA,MAA2B;AACtC,UAAM,MAAM,MAAM,KAAK,QAA+BA,IAAG;AAEzD,WAAO;AAAA,MACN,IAAI,CAAC,EAAE,CAAC,EAAE,OAAO;AAAA,IAClB;AAAA,EACD;AAAA,EAOU,qBAAqB,QAAuD;AACrF,UAAM,QAAkB,CAAC;AAEzB,QAAI,OAAO,gBAAgB;AAC1B,YAAM,KAAK,mBAAmB,OAAO,cAAc,EAAE;AAAA,IACtD;AAEA,WAAO,MAAM,SAAS,iCAAsB,eAAI,IAAI,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK;AAAA,EAC1E;AAAA,EAEU,uBAAuB,QAAuD;AACvF,UAAM,QAAkB,CAAC;AAEzB,QAAI,OAAO,wBAAwB;AAClC,YAAM,KAAK,0BAA0B;AAAA,IACtC;AAEA,QAAI,OAAO,YAAY;AACtB,YAAM,KAAK,OAAO,UAAU;AAAA,IAC7B;AAEA,WAAO,MAAM,SAAS,mCAAwB,eAAI,IAAI,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK;AAAA,EAC5E;AACD;AAEO,MAAe,+BAKZ,8BAA2E;AAAA,EAGpF,YACC,SACA,SACU,QACS,aAClB;AACD,UAAM,SAAS,SAAS,MAAM;AAHpB;AACS;AAAA,EAGpB;AAAA,EATA,QAA0B,wBAAU,IAAY;AAAA,EAWhD,WAAkB;AACjB,UAAM,IAAI,uCAAyB;AAAA,EACpC;AAMD;","names":["sql"]}
|