turbine-orm 0.93.1 → 0.94.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +49 -23
- package/dist/adapters/cockroachdb.d.ts +3 -3
- package/dist/adapters/cockroachdb.js +7 -11
- package/dist/adapters/index.d.ts +1 -1
- package/dist/adapters/yugabytedb.js +1 -1
- package/dist/better-sqlite3.d.ts +132 -0
- package/dist/better-sqlite3.js +303 -0
- package/dist/catalog-metadata.d.ts +250 -0
- package/dist/catalog-metadata.js +730 -0
- package/dist/cjs/adapters/cockroachdb.d.ts +3 -3
- package/dist/cjs/adapters/cockroachdb.js +7 -11
- package/dist/cjs/adapters/index.d.ts +1 -1
- package/dist/cjs/adapters/yugabytedb.js +1 -1
- package/dist/cjs/better-sqlite3.d.ts +132 -0
- package/dist/cjs/better-sqlite3.js +311 -0
- package/dist/cjs/catalog-metadata.d.ts +250 -0
- package/dist/cjs/catalog-metadata.js +747 -0
- package/dist/cjs/cli/compile-query.d.ts +6 -3
- package/dist/cjs/cli/compile-query.js +24 -3
- package/dist/cjs/cli/config.d.ts +35 -10
- package/dist/cjs/cli/config.js +173 -42
- package/dist/cjs/cli/d1-config.d.ts +14 -0
- package/dist/cjs/cli/d1-config.js +9 -0
- package/dist/cjs/cli/d1-local.d.ts +31 -0
- package/dist/cjs/cli/d1-local.js +298 -0
- package/dist/cjs/cli/d1-migrations.d.ts +16 -0
- package/dist/cjs/cli/d1-migrations.js +156 -0
- package/dist/cjs/cli/d1-project.d.ts +23 -0
- package/dist/cjs/cli/d1-project.js +314 -0
- package/dist/cjs/cli/d1-seed.d.ts +35 -0
- package/dist/cjs/cli/d1-seed.js +220 -0
- package/dist/cjs/cli/destructive.js +1 -2
- package/dist/cjs/cli/error-catalog.d.ts +3 -3
- package/dist/cjs/cli/error-catalog.js +21 -3
- package/dist/cjs/cli/index.d.ts +13 -8
- package/dist/cjs/cli/index.js +503 -71
- package/dist/cjs/cli/libsql-migrate-command.d.ts +5 -0
- package/dist/cjs/cli/libsql-migrate-command.js +82 -0
- package/dist/cjs/cli/libsql-migrate-status.d.ts +33 -0
- package/dist/cjs/cli/libsql-migrate-status.js +189 -0
- package/dist/cjs/cli/libsql-migrate.d.ts +14 -0
- package/dist/cjs/cli/libsql-migrate.js +522 -0
- package/dist/cjs/cli/libsql-project-config.d.ts +11 -0
- package/dist/cjs/cli/libsql-project-config.js +59 -0
- package/dist/cjs/cli/libsql-project.d.ts +52 -0
- package/dist/cjs/cli/libsql-project.js +409 -0
- package/dist/cjs/cli/libsql-seed-command.d.ts +29 -0
- package/dist/cjs/cli/libsql-seed-command.js +93 -0
- package/dist/cjs/cli/loader.d.ts +6 -5
- package/dist/cjs/cli/loader.js +53 -9
- package/dist/cjs/cli/mcp.d.ts +16 -1
- package/dist/cjs/cli/mcp.js +219 -125
- package/dist/cjs/cli/migrate.d.ts +2 -2
- package/dist/cjs/cli/migrate.js +29 -14
- package/dist/cjs/cli/mssql-doctor.d.ts +44 -0
- package/dist/cjs/cli/mssql-doctor.js +277 -0
- package/dist/cjs/cli/mssql-migrate-command.d.ts +9 -0
- package/dist/cjs/cli/mssql-migrate-command.js +230 -0
- package/dist/cjs/cli/mssql-migrate-connection.d.ts +51 -0
- package/dist/cjs/cli/mssql-migrate-connection.js +255 -0
- package/dist/cjs/cli/mssql-migrate-sql.d.ts +12 -0
- package/dist/cjs/cli/mssql-migrate-sql.js +282 -0
- package/dist/cjs/cli/mssql-migrate.d.ts +45 -0
- package/dist/cjs/cli/mssql-migrate.js +296 -0
- package/dist/cjs/cli/mssql-project.d.ts +34 -0
- package/dist/cjs/cli/mssql-project.js +171 -0
- package/dist/cjs/cli/mssql-seed.d.ts +7 -0
- package/dist/cjs/cli/mssql-seed.js +78 -0
- package/dist/cjs/cli/mssql-tools.d.ts +37 -0
- package/dist/cjs/cli/mssql-tools.js +354 -0
- package/dist/cjs/cli/mysql-doctor.d.ts +48 -0
- package/dist/cjs/cli/mysql-doctor.js +323 -0
- package/dist/cjs/cli/mysql-migrate-command.d.ts +7 -0
- package/dist/cjs/cli/mysql-migrate-command.js +290 -0
- package/dist/cjs/cli/mysql-migrate-sql.d.ts +18 -0
- package/dist/cjs/cli/mysql-migrate-sql.js +166 -0
- package/dist/cjs/cli/mysql-migrate.d.ts +77 -0
- package/dist/cjs/cli/mysql-migrate.js +619 -0
- package/dist/cjs/cli/mysql-project.d.ts +49 -0
- package/dist/cjs/cli/mysql-project.js +284 -0
- package/dist/cjs/cli/mysql-push-command.d.ts +7 -0
- package/dist/cjs/cli/mysql-push-command.js +94 -0
- package/dist/cjs/cli/mysql-push.d.ts +15 -0
- package/dist/cjs/cli/mysql-push.js +98 -0
- package/dist/cjs/cli/mysql-schema-command.d.ts +5 -0
- package/dist/cjs/cli/mysql-schema-command.js +58 -0
- package/dist/cjs/cli/mysql-schema-ddl.d.ts +37 -0
- package/dist/cjs/cli/mysql-schema-ddl.js +234 -0
- package/dist/cjs/cli/mysql-schema-snapshot.d.ts +21 -0
- package/dist/cjs/cli/mysql-schema-snapshot.js +127 -0
- package/dist/cjs/cli/mysql-schema.d.ts +27 -0
- package/dist/cjs/cli/mysql-schema.js +206 -0
- package/dist/cjs/cli/mysql-seed-loader.cjs +58 -0
- package/dist/cjs/cli/mysql-seed-loader.d.cts +3 -0
- package/dist/cjs/cli/mysql-seed.d.ts +6 -0
- package/dist/cjs/cli/mysql-seed.js +83 -0
- package/dist/cjs/cli/mysql-tools.d.ts +44 -0
- package/dist/cjs/cli/mysql-tools.js +336 -0
- package/dist/cjs/cli/no-follow.d.ts +29 -0
- package/dist/cjs/cli/no-follow.js +73 -0
- package/dist/cjs/cli/pii-predicate-guard.d.ts +1 -1
- package/dist/cjs/cli/pii-predicate-guard.js +2 -2
- package/dist/cjs/cli/pii-tags.d.ts +2 -2
- package/dist/cjs/cli/pii-tags.js +1 -1
- package/dist/cjs/cli/prisma-schema.js +2 -2
- package/dist/cjs/cli/sql-statements.d.ts +1 -1
- package/dist/cjs/cli/sql-statements.js +1 -1
- package/dist/cjs/cli/sqlite-doctor.d.ts +35 -0
- package/dist/cjs/cli/sqlite-doctor.js +400 -0
- package/dist/cjs/cli/sqlite-migrate-command.d.ts +4 -0
- package/dist/cjs/cli/sqlite-migrate-command.js +175 -0
- package/dist/cjs/cli/sqlite-migrate.d.ts +61 -0
- package/dist/cjs/cli/sqlite-migrate.js +692 -0
- package/dist/cjs/cli/sqlite-project.d.ts +42 -0
- package/dist/cjs/cli/sqlite-project.js +254 -0
- package/dist/cjs/cli/sqlite-schema-command.d.ts +4 -0
- package/dist/cjs/cli/sqlite-schema-command.js +82 -0
- package/dist/cjs/cli/sqlite-schema-ddl.d.ts +25 -0
- package/dist/cjs/cli/sqlite-schema-ddl.js +252 -0
- package/dist/cjs/cli/sqlite-schema.d.ts +25 -0
- package/dist/cjs/cli/sqlite-schema.js +334 -0
- package/dist/cjs/cli/sqlite-seed.d.ts +4 -0
- package/dist/cjs/cli/sqlite-seed.js +94 -0
- package/dist/cjs/cli/sqlite-tools.d.ts +24 -0
- package/dist/cjs/cli/sqlite-tools.js +169 -0
- package/dist/cjs/cli/studio.js +9 -9
- package/dist/cjs/cli/tool-capabilities.d.ts +72 -0
- package/dist/cjs/cli/tool-capabilities.js +120 -0
- package/dist/cjs/cli/tool-command.d.ts +11 -0
- package/dist/cjs/cli/tool-command.js +49 -0
- package/dist/cjs/cli/ui.d.ts +1 -1
- package/dist/cjs/cli/ui.js +1 -1
- package/dist/cjs/client.d.ts +20 -20
- package/dist/cjs/client.js +65 -344
- package/dist/cjs/connection-url.d.ts +1 -1
- package/dist/cjs/connection-url.js +1 -1
- package/dist/cjs/core.d.ts +58 -0
- package/dist/cjs/core.js +225 -0
- package/dist/cjs/d1/catalog-metadata.d.ts +5 -0
- package/dist/cjs/d1/catalog-metadata.js +230 -0
- package/dist/cjs/d1/catalog.d.ts +15 -0
- package/dist/cjs/d1/catalog.js +88 -0
- package/dist/cjs/d1/generate.d.ts +8 -0
- package/dist/cjs/d1/generate.js +163 -0
- package/dist/cjs/d1/introspect.d.ts +21 -0
- package/dist/cjs/d1/introspect.js +74 -0
- package/dist/cjs/d1/migrate.d.ts +29 -0
- package/dist/cjs/d1/migrate.js +222 -0
- package/dist/cjs/d1/migrations/sql.d.ts +2 -0
- package/dist/cjs/d1/migrations/sql.js +109 -0
- package/dist/cjs/d1/pool.d.ts +14 -0
- package/dist/cjs/d1/pool.js +90 -0
- package/dist/cjs/d1/sql.d.ts +5 -0
- package/dist/cjs/d1/sql.js +140 -0
- package/dist/cjs/d1/sqlite-dialect.d.ts +16 -0
- package/dist/cjs/d1/sqlite-dialect.js +579 -0
- package/dist/cjs/d1/types.d.ts +29 -0
- package/dist/cjs/d1/types.js +2 -0
- package/dist/cjs/d1.d.ts +53 -0
- package/dist/cjs/d1.js +220 -0
- package/dist/cjs/dialect.d.ts +33 -5
- package/dist/cjs/dialect.js +8 -6
- package/dist/cjs/errors.d.ts +38 -1
- package/dist/cjs/errors.js +72 -18
- package/dist/cjs/generate.d.ts +19 -3
- package/dist/cjs/generate.js +330 -97
- package/dist/cjs/global-filters-config.js +4 -4
- package/dist/cjs/index-advisor.js +6 -6
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.js +3 -2
- package/dist/cjs/introspect.d.ts +59 -356
- package/dist/cjs/introspect.js +158 -984
- package/dist/cjs/libsql/bindings.d.ts +2 -0
- package/dist/cjs/libsql/bindings.js +78 -0
- package/dist/cjs/libsql/dialect.d.ts +3 -0
- package/dist/cjs/libsql/dialect.js +48 -0
- package/dist/cjs/libsql/generate.d.ts +4 -0
- package/dist/cjs/libsql/generate.js +56 -0
- package/dist/cjs/libsql/introspect.d.ts +16 -0
- package/dist/cjs/libsql/introspect.js +295 -0
- package/dist/cjs/libsql/pool.d.ts +42 -0
- package/dist/cjs/libsql/pool.js +275 -0
- package/dist/cjs/libsql/seed-cleanup.d.ts +2 -0
- package/dist/cjs/libsql/seed-cleanup.js +19 -0
- package/dist/cjs/libsql/values.d.ts +20 -0
- package/dist/cjs/libsql/values.js +75 -0
- package/dist/cjs/libsql-seed.d.ts +19 -0
- package/dist/cjs/libsql-seed.js +50 -0
- package/dist/cjs/libsql.d.ts +28 -0
- package/dist/cjs/libsql.js +88 -0
- package/dist/cjs/live-query.d.ts +33 -0
- package/dist/cjs/live-query.js +172 -0
- package/dist/cjs/log-codes.d.ts +1 -1
- package/dist/cjs/log-codes.js +4 -0
- package/dist/cjs/mssql-seed.d.ts +27 -0
- package/dist/cjs/mssql-seed.js +118 -0
- package/dist/cjs/mssql.d.ts +7 -7
- package/dist/cjs/mssql.js +365 -53
- package/dist/cjs/mysql-seed.d.ts +25 -0
- package/dist/cjs/mysql-seed.js +169 -0
- package/dist/cjs/mysql.d.ts +18 -6
- package/dist/cjs/mysql.js +602 -94
- package/dist/cjs/neon-http/client.d.ts +95 -0
- package/dist/cjs/neon-http/client.js +291 -0
- package/dist/cjs/neon-http/sql.d.ts +3 -0
- package/dist/cjs/neon-http/sql.js +116 -0
- package/dist/cjs/neon-http.d.ts +5 -0
- package/dist/cjs/neon-http.js +8 -0
- package/dist/cjs/neon-ws/load-driver.cjs +44 -0
- package/dist/cjs/neon-ws/load-driver.d.cts +9 -0
- package/dist/cjs/neon-ws/recovery.d.ts +14 -0
- package/dist/cjs/neon-ws/recovery.js +69 -0
- package/dist/cjs/neon-ws/snapshot.d.ts +3 -0
- package/dist/cjs/neon-ws/snapshot.js +17 -0
- package/dist/cjs/neon-ws/transport.d.ts +112 -0
- package/dist/cjs/neon-ws/transport.js +290 -0
- package/dist/cjs/neon-ws.d.ts +26 -0
- package/dist/cjs/neon-ws.js +189 -0
- package/dist/cjs/nested-write.d.ts +34 -3
- package/dist/cjs/nested-write.js +117 -24
- package/dist/cjs/notification-hub/consumer.d.ts +22 -0
- package/dist/cjs/notification-hub/consumer.js +111 -0
- package/dist/cjs/notification-hub.d.ts +41 -0
- package/dist/cjs/notification-hub.js +373 -0
- package/dist/cjs/pg-catalog-text.d.ts +96 -0
- package/dist/cjs/pg-catalog-text.js +213 -0
- package/dist/cjs/pg-types.d.ts +46 -2
- package/dist/cjs/pipeline-submittable.d.ts +15 -5
- package/dist/cjs/pipeline-submittable.js +103 -48
- package/dist/cjs/pipeline.d.ts +5 -2
- package/dist/cjs/pipeline.js +111 -41
- package/dist/cjs/plan-divergence.d.ts +1 -1
- package/dist/cjs/plan-divergence.js +1 -1
- package/dist/cjs/powdb-introspect.d.ts +1 -1
- package/dist/cjs/powdb-introspect.js +5 -5
- package/dist/cjs/powdb-shared.d.ts +5 -5
- package/dist/cjs/powdb-shared.js +6 -5
- package/dist/cjs/powdb.d.ts +28 -10
- package/dist/cjs/powdb.js +80 -28
- package/dist/cjs/powql.d.ts +50 -28
- package/dist/cjs/powql.js +47 -33
- package/dist/cjs/prisma-compat.js +4 -5
- package/dist/cjs/prisma-schema-fingerprint.d.ts +1 -1
- package/dist/cjs/prisma-schema-fingerprint.js +1 -1
- package/dist/cjs/query/aggregates.d.ts +0 -13
- package/dist/cjs/query/aggregates.js +105 -238
- package/dist/cjs/query/batched-loader.d.ts +1 -1
- package/dist/cjs/query/batched-loader.js +18 -20
- package/dist/cjs/query/builder.d.ts +108 -144
- package/dist/cjs/query/builder.js +592 -893
- package/dist/cjs/query/compound-unique.d.ts +18 -3
- package/dist/cjs/query/compound-unique.js +110 -43
- package/dist/cjs/query/cursor-tuple.d.ts +17 -0
- package/dist/cjs/query/cursor-tuple.js +121 -0
- package/dist/cjs/query/expr.d.ts +2 -0
- package/dist/cjs/query/expr.js +40 -23
- package/dist/cjs/query/filters.d.ts +39 -7
- package/dist/cjs/query/filters.js +77 -19
- package/dist/cjs/query/normalize-args.d.ts +1 -1
- package/dist/cjs/query/normalize-args.js +7 -5
- package/dist/cjs/query/option-surface.d.ts +1 -1
- package/dist/cjs/query/option-surface.js +5 -3
- package/dist/cjs/query/pg-type-parsers.d.ts +126 -0
- package/dist/cjs/query/pg-type-parsers.js +306 -0
- package/dist/cjs/query/relation-names.d.ts +4 -2
- package/dist/cjs/query/relation-names.js +21 -12
- package/dist/cjs/query/relations.d.ts +19 -7
- package/dist/cjs/query/relations.js +329 -260
- package/dist/cjs/query/row-lock.js +3 -3
- package/dist/cjs/query/sql-comment.js +3 -3
- package/dist/cjs/query/stream-idle.d.ts +11 -1
- package/dist/cjs/query/stream-idle.js +53 -13
- package/dist/cjs/query/stream-signal.d.ts +21 -0
- package/dist/cjs/query/stream-signal.js +132 -0
- package/dist/cjs/query/temporal-parsers.d.ts +101 -0
- package/dist/cjs/query/temporal-parsers.js +362 -0
- package/dist/cjs/query/types.d.ts +67 -20
- package/dist/cjs/query/utils.d.ts +2 -878
- package/dist/cjs/query/utils.js +25 -2058
- package/dist/cjs/query/warn-registry.d.ts +1 -1
- package/dist/cjs/query/warn-registry.js +1 -1
- package/dist/cjs/query/where-compile.d.ts +4 -1
- package/dist/cjs/query/where-compile.js +18 -14
- package/dist/cjs/query/where.d.ts +14 -7
- package/dist/cjs/query/where.js +244 -436
- package/dist/cjs/query/writes.d.ts +33 -2
- package/dist/cjs/query/writes.js +104 -77
- package/dist/cjs/query-utils.d.ts +687 -0
- package/dist/cjs/query-utils.js +1444 -0
- package/dist/cjs/realtime.d.ts +1 -1
- package/dist/cjs/realtime.js +3 -3
- package/dist/cjs/schema-builder.js +2 -2
- package/dist/cjs/schema-metadata.d.ts +13 -3
- package/dist/cjs/schema-metadata.js +33 -5
- package/dist/cjs/schema-sql.d.ts +15 -24
- package/dist/cjs/schema-sql.js +53 -63
- package/dist/cjs/schema.d.ts +37 -2
- package/dist/cjs/schema.js +29 -2
- package/dist/cjs/seed.js +5 -5
- package/dist/cjs/serverless.d.ts +24 -71
- package/dist/cjs/serverless.js +24 -71
- package/dist/cjs/sql.d.ts +111 -0
- package/dist/cjs/sql.js +335 -0
- package/dist/cjs/sqlite-seed.d.ts +17 -0
- package/dist/cjs/sqlite-seed.js +31 -0
- package/dist/cjs/sqlite.d.ts +32 -19
- package/dist/cjs/sqlite.js +865 -652
- package/dist/cjs/supplied-pool-types.js +10 -9
- package/dist/cjs/transaction-control.js +6 -1
- package/dist/cjs/transaction-outcome.d.ts +61 -0
- package/dist/cjs/transaction-outcome.js +239 -0
- package/dist/cjs/transaction-state.d.ts +82 -13
- package/dist/cjs/transaction-state.js +222 -56
- package/dist/cjs/transaction-transport.d.ts +38 -0
- package/dist/cjs/transaction-transport.js +157 -0
- package/dist/cjs/typed-sql.d.ts +1 -1
- package/dist/cjs/typed-sql.js +1 -1
- package/dist/cli/compile-query.d.ts +6 -3
- package/dist/cli/compile-query.js +25 -4
- package/dist/cli/config.d.ts +35 -10
- package/dist/cli/config.js +170 -43
- package/dist/cli/d1-config.d.ts +14 -0
- package/dist/cli/d1-config.js +6 -0
- package/dist/cli/d1-local.d.ts +31 -0
- package/dist/cli/d1-local.js +285 -0
- package/dist/cli/d1-migrations.d.ts +16 -0
- package/dist/cli/d1-migrations.js +151 -0
- package/dist/cli/d1-project.d.ts +23 -0
- package/dist/cli/d1-project.js +304 -0
- package/dist/cli/d1-seed.d.ts +35 -0
- package/dist/cli/d1-seed.js +213 -0
- package/dist/cli/destructive.js +1 -2
- package/dist/cli/error-catalog.d.ts +3 -3
- package/dist/cli/error-catalog.js +21 -3
- package/dist/cli/index.d.ts +13 -8
- package/dist/cli/index.js +500 -71
- package/dist/cli/libsql-migrate-command.d.ts +5 -0
- package/dist/cli/libsql-migrate-command.js +77 -0
- package/dist/cli/libsql-migrate-status.d.ts +33 -0
- package/dist/cli/libsql-migrate-status.js +182 -0
- package/dist/cli/libsql-migrate.d.ts +14 -0
- package/dist/cli/libsql-migrate.js +516 -0
- package/dist/cli/libsql-project-config.d.ts +11 -0
- package/dist/cli/libsql-project-config.js +55 -0
- package/dist/cli/libsql-project.d.ts +52 -0
- package/dist/cli/libsql-project.js +391 -0
- package/dist/cli/libsql-seed-command.d.ts +29 -0
- package/dist/cli/libsql-seed-command.js +85 -0
- package/dist/cli/loader.d.ts +6 -5
- package/dist/cli/loader.js +50 -9
- package/dist/cli/mcp.d.ts +16 -1
- package/dist/cli/mcp.js +220 -127
- package/dist/cli/migrate.d.ts +2 -2
- package/dist/cli/migrate.js +29 -14
- package/dist/cli/mssql-doctor.d.ts +44 -0
- package/dist/cli/mssql-doctor.js +237 -0
- package/dist/cli/mssql-migrate-command.d.ts +9 -0
- package/dist/cli/mssql-migrate-command.js +192 -0
- package/dist/cli/mssql-migrate-connection.d.ts +51 -0
- package/dist/cli/mssql-migrate-connection.js +245 -0
- package/dist/cli/mssql-migrate-sql.d.ts +12 -0
- package/dist/cli/mssql-migrate-sql.js +275 -0
- package/dist/cli/mssql-migrate.d.ts +45 -0
- package/dist/cli/mssql-migrate.js +290 -0
- package/dist/cli/mssql-project.d.ts +34 -0
- package/dist/cli/mssql-project.js +160 -0
- package/dist/cli/mssql-seed.d.ts +7 -0
- package/dist/cli/mssql-seed.js +73 -0
- package/dist/cli/mssql-tools.d.ts +37 -0
- package/dist/cli/mssql-tools.js +341 -0
- package/dist/cli/mysql-doctor.d.ts +48 -0
- package/dist/cli/mysql-doctor.js +316 -0
- package/dist/cli/mysql-migrate-command.d.ts +7 -0
- package/dist/cli/mysql-migrate-command.js +285 -0
- package/dist/cli/mysql-migrate-sql.d.ts +18 -0
- package/dist/cli/mysql-migrate-sql.js +162 -0
- package/dist/cli/mysql-migrate.d.ts +77 -0
- package/dist/cli/mysql-migrate.js +606 -0
- package/dist/cli/mysql-project.d.ts +49 -0
- package/dist/cli/mysql-project.js +272 -0
- package/dist/cli/mysql-push-command.d.ts +7 -0
- package/dist/cli/mysql-push-command.js +89 -0
- package/dist/cli/mysql-push.d.ts +15 -0
- package/dist/cli/mysql-push.js +95 -0
- package/dist/cli/mysql-schema-command.d.ts +5 -0
- package/dist/cli/mysql-schema-command.js +54 -0
- package/dist/cli/mysql-schema-ddl.d.ts +37 -0
- package/dist/cli/mysql-schema-ddl.js +227 -0
- package/dist/cli/mysql-schema-snapshot.d.ts +21 -0
- package/dist/cli/mysql-schema-snapshot.js +119 -0
- package/dist/cli/mysql-schema.d.ts +27 -0
- package/dist/cli/mysql-schema.js +200 -0
- package/dist/cli/mysql-seed-loader.cjs +25 -0
- package/dist/cli/mysql-seed-loader.d.cts +3 -0
- package/dist/cli/mysql-seed.d.ts +6 -0
- package/dist/cli/mysql-seed.js +75 -0
- package/dist/cli/mysql-tools.d.ts +44 -0
- package/dist/cli/mysql-tools.js +290 -0
- package/dist/cli/no-follow.d.ts +29 -0
- package/dist/cli/no-follow.js +67 -0
- package/dist/cli/pii-predicate-guard.d.ts +1 -1
- package/dist/cli/pii-predicate-guard.js +2 -2
- package/dist/cli/pii-tags.d.ts +2 -2
- package/dist/cli/pii-tags.js +1 -1
- package/dist/cli/prisma-schema.js +2 -2
- package/dist/cli/sql-statements.d.ts +1 -1
- package/dist/cli/sql-statements.js +1 -1
- package/dist/cli/sqlite-doctor.d.ts +35 -0
- package/dist/cli/sqlite-doctor.js +392 -0
- package/dist/cli/sqlite-migrate-command.d.ts +4 -0
- package/dist/cli/sqlite-migrate-command.js +171 -0
- package/dist/cli/sqlite-migrate.d.ts +61 -0
- package/dist/cli/sqlite-migrate.js +681 -0
- package/dist/cli/sqlite-project.d.ts +42 -0
- package/dist/cli/sqlite-project.js +244 -0
- package/dist/cli/sqlite-schema-command.d.ts +4 -0
- package/dist/cli/sqlite-schema-command.js +79 -0
- package/dist/cli/sqlite-schema-ddl.d.ts +25 -0
- package/dist/cli/sqlite-schema-ddl.js +248 -0
- package/dist/cli/sqlite-schema.d.ts +25 -0
- package/dist/cli/sqlite-schema.js +330 -0
- package/dist/cli/sqlite-seed.d.ts +4 -0
- package/dist/cli/sqlite-seed.js +57 -0
- package/dist/cli/sqlite-tools.d.ts +24 -0
- package/dist/cli/sqlite-tools.js +163 -0
- package/dist/cli/studio.js +9 -9
- package/dist/cli/tool-capabilities.d.ts +72 -0
- package/dist/cli/tool-capabilities.js +114 -0
- package/dist/cli/tool-command.d.ts +11 -0
- package/dist/cli/tool-command.js +45 -0
- package/dist/cli/ui.d.ts +1 -1
- package/dist/cli/ui.js +1 -1
- package/dist/client.d.ts +20 -20
- package/dist/client.js +62 -341
- package/dist/connection-url.d.ts +1 -1
- package/dist/connection-url.js +1 -1
- package/dist/core.d.ts +58 -0
- package/dist/core.js +220 -0
- package/dist/d1/catalog-metadata.d.ts +5 -0
- package/dist/d1/catalog-metadata.js +227 -0
- package/dist/d1/catalog.d.ts +15 -0
- package/dist/d1/catalog.js +82 -0
- package/dist/d1/generate.d.ts +8 -0
- package/dist/d1/generate.js +160 -0
- package/dist/d1/introspect.d.ts +21 -0
- package/dist/d1/introspect.js +71 -0
- package/dist/d1/migrate.d.ts +29 -0
- package/dist/d1/migrate.js +217 -0
- package/dist/d1/migrations/sql.d.ts +2 -0
- package/dist/d1/migrations/sql.js +106 -0
- package/dist/d1/pool.d.ts +14 -0
- package/dist/d1/pool.js +86 -0
- package/dist/d1/sql.d.ts +5 -0
- package/dist/d1/sql.js +135 -0
- package/dist/d1/sqlite-dialect.d.ts +16 -0
- package/dist/d1/sqlite-dialect.js +572 -0
- package/dist/d1/types.d.ts +29 -0
- package/dist/d1/types.js +1 -0
- package/dist/d1.d.ts +53 -0
- package/dist/d1.js +215 -0
- package/dist/dialect.d.ts +33 -5
- package/dist/dialect.js +6 -4
- package/dist/errors.d.ts +38 -1
- package/dist/errors.js +68 -17
- package/dist/generate.d.ts +19 -3
- package/dist/generate.js +330 -97
- package/dist/global-filters-config.js +2 -2
- package/dist/index-advisor.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/introspect.d.ts +59 -356
- package/dist/introspect.js +116 -943
- package/dist/libsql/bindings.d.ts +2 -0
- package/dist/libsql/bindings.js +75 -0
- package/dist/libsql/dialect.d.ts +3 -0
- package/dist/libsql/dialect.js +45 -0
- package/dist/libsql/generate.d.ts +4 -0
- package/dist/libsql/generate.js +53 -0
- package/dist/libsql/introspect.d.ts +16 -0
- package/dist/libsql/introspect.js +289 -0
- package/dist/libsql/pool.d.ts +42 -0
- package/dist/libsql/pool.js +270 -0
- package/dist/libsql/seed-cleanup.d.ts +2 -0
- package/dist/libsql/seed-cleanup.js +15 -0
- package/dist/libsql/values.d.ts +20 -0
- package/dist/libsql/values.js +68 -0
- package/dist/libsql-seed.d.ts +19 -0
- package/dist/libsql-seed.js +46 -0
- package/dist/libsql.d.ts +28 -0
- package/dist/libsql.js +79 -0
- package/dist/live-query.d.ts +33 -0
- package/dist/live-query.js +169 -0
- package/dist/log-codes.d.ts +1 -1
- package/dist/log-codes.js +4 -0
- package/dist/mssql-seed.d.ts +27 -0
- package/dist/mssql-seed.js +114 -0
- package/dist/mssql.d.ts +7 -7
- package/dist/mssql.js +366 -54
- package/dist/mysql-seed.d.ts +25 -0
- package/dist/mysql-seed.js +165 -0
- package/dist/mysql.d.ts +18 -6
- package/dist/mysql.js +603 -95
- package/dist/neon-http/client.d.ts +95 -0
- package/dist/neon-http/client.js +286 -0
- package/dist/neon-http/sql.d.ts +3 -0
- package/dist/neon-http/sql.js +112 -0
- package/dist/neon-http.d.ts +5 -0
- package/dist/neon-http.js +2 -0
- package/dist/neon-ws/load-driver.cjs +11 -0
- package/dist/neon-ws/load-driver.d.cts +9 -0
- package/dist/neon-ws/recovery.d.ts +14 -0
- package/dist/neon-ws/recovery.js +66 -0
- package/dist/neon-ws/snapshot.d.ts +3 -0
- package/dist/neon-ws/snapshot.js +15 -0
- package/dist/neon-ws/transport.d.ts +112 -0
- package/dist/neon-ws/transport.js +286 -0
- package/dist/neon-ws.d.ts +26 -0
- package/dist/neon-ws.js +182 -0
- package/dist/nested-write.d.ts +34 -3
- package/dist/nested-write.js +114 -22
- package/dist/notification-hub/consumer.d.ts +22 -0
- package/dist/notification-hub/consumer.js +106 -0
- package/dist/notification-hub.d.ts +41 -0
- package/dist/notification-hub.js +370 -0
- package/dist/pg-catalog-text.d.ts +96 -0
- package/dist/pg-catalog-text.js +208 -0
- package/dist/pg-types.d.ts +46 -2
- package/dist/pipeline-submittable.d.ts +15 -5
- package/dist/pipeline-submittable.js +105 -50
- package/dist/pipeline.d.ts +5 -2
- package/dist/pipeline.js +113 -43
- package/dist/plan-divergence.d.ts +1 -1
- package/dist/plan-divergence.js +1 -1
- package/dist/powdb-introspect.d.ts +1 -1
- package/dist/powdb-introspect.js +5 -5
- package/dist/powdb-shared.d.ts +5 -5
- package/dist/powdb-shared.js +6 -5
- package/dist/powdb.d.ts +28 -10
- package/dist/powdb.js +80 -28
- package/dist/powql.d.ts +50 -28
- package/dist/powql.js +49 -35
- package/dist/prisma-compat.js +4 -5
- package/dist/prisma-schema-fingerprint.d.ts +1 -1
- package/dist/prisma-schema-fingerprint.js +1 -1
- package/dist/query/aggregates.d.ts +0 -13
- package/dist/query/aggregates.js +97 -230
- package/dist/query/batched-loader.d.ts +1 -1
- package/dist/query/batched-loader.js +5 -7
- package/dist/query/builder.d.ts +108 -144
- package/dist/query/builder.js +563 -864
- package/dist/query/compound-unique.d.ts +18 -3
- package/dist/query/compound-unique.js +99 -33
- package/dist/query/cursor-tuple.d.ts +17 -0
- package/dist/query/cursor-tuple.js +114 -0
- package/dist/query/expr.d.ts +2 -0
- package/dist/query/expr.js +32 -16
- package/dist/query/filters.d.ts +39 -7
- package/dist/query/filters.js +69 -14
- package/dist/query/normalize-args.d.ts +1 -1
- package/dist/query/normalize-args.js +4 -2
- package/dist/query/option-surface.d.ts +1 -1
- package/dist/query/option-surface.js +4 -2
- package/dist/query/pg-type-parsers.d.ts +126 -0
- package/dist/query/pg-type-parsers.js +296 -0
- package/dist/query/relation-names.d.ts +4 -2
- package/dist/query/relation-names.js +15 -7
- package/dist/query/relations.d.ts +19 -7
- package/dist/query/relations.js +293 -227
- package/dist/query/row-lock.js +1 -1
- package/dist/query/sql-comment.js +1 -1
- package/dist/query/stream-idle.d.ts +11 -1
- package/dist/query/stream-idle.js +51 -13
- package/dist/query/stream-signal.d.ts +21 -0
- package/dist/query/stream-signal.js +125 -0
- package/dist/query/temporal-parsers.d.ts +101 -0
- package/dist/query/temporal-parsers.js +354 -0
- package/dist/query/types.d.ts +67 -20
- package/dist/query/utils.d.ts +2 -878
- package/dist/query/utils.js +5 -2003
- package/dist/query/warn-registry.d.ts +1 -1
- package/dist/query/warn-registry.js +1 -1
- package/dist/query/where-compile.d.ts +4 -1
- package/dist/query/where-compile.js +14 -10
- package/dist/query/where.d.ts +14 -7
- package/dist/query/where.js +236 -430
- package/dist/query/writes.d.ts +33 -2
- package/dist/query/writes.js +90 -65
- package/dist/query-utils.d.ts +687 -0
- package/dist/query-utils.js +1390 -0
- package/dist/realtime.d.ts +1 -1
- package/dist/realtime.js +3 -3
- package/dist/schema-builder.js +2 -2
- package/dist/schema-metadata.d.ts +13 -3
- package/dist/schema-metadata.js +33 -5
- package/dist/schema-sql.d.ts +15 -24
- package/dist/schema-sql.js +50 -60
- package/dist/schema.d.ts +37 -2
- package/dist/schema.js +29 -2
- package/dist/seed.js +5 -5
- package/dist/serverless.d.ts +24 -71
- package/dist/serverless.js +24 -71
- package/dist/sql.d.ts +111 -0
- package/dist/sql.js +321 -0
- package/dist/sqlite-seed.d.ts +17 -0
- package/dist/sqlite-seed.js +27 -0
- package/dist/sqlite.d.ts +32 -19
- package/dist/sqlite.js +859 -648
- package/dist/supplied-pool-types.js +2 -1
- package/dist/transaction-control.js +6 -1
- package/dist/transaction-outcome.d.ts +61 -0
- package/dist/transaction-outcome.js +234 -0
- package/dist/transaction-state.d.ts +82 -13
- package/dist/transaction-state.js +220 -57
- package/dist/transaction-transport.d.ts +38 -0
- package/dist/transaction-transport.js +153 -0
- package/dist/typed-sql.d.ts +1 -1
- package/dist/typed-sql.js +1 -1
- package/package.json +239 -13
- package/skills/turbine-orm/SKILL.md +6 -5
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
import { type ReturningSelection } from '../dialect.js';
|
|
14
14
|
import type { TableMetadata } from '../schema.js';
|
|
15
15
|
import type { DeferredQuery } from './deferred.js';
|
|
16
|
+
import { type OperandColumnKind } from './filters.js';
|
|
16
17
|
import type { CreateArgs, CreateManyArgs, DeleteArgs, DeleteManyArgs, UpdateArgs, UpdateManyArgs, UpsertArgs } from './types.js';
|
|
17
18
|
import type { BuilderCtx } from './where.js';
|
|
18
19
|
/**
|
|
@@ -61,6 +62,23 @@ import type { BuilderCtx } from './where.js';
|
|
|
61
62
|
* type first; see {@link checkTextWrite}.
|
|
62
63
|
*/
|
|
63
64
|
export declare function coerceWriteValue(qi: BuilderCtx, key: string, value: unknown): unknown;
|
|
65
|
+
/**
|
|
66
|
+
* Refuse an array written to a column that cannot store it as one value:
|
|
67
|
+
*
|
|
68
|
+
* - on an array column, an array with a hole at any depth: the driver binds
|
|
69
|
+
* each hole as NULL, so `new Array(1)` would store `{NULL}`, and the where
|
|
70
|
+
* compiler already refuses the same value as an operand;
|
|
71
|
+
* - on a scalar type named like an array type (`dbType` spelled `_mood` or
|
|
72
|
+
* `mood[]` while the catalog records `isArray: false`, so `kind` is not
|
|
73
|
+
* `array`; see `columnOperandKind`), any array: it was bound as an array
|
|
74
|
+
* literal, so a one-row write stored the label `{"x"}` and createMany's
|
|
75
|
+
* UNNEST flattened it to `x`, while reads refuse the same value.
|
|
76
|
+
*
|
|
77
|
+
* A JSON column never gets here with an array (it is serialized as JSON
|
|
78
|
+
* does), and an array on every other scalar column is
|
|
79
|
+
* {@link assertScalarBindable}'s to refuse or not, as before.
|
|
80
|
+
*/
|
|
81
|
+
export declare function assertArrayWrite(kind: OperandColumnKind, dbType: string | undefined, table: string, key: string, value: unknown): void;
|
|
64
82
|
/**
|
|
65
83
|
* Build a `SELECT * ... WHERE <predicate>` that re-fetches the row(s) matched
|
|
66
84
|
* by a write's `where` clause. Used by the `'reselect'` result strategy to
|
|
@@ -130,7 +148,9 @@ type OptimisticLockRefusal = 'upsert' | 'updateMany' | 'delete' | 'deleteMany';
|
|
|
130
148
|
* `$transaction`) has no second round trip to look anything up with.
|
|
131
149
|
*
|
|
132
150
|
* - `where-differs`: `where` is not pinned to `create`'s values, so the
|
|
133
|
-
* conflict statement would compare the wrong row
|
|
151
|
+
* conflict statement would compare the wrong row, or its columns are not
|
|
152
|
+
* exactly one unique key, so no conflict target names it
|
|
153
|
+
* (upsertWhereMatchesCreate).
|
|
134
154
|
* - `empty-update`: an `update` with no fields has no `DO UPDATE SET` to emit;
|
|
135
155
|
* every engine rejected the statement as a syntax error. Prisma reads it as
|
|
136
156
|
* "create it if it is missing", which the lookup answers.
|
|
@@ -253,6 +273,17 @@ export declare function writeProjectionCacheSegment(projection: WriteProjection
|
|
|
253
273
|
* time (`SET "updated_at" = $1, "updated_at" = $2`, PostgreSQL 42701).
|
|
254
274
|
*/
|
|
255
275
|
export declare function applyUpdatedAtColumns(qi: BuilderCtx, data: Record<string, unknown>): Record<string, unknown>;
|
|
276
|
+
/**
|
|
277
|
+
* The set of COLUMNS a `data` object names, under any accepted spelling of each
|
|
278
|
+
* key. A key set to `undefined` names nothing (see {@link definedKeys}), and a
|
|
279
|
+
* key that resolves to no column is left to the SQL builder's own E003.
|
|
280
|
+
*/
|
|
281
|
+
/**
|
|
282
|
+
* `optimisticLock` writes its own version bump, so `data` that also writes the
|
|
283
|
+
* version column would assign it twice, which PostgreSQL rejects (42601) with
|
|
284
|
+
* an untyped error. Refused before anything is built, on every engine.
|
|
285
|
+
*/
|
|
286
|
+
export declare function assertLockColumnNotWritten(meta: TableMetadata, table: string, data: Record<string, unknown>, field: string): void;
|
|
256
287
|
export declare function writeReturningColumns(qi: BuilderCtx, projection?: WriteProjection): ReturningSelection;
|
|
257
288
|
/**
|
|
258
289
|
* String form of {@link writeReturningColumns} for a `SELECT` list (the
|
|
@@ -279,7 +310,7 @@ export declare function assertWritable(qi: BuilderCtx, operation: string): void;
|
|
|
279
310
|
/**
|
|
280
311
|
* Reject a write whose `data` names a `GENERATED ALWAYS AS (...) STORED`
|
|
281
312
|
* column (H3). Postgres computes these from other columns and errors if you
|
|
282
|
-
* try to write them;
|
|
313
|
+
* try to write them; fail early with a clear {@link ValidationError} (E003)
|
|
283
314
|
* instead of surfacing a cryptic driver error. Undefined values are ignored
|
|
284
315
|
* (they're stripped from the statement anyway).
|
|
285
316
|
*/
|
package/dist/cjs/query/writes.js
CHANGED
|
@@ -47,6 +47,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
47
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
48
|
exports.COUNT_ONLY = void 0;
|
|
49
49
|
exports.coerceWriteValue = coerceWriteValue;
|
|
50
|
+
exports.assertArrayWrite = assertArrayWrite;
|
|
50
51
|
exports.buildReselectByWhere = buildReselectByWhere;
|
|
51
52
|
exports.buildCreate = buildCreate;
|
|
52
53
|
exports.makeCreateReselect = makeCreateReselect;
|
|
@@ -66,6 +67,7 @@ exports.piiFields = piiFields;
|
|
|
66
67
|
exports.isCountOnly = isCountOnly;
|
|
67
68
|
exports.writeProjectionCacheSegment = writeProjectionCacheSegment;
|
|
68
69
|
exports.applyUpdatedAtColumns = applyUpdatedAtColumns;
|
|
70
|
+
exports.assertLockColumnNotWritten = assertLockColumnNotWritten;
|
|
69
71
|
exports.writeReturningColumns = writeReturningColumns;
|
|
70
72
|
exports.writeReselectSelection = writeReselectSelection;
|
|
71
73
|
exports.parseWriteRow = parseWriteRow;
|
|
@@ -77,6 +79,7 @@ exports.fingerprintSet = fingerprintSet;
|
|
|
77
79
|
exports.collectSetParams = collectSetParams;
|
|
78
80
|
const dialect_js_1 = require("../dialect.js");
|
|
79
81
|
const errors_js_1 = require("../errors.js");
|
|
82
|
+
const query_utils_js_1 = require("../query-utils.js");
|
|
80
83
|
const column_ref_js_1 = require("./column-ref.js");
|
|
81
84
|
const compound_unique_js_1 = require("./compound-unique.js");
|
|
82
85
|
const expr_js_1 = require("./expr.js");
|
|
@@ -84,7 +87,6 @@ const filters_js_1 = require("./filters.js");
|
|
|
84
87
|
const json_value_js_1 = require("./json-value.js");
|
|
85
88
|
const normalize_args_js_1 = require("./normalize-args.js");
|
|
86
89
|
const types_js_1 = require("./types.js");
|
|
87
|
-
const utils_js_1 = require("./utils.js");
|
|
88
90
|
const whereMod = __importStar(require("./where.js"));
|
|
89
91
|
/**
|
|
90
92
|
* Normalize one `data` value before it is bound as a write param. This is THE
|
|
@@ -148,7 +150,7 @@ function coerceWriteValue(qi, key, value) {
|
|
|
148
150
|
// Non-throwing, because this also runs on the cache-HIT param-collect path,
|
|
149
151
|
// where an unknown key must not turn into a different error than the build
|
|
150
152
|
// path already raises.
|
|
151
|
-
const column = (0,
|
|
153
|
+
const column = (0, query_utils_js_1.resolveColumnName)(qi.tableMeta, key);
|
|
152
154
|
const dbType = column ? qi.columnPgTypeMap.get(column) : undefined;
|
|
153
155
|
if ((0, json_value_js_1.isJsonValue)(value))
|
|
154
156
|
return jsonText(qi, key, value.value);
|
|
@@ -159,13 +161,42 @@ function coerceWriteValue(qi, key, value) {
|
|
|
159
161
|
throw new errors_js_1.ValidationError((0, expr_js_1.plainExprShapeMessage)(qi.table, key, String(value.kind)));
|
|
160
162
|
}
|
|
161
163
|
assertScalarBindable(qi, key, dbType, value);
|
|
164
|
+
if (column !== undefined)
|
|
165
|
+
assertArrayWrite(qi.whereHost.getColumnKind(column), dbType, qi.table, key, value);
|
|
162
166
|
if (!(value instanceof Date) && !Array.isArray(value))
|
|
163
167
|
return value;
|
|
164
168
|
// A column missing from the type map resolves to undefined → no coercion.
|
|
165
169
|
// The gate is where.ts's, so a written Date and a compared Date take the
|
|
166
170
|
// same form: a `date` column the UTC date part on every SQL engine, a
|
|
167
171
|
// zone-less `timestamp` the UTC literal on PostgreSQL only.
|
|
168
|
-
return (0,
|
|
172
|
+
return (0, query_utils_js_1.coerceTemporalValue)(dbType, value, whereMod.utcDateTimeRewrite(qi, dbType));
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Refuse an array written to a column that cannot store it as one value:
|
|
176
|
+
*
|
|
177
|
+
* - on an array column, an array with a hole at any depth: the driver binds
|
|
178
|
+
* each hole as NULL, so `new Array(1)` would store `{NULL}`, and the where
|
|
179
|
+
* compiler already refuses the same value as an operand;
|
|
180
|
+
* - on a scalar type named like an array type (`dbType` spelled `_mood` or
|
|
181
|
+
* `mood[]` while the catalog records `isArray: false`, so `kind` is not
|
|
182
|
+
* `array`; see `columnOperandKind`), any array: it was bound as an array
|
|
183
|
+
* literal, so a one-row write stored the label `{"x"}` and createMany's
|
|
184
|
+
* UNNEST flattened it to `x`, while reads refuse the same value.
|
|
185
|
+
*
|
|
186
|
+
* A JSON column never gets here with an array (it is serialized as JSON
|
|
187
|
+
* does), and an array on every other scalar column is
|
|
188
|
+
* {@link assertScalarBindable}'s to refuse or not, as before.
|
|
189
|
+
*/
|
|
190
|
+
function assertArrayWrite(kind, dbType, table, key, value) {
|
|
191
|
+
if (!Array.isArray(value))
|
|
192
|
+
return;
|
|
193
|
+
if (kind === 'array' && (0, filters_js_1.hasArrayHole)(value)) {
|
|
194
|
+
throw new errors_js_1.ValidationError(`Invalid value for "${key}" on table "${table}": received a sparse array (an index with no element), which ` +
|
|
195
|
+
'would store each hole as NULL. Give every index an element (null for a NULL element).');
|
|
196
|
+
}
|
|
197
|
+
if (kind !== 'array' && dbType !== undefined && (0, filters_js_1.isArrayTypeToken)(dbType)) {
|
|
198
|
+
throw new errors_js_1.ValidationError(`Cannot write an array to "${table}.${key}" (column type ${dbType}): a scalar type named like an array type.`);
|
|
199
|
+
}
|
|
169
200
|
}
|
|
170
201
|
/**
|
|
171
202
|
* Ask the engine whether it stores `value` in the column `key` names as that
|
|
@@ -174,7 +205,7 @@ function coerceWriteValue(qi, key, value) {
|
|
|
174
205
|
* {@link coerceWriteValue}.
|
|
175
206
|
*/
|
|
176
207
|
function checkTextWrite(qi, key, value) {
|
|
177
|
-
const column = (0,
|
|
208
|
+
const column = (0, query_utils_js_1.resolveColumnName)(qi.tableMeta, key);
|
|
178
209
|
const columnType = column ? qi.columnPgTypeMap.get(column) : undefined;
|
|
179
210
|
if (!column || columnType === undefined)
|
|
180
211
|
return;
|
|
@@ -427,7 +458,7 @@ async function lockMovedRowKey(qi, exec, whereObj, data, operation, manyRows) {
|
|
|
427
458
|
}
|
|
428
459
|
const assigned = new Map();
|
|
429
460
|
for (const [key, value] of writeEntries(qi, data)) {
|
|
430
|
-
const column = (0,
|
|
461
|
+
const column = (0, query_utils_js_1.resolveColumnName)(qi.tableMeta, key);
|
|
431
462
|
if (column !== undefined && identity.includes(column))
|
|
432
463
|
assigned.set(column, [key, value]);
|
|
433
464
|
}
|
|
@@ -479,7 +510,7 @@ function movedKeyValue(qi, operation, key, current, assigned) {
|
|
|
479
510
|
/** The columns the top level of `where` names, for a message. */
|
|
480
511
|
function whereColumns(qi, where) {
|
|
481
512
|
return Object.keys(where).flatMap((key) => {
|
|
482
|
-
const column = where[key] === undefined ? undefined : (0,
|
|
513
|
+
const column = where[key] === undefined ? undefined : (0, query_utils_js_1.resolveColumnName)(qi.tableMeta, key);
|
|
483
514
|
return column === undefined ? [] : [column];
|
|
484
515
|
});
|
|
485
516
|
}
|
|
@@ -500,7 +531,7 @@ function integerOf(value) {
|
|
|
500
531
|
function textSafeKeyWhere(qi, where) {
|
|
501
532
|
let out;
|
|
502
533
|
for (const [key, value] of Object.entries(where)) {
|
|
503
|
-
const column = (0,
|
|
534
|
+
const column = (0, query_utils_js_1.resolveColumnName)(qi.tableMeta, key);
|
|
504
535
|
if (column === undefined)
|
|
505
536
|
continue;
|
|
506
537
|
const plain = (0, filters_js_1.isPlainRecord)(value) && Object.keys(value).length === 1 && 'equals' in value;
|
|
@@ -628,7 +659,7 @@ const ZERO_INSERT_ID = Symbol('turbine.zeroInsertId');
|
|
|
628
659
|
function createReselectKey(qi, data) {
|
|
629
660
|
const supplied = new Map();
|
|
630
661
|
for (const [key, value] of writeEntries(qi, data)) {
|
|
631
|
-
const column = (0,
|
|
662
|
+
const column = (0, query_utils_js_1.resolveColumnName)(qi.tableMeta, key);
|
|
632
663
|
// Same rewrite the INSERT's own params got, then the text-key rule.
|
|
633
664
|
if (column !== undefined && value !== null) {
|
|
634
665
|
supplied.set(column, reselectKeyValue(qi, column, coerceWriteValue(qi, key, value)));
|
|
@@ -785,7 +816,7 @@ function assertOneRowByKey(qi, operation, columns, rows) {
|
|
|
785
816
|
* statement and its params describe different writes.
|
|
786
817
|
*/
|
|
787
818
|
function writeEntries(qi, data) {
|
|
788
|
-
return (0,
|
|
819
|
+
return (0, query_utils_js_1.canonicalWriteEntries)(qi.tableMeta, Object.entries(data).filter(([, v]) => v !== undefined));
|
|
789
820
|
}
|
|
790
821
|
/** The key half of {@link writeEntries}, for the paths that need names only. */
|
|
791
822
|
function definedKeys(qi, row) {
|
|
@@ -1018,7 +1049,7 @@ function prepareCreateMany(qi, args, projection) {
|
|
|
1018
1049
|
// nested array to flatten (a raw `[1, 2, 3]` there used to become three
|
|
1019
1050
|
// rows), and every other cell is a string, object or null that the driver
|
|
1020
1051
|
// serializes as one array element.
|
|
1021
|
-
const hasArrayColumn = columns.some((col) =>
|
|
1052
|
+
const hasArrayColumn = columns.some((col) => qi.whereHost.getColumnKind(col) === 'array');
|
|
1022
1053
|
return {
|
|
1023
1054
|
conflict,
|
|
1024
1055
|
identity,
|
|
@@ -1131,7 +1162,7 @@ function resolveConflictTarget(qi, raw) {
|
|
|
1131
1162
|
}
|
|
1132
1163
|
const columns = [];
|
|
1133
1164
|
for (const field of raw) {
|
|
1134
|
-
const column = (0,
|
|
1165
|
+
const column = (0, query_utils_js_1.resolveColumnName)(qi.tableMeta, field);
|
|
1135
1166
|
if (column === undefined) {
|
|
1136
1167
|
throw new errors_js_1.ValidationError(`createMany on "${table}": onConflict.target names "${field}", which is not a column. ` +
|
|
1137
1168
|
`Valid targets: ${describeConflictTargets(qi)}.`);
|
|
@@ -1178,7 +1209,7 @@ function resolveConflictUpdate(qi, raw) {
|
|
|
1178
1209
|
if (Object.hasOwn(update, field)) {
|
|
1179
1210
|
throw new errors_js_1.ValidationError(`createMany on "${qi.table}": onConflict.update names "${field}" twice.`);
|
|
1180
1211
|
}
|
|
1181
|
-
update[field] = expr_js_1.
|
|
1212
|
+
update[field] = (0, expr_js_1.buildExcludedRef)(field);
|
|
1182
1213
|
}
|
|
1183
1214
|
return update;
|
|
1184
1215
|
}
|
|
@@ -1323,7 +1354,7 @@ function explainConflictKeyCollision(qi, args, err) {
|
|
|
1323
1354
|
return err;
|
|
1324
1355
|
const raw = args.onConflict.target;
|
|
1325
1356
|
const target = Array.isArray(raw)
|
|
1326
|
-
? raw.map((f) => (typeof f === 'string' ? ((0,
|
|
1357
|
+
? raw.map((f) => (typeof f === 'string' ? ((0, query_utils_js_1.resolveColumnName)(qi.tableMeta, f) ?? f) : String(f)))
|
|
1327
1358
|
: [];
|
|
1328
1359
|
return conflictKeySharedError(qi, target, err);
|
|
1329
1360
|
}
|
|
@@ -1488,6 +1519,8 @@ function buildUpdate(qi, args, projection) {
|
|
|
1488
1519
|
// members count as a real predicate.
|
|
1489
1520
|
const userWhere = (0, compound_unique_js_1.expandCompoundUniqueWhere)(qi.tableMeta, args.where);
|
|
1490
1521
|
const lock = args.optimisticLock;
|
|
1522
|
+
if (lock)
|
|
1523
|
+
assertLockColumnNotWritten(qi.tableMeta, qi.table, dataObj, lock.field);
|
|
1491
1524
|
// The empty-`where` guard checks the USER predicate only, a global filter
|
|
1492
1525
|
// must never turn an unguarded mass update into an allowed one.
|
|
1493
1526
|
const userHasPredicate = !whereMod.userPredicateIsEmpty(qi, userWhere) || !!lock;
|
|
@@ -1544,8 +1577,7 @@ function buildUpdate(qi, args, projection) {
|
|
|
1544
1577
|
const versionCol = qi.toSqlColumn(lock.field);
|
|
1545
1578
|
setClauses.push(`${versionCol} = ${versionCol} + 1`);
|
|
1546
1579
|
}
|
|
1547
|
-
|
|
1548
|
-
let whereSql = whereClause ? ` WHERE ${whereClause}` : '';
|
|
1580
|
+
let whereSql = whereMod.buildWhereSql(qi, whereObj, freshParams);
|
|
1549
1581
|
if (lock) {
|
|
1550
1582
|
const versionCol = qi.toSqlColumn(lock.field);
|
|
1551
1583
|
freshParams.push(lock.expected);
|
|
@@ -1663,8 +1695,7 @@ function buildDelete(qi, args, projection) {
|
|
|
1663
1695
|
const ck = `d:${whereFp}${whereMod.globalFilterCacheSegment(qi)}${writeProjectionCacheSegment(projection)}`;
|
|
1664
1696
|
const params = [];
|
|
1665
1697
|
const buildSql = (freshParams) => {
|
|
1666
|
-
const
|
|
1667
|
-
const whereSql = clause ? ` WHERE ${clause}` : '';
|
|
1698
|
+
const whereSql = whereMod.buildWhereSql(qi, whereObj, freshParams);
|
|
1668
1699
|
// SQL Server injects `OUTPUT DELETED.*` between `DELETE FROM <t>` and WHERE;
|
|
1669
1700
|
// absent override → the trailing-clause PG/SQLite/MySQL form (byte-identical).
|
|
1670
1701
|
// `returning` excludes PII columns on tagged tables (else '*').
|
|
@@ -1786,7 +1817,9 @@ function upsertStatementRefusal(qi, reason, where, create) {
|
|
|
1786
1817
|
return new errors_js_1.ValidationError(`A batched upsert on "${qi.table}" cannot be one statement: ` +
|
|
1787
1818
|
(reason === 'empty-update'
|
|
1788
1819
|
? 'its `update` is empty. '
|
|
1789
|
-
:
|
|
1820
|
+
: !(0, compound_unique_js_1.upsertWhereIsOneKey)(qi.tableMeta, where)
|
|
1821
|
+
? `\`where\` (${keys.join(', ')}) is not exactly one unique key, which is all one statement's conflict target can name. `
|
|
1822
|
+
: `\`where\` (${keys.join(', ')}) does not carry \`create\`'s values, which are what one statement matches on. `) +
|
|
1790
1823
|
call);
|
|
1791
1824
|
}
|
|
1792
1825
|
function buildUpsert(qi, args, projection) {
|
|
@@ -1959,19 +1992,26 @@ function upsertTargetRef(qi) {
|
|
|
1959
1992
|
return qi.dialect.upsertTargetAlias ?? qi.q(qi.table);
|
|
1960
1993
|
}
|
|
1961
1994
|
function buildUpdateMany(qi, args) {
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1995
|
+
return buildBulkMutation(qi, args, 'updateMany');
|
|
1996
|
+
}
|
|
1997
|
+
function buildDeleteMany(qi, args) {
|
|
1998
|
+
return buildBulkMutation(qi, args, 'deleteMany');
|
|
1999
|
+
}
|
|
2000
|
+
/** The two count-returning writes share guards, cache traversal and result shape. */
|
|
2001
|
+
function buildBulkMutation(qi, args, operation) {
|
|
2002
|
+
assertWritable(qi, operation);
|
|
2003
|
+
assertNoBulkWritePaging(qi.table, operation, args);
|
|
2004
|
+
assertNoOptimisticLock(qi, args, operation);
|
|
1965
2005
|
qi.currentSkip = (0, types_js_1.resolveSkipGlobalFilters)(args.skipGlobalFilters);
|
|
1966
|
-
const
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
if (!Object.values(
|
|
2006
|
+
const update = operation === 'updateMany';
|
|
2007
|
+
let data;
|
|
2008
|
+
if (update) {
|
|
2009
|
+
data = applyUpdatedAtColumns(qi, args.data);
|
|
2010
|
+
assertNoGeneratedColumns(qi, data, operation);
|
|
2011
|
+
}
|
|
2012
|
+
whereMod.assertMutationHasPredicate(qi, operation, whereMod.userPredicateIsEmpty(qi, args.where) ? '' : ' WHERE x', (0, types_js_1.resolveUnsafeFlag)(args.allowFullTableScan, 'allowFullTableScan'));
|
|
2013
|
+
const where = (whereMod.mergeGlobalFilter(qi, args.where) ?? {});
|
|
2014
|
+
if (update && !Object.values(data).some((v) => v !== undefined)) {
|
|
1975
2015
|
return {
|
|
1976
2016
|
sql: `SELECT ${qi.p(1)} AS count`,
|
|
1977
2017
|
params: [0],
|
|
@@ -1979,51 +2019,26 @@ function buildUpdateMany(qi, args) {
|
|
|
1979
2019
|
tag: `${qi.table}.updateMany`,
|
|
1980
2020
|
};
|
|
1981
2021
|
}
|
|
1982
|
-
const setFp = fingerprintSet(qi,
|
|
1983
|
-
const whereFp = whereMod.fingerprintWhere(qi,
|
|
1984
|
-
const
|
|
2022
|
+
const setFp = update ? fingerprintSet(qi, data) : undefined;
|
|
2023
|
+
const whereFp = whereMod.fingerprintWhere(qi, where);
|
|
2024
|
+
const key = `${update ? `um:${setFp}|` : 'dm:'}${whereFp}${whereMod.globalFilterCacheSegment(qi)}`;
|
|
1985
2025
|
const params = [];
|
|
1986
|
-
const
|
|
1987
|
-
const
|
|
1988
|
-
const
|
|
1989
|
-
const
|
|
1990
|
-
return
|
|
2026
|
+
const build = (fresh) => {
|
|
2027
|
+
const set = update ? buildSetClauses(qi, writeEntries(qi, data), fresh, { operation: 'updateMany' }) : undefined;
|
|
2028
|
+
const whereSql = whereMod.buildWhereSql(qi, where, fresh);
|
|
2029
|
+
const prefix = set ? `UPDATE ${qi.q(qi.table)} SET ${set.join(', ')}` : `DELETE FROM ${qi.q(qi.table)}`;
|
|
2030
|
+
return `${prefix}${whereSql}`;
|
|
1991
2031
|
};
|
|
1992
|
-
const entry = qi.acquireSql(
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
2032
|
+
const entry = qi.acquireSql(key, build);
|
|
2033
|
+
if (update)
|
|
2034
|
+
collectSetParams(qi, data, params);
|
|
2035
|
+
whereMod.collectWhereParams(qi, where, params);
|
|
2036
|
+
qi.crossCheckCache(operation, key, entry, build, params);
|
|
1996
2037
|
return {
|
|
1997
2038
|
sql: entry.sql,
|
|
1998
2039
|
params,
|
|
1999
2040
|
transform: (result) => ({ count: result.rowCount ?? 0 }),
|
|
2000
|
-
tag: `${qi.table}
|
|
2001
|
-
preparedName: entry.name,
|
|
2002
|
-
};
|
|
2003
|
-
}
|
|
2004
|
-
function buildDeleteMany(qi, args) {
|
|
2005
|
-
assertWritable(qi, 'deleteMany');
|
|
2006
|
-
assertNoBulkWritePaging(qi.table, 'deleteMany', args);
|
|
2007
|
-
assertNoOptimisticLock(qi, args, 'deleteMany');
|
|
2008
|
-
qi.currentSkip = (0, types_js_1.resolveSkipGlobalFilters)(args.skipGlobalFilters);
|
|
2009
|
-
whereMod.assertMutationHasPredicate(qi, 'deleteMany', whereMod.userPredicateIsEmpty(qi, args.where) ? '' : ' WHERE x', (0, types_js_1.resolveUnsafeFlag)(args.allowFullTableScan, 'allowFullTableScan'));
|
|
2010
|
-
const whereObj = (whereMod.mergeGlobalFilter(qi, args.where) ?? {});
|
|
2011
|
-
const whereFp = whereMod.fingerprintWhere(qi, whereObj);
|
|
2012
|
-
const ck = `dm:${whereFp}${whereMod.globalFilterCacheSegment(qi)}`;
|
|
2013
|
-
const params = [];
|
|
2014
|
-
const buildSql = (freshParams) => {
|
|
2015
|
-
const clause = whereMod.buildWhereClause(qi, whereObj, freshParams);
|
|
2016
|
-
const whereSql = clause ? ` WHERE ${clause}` : '';
|
|
2017
|
-
return `DELETE FROM ${qi.q(qi.table)}${whereSql}`;
|
|
2018
|
-
};
|
|
2019
|
-
const entry = qi.acquireSql(ck, buildSql);
|
|
2020
|
-
whereMod.collectWhereParams(qi, whereObj, params);
|
|
2021
|
-
qi.crossCheckCache('deleteMany', ck, entry, buildSql, params);
|
|
2022
|
-
return {
|
|
2023
|
-
sql: entry.sql,
|
|
2024
|
-
params,
|
|
2025
|
-
transform: (result) => ({ count: result.rowCount ?? 0 }),
|
|
2026
|
-
tag: `${qi.table}.deleteMany`,
|
|
2041
|
+
tag: `${qi.table}.${operation}`,
|
|
2027
2042
|
preparedName: entry.name,
|
|
2028
2043
|
};
|
|
2029
2044
|
}
|
|
@@ -2163,12 +2178,24 @@ function applyUpdatedAtColumns(qi, data) {
|
|
|
2163
2178
|
* key. A key set to `undefined` names nothing (see {@link definedKeys}), and a
|
|
2164
2179
|
* key that resolves to no column is left to the SQL builder's own E003.
|
|
2165
2180
|
*/
|
|
2181
|
+
/**
|
|
2182
|
+
* `optimisticLock` writes its own version bump, so `data` that also writes the
|
|
2183
|
+
* version column would assign it twice, which PostgreSQL rejects (42601) with
|
|
2184
|
+
* an untyped error. Refused before anything is built, on every engine.
|
|
2185
|
+
*/
|
|
2186
|
+
function assertLockColumnNotWritten(meta, table, data, field) {
|
|
2187
|
+
const column = (0, query_utils_js_1.resolveColumnName)(meta, field);
|
|
2188
|
+
if (column === undefined || !namedColumns(meta, data).has(column))
|
|
2189
|
+
return;
|
|
2190
|
+
throw new errors_js_1.ValidationError(`\`optimisticLock\` on "${table}" writes "${field}" itself (it adds 1), so \`data\` must not write it too. ` +
|
|
2191
|
+
'Remove it from `data`, or drop `optimisticLock` and write the version yourself.');
|
|
2192
|
+
}
|
|
2166
2193
|
function namedColumns(meta, data) {
|
|
2167
2194
|
const out = new Set();
|
|
2168
2195
|
for (const key of Object.keys(data)) {
|
|
2169
2196
|
if (data[key] === undefined)
|
|
2170
2197
|
continue;
|
|
2171
|
-
const column = (0,
|
|
2198
|
+
const column = (0, query_utils_js_1.resolveColumnName)(meta, key);
|
|
2172
2199
|
if (column)
|
|
2173
2200
|
out.add(column);
|
|
2174
2201
|
}
|
|
@@ -2177,7 +2204,7 @@ function namedColumns(meta, data) {
|
|
|
2177
2204
|
function writeReturningColumns(qi, projection) {
|
|
2178
2205
|
if (projection)
|
|
2179
2206
|
return projection.columns.map((col) => qi.q(col));
|
|
2180
|
-
// The PK exemption used to be re-stated here as `|| pk.has(col)`. It
|
|
2207
|
+
// The PK exemption used to be re-stated here as `|| pk.has(col)`. It
|
|
2181
2208
|
// lives in `piiColumns` so every projection inherits it and none can drift.
|
|
2182
2209
|
const piiCols = piiColumns(qi, qi.tableMeta);
|
|
2183
2210
|
if (piiCols.size === 0)
|
|
@@ -2233,7 +2260,7 @@ function assertWritable(qi, operation) {
|
|
|
2233
2260
|
/**
|
|
2234
2261
|
* Reject a write whose `data` names a `GENERATED ALWAYS AS (...) STORED`
|
|
2235
2262
|
* column (H3). Postgres computes these from other columns and errors if you
|
|
2236
|
-
* try to write them;
|
|
2263
|
+
* try to write them; fail early with a clear {@link ValidationError} (E003)
|
|
2237
2264
|
* instead of surfacing a cryptic driver error. Undefined values are ignored
|
|
2238
2265
|
* (they're stripped from the statement anyway).
|
|
2239
2266
|
*/
|
|
@@ -2264,7 +2291,7 @@ function assertNoGeneratedKeys(qi, generated, data, operation) {
|
|
|
2264
2291
|
for (const key in data) {
|
|
2265
2292
|
if (!Object.hasOwn(data, key) || data[key] === undefined)
|
|
2266
2293
|
continue;
|
|
2267
|
-
const column = (0,
|
|
2294
|
+
const column = (0, query_utils_js_1.resolveColumnName)(qi.tableMeta, key);
|
|
2268
2295
|
if (column !== undefined && generated.has(column)) {
|
|
2269
2296
|
throw new errors_js_1.ValidationError(`Cannot ${operation} "${qi.table}": column "${key}" is a GENERATED ALWAYS AS (…) STORED ` +
|
|
2270
2297
|
'column whose value the database computes, remove it from your data.');
|
|
@@ -2319,7 +2346,7 @@ function setOperatorOf(qi, key, value) {
|
|
|
2319
2346
|
}
|
|
2320
2347
|
/** Whether `key` names a json/jsonb column (non-throwing; unknown keys are not). */
|
|
2321
2348
|
function isJsonWriteColumn(qi, key) {
|
|
2322
|
-
const column = (0,
|
|
2349
|
+
const column = (0, query_utils_js_1.resolveColumnName)(qi.tableMeta, key);
|
|
2323
2350
|
const dbType = column ? qi.columnPgTypeMap.get(column) : undefined;
|
|
2324
2351
|
return dbType !== undefined && whereMod.isJsonColumnType(qi, dbType);
|
|
2325
2352
|
}
|
|
@@ -2444,7 +2471,7 @@ const SAFE_CAST_TYPE = /^[A-Za-z_][A-Za-z0-9_]*( [A-Za-z_][A-Za-z0-9_]*)*(\(\d+(
|
|
|
2444
2471
|
function exprValueCast(qi, key) {
|
|
2445
2472
|
if (!qi.dialect.capabilities.paramTypeCasts)
|
|
2446
2473
|
return '';
|
|
2447
|
-
const column = (0,
|
|
2474
|
+
const column = (0, query_utils_js_1.resolveColumnName)(qi.tableMeta, key);
|
|
2448
2475
|
if (column === undefined)
|
|
2449
2476
|
return '';
|
|
2450
2477
|
const enumCast = whereMod.enumCastSuffix(qi, column);
|
|
@@ -2453,7 +2480,7 @@ function exprValueCast(qi, key) {
|
|
|
2453
2480
|
if (qi.crossSchemaTypeColumns.has(column))
|
|
2454
2481
|
return '';
|
|
2455
2482
|
const type = qi.columnPgTypeMap.get(column);
|
|
2456
|
-
if (type === undefined ||
|
|
2483
|
+
if (type === undefined || qi.whereHost.getColumnKind(column) === 'array' || !SAFE_CAST_TYPE.test(type))
|
|
2457
2484
|
return '';
|
|
2458
2485
|
return `::${type}`;
|
|
2459
2486
|
}
|
|
@@ -2469,7 +2496,7 @@ function arithmeticValueCast(qi, key, targetCast, cls) {
|
|
|
2469
2496
|
return '';
|
|
2470
2497
|
if (cls === 'dec')
|
|
2471
2498
|
return '::numeric';
|
|
2472
|
-
const column = (0,
|
|
2499
|
+
const column = (0, query_utils_js_1.resolveColumnName)(qi.tableMeta, key);
|
|
2473
2500
|
return column !== undefined && targetCast !== '' && isIntegerColumnType(qi.columnPgTypeMap.get(column))
|
|
2474
2501
|
? targetCast
|
|
2475
2502
|
: '::int8';
|