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
package/dist/cjs/mysql.js
CHANGED
|
@@ -15,8 +15,7 @@
|
|
|
15
15
|
* rows. `mysqlDialect.resultStrategy = 'reselect'`: the executor runs the
|
|
16
16
|
* write, then issues a follow-up `SELECT` by primary key (using mysql2's
|
|
17
17
|
* `insertId` for auto-increment PKs) / by the `where` predicate, so
|
|
18
|
-
* `create`/`update`/`upsert`/`delete` still return real rows.
|
|
19
|
-
* first shipped engine to exercise the Phase-0 `reselect` path.
|
|
18
|
+
* `create`/`update`/`upsert`/`delete` still return real rows.
|
|
20
19
|
* 2. **Positional `?` is broken for this builder.** Turbine pushes params in
|
|
21
20
|
* 1-indexed generation order but EMITS them in a different SQL-text position
|
|
22
21
|
* (e.g. a `with`-relation `LIMIT` lands in the SELECT list, ahead of the
|
|
@@ -76,6 +75,7 @@ const client_js_1 = require("./client.js");
|
|
|
76
75
|
const dialect_js_1 = require("./dialect.js");
|
|
77
76
|
const errors_js_1 = require("./errors.js");
|
|
78
77
|
const introspect_js_1 = require("./introspect.js");
|
|
78
|
+
const logger_js_1 = require("./logger.js");
|
|
79
79
|
const optional_peer_import_cjs_1 = __importDefault(require("./optional-peer-import.cjs"));
|
|
80
80
|
const schema_js_1 = require("./schema.js");
|
|
81
81
|
const sql_placeholders_js_1 = require("./sql-placeholders.js");
|
|
@@ -144,34 +144,55 @@ function paddedListLength(n) {
|
|
|
144
144
|
function refusePlaceholder(message) {
|
|
145
145
|
throw new errors_js_1.ValidationError(message);
|
|
146
146
|
}
|
|
147
|
+
/** Bounded SQL-only templates. Neither bindings nor list contents are retained. */
|
|
148
|
+
const bindingTemplates = new Map();
|
|
149
|
+
function bindingTemplate(sql, count) {
|
|
150
|
+
const cached = bindingTemplates.get(sql);
|
|
151
|
+
if (cached?.count === count)
|
|
152
|
+
return cached;
|
|
153
|
+
// Arity is part of admission: a warmed $2 must still refuse one supplied value.
|
|
154
|
+
const template = {
|
|
155
|
+
count,
|
|
156
|
+
sql: (0, sql_placeholders_js_1.rewritePositionalPlaceholders)(sql, 'mysql', count, (i) => `:p${i}`, refusePlaceholder),
|
|
157
|
+
names: Array.from({ length: count }, (_, i) => `p${i + 1}`),
|
|
158
|
+
};
|
|
159
|
+
if (sql.length <= 8192 && count <= 128) {
|
|
160
|
+
if (bindingTemplates.size >= 128)
|
|
161
|
+
bindingTemplates.delete(bindingTemplates.keys().next().value);
|
|
162
|
+
bindingTemplates.set(sql, template);
|
|
163
|
+
}
|
|
164
|
+
return template;
|
|
165
|
+
}
|
|
147
166
|
/**
|
|
148
167
|
* The statement text and named binding for one execution: `$n` placeholders
|
|
149
168
|
* (the spelling `rawUnsafe` documents) rewritten to `:pN`, every
|
|
150
169
|
* {@link MysqlInList} expanded, and every other value bound by name. Mapping by
|
|
151
170
|
* NAME makes binding independent of where each placeholder lands in the SQL
|
|
152
|
-
* text, the same guarantee Postgres' numbered `$N` gives.
|
|
171
|
+
* text, the same guarantee Postgres' numbered `$N` gives. No wrapper is needed
|
|
172
|
+
* for an empty parameter array. `binding` is
|
|
153
173
|
* `undefined` when nothing is bound, so parameter-less statements (BEGIN,
|
|
154
174
|
* COMMIT, DDL) run through `.query()`.
|
|
155
175
|
*/
|
|
156
176
|
function bindStatement(sql, values) {
|
|
157
177
|
if (values.length === 0)
|
|
158
|
-
return
|
|
159
|
-
const
|
|
178
|
+
return undefined;
|
|
179
|
+
const template = bindingTemplate(sql, values.length);
|
|
160
180
|
const named = {};
|
|
161
181
|
let lists;
|
|
162
182
|
for (let i = 0; i < values.length; i++) {
|
|
163
183
|
const value = values[i];
|
|
184
|
+
const name = i < template.names.length ? template.names[i] : `p${i + 1}`;
|
|
164
185
|
if (value instanceof MysqlInList) {
|
|
165
186
|
lists ??= new Map();
|
|
166
|
-
lists.set(
|
|
187
|
+
lists.set(name, value);
|
|
167
188
|
}
|
|
168
189
|
else {
|
|
169
|
-
named[
|
|
190
|
+
named[name] = toMysqlParam(value);
|
|
170
191
|
}
|
|
171
192
|
}
|
|
172
193
|
if (lists === undefined)
|
|
173
|
-
return { sql:
|
|
174
|
-
const expanded = expandInLists(
|
|
194
|
+
return { sql: template.sql, binding: named };
|
|
195
|
+
const expanded = expandInLists(template.sql, lists, named);
|
|
175
196
|
return { sql: expanded, binding: Object.keys(named).length > 0 ? named : undefined };
|
|
176
197
|
}
|
|
177
198
|
/**
|
|
@@ -258,15 +279,16 @@ const MYSQL_FIELD_TYPE_TINY = 1;
|
|
|
258
279
|
function coerceBooleanColumns(rows, fields) {
|
|
259
280
|
if (!Array.isArray(fields) || rows.length === 0)
|
|
260
281
|
return;
|
|
261
|
-
|
|
282
|
+
let names;
|
|
262
283
|
for (const f of fields) {
|
|
263
284
|
if (!f || f.columnType !== MYSQL_FIELD_TYPE_TINY || f.columnLength !== 1)
|
|
264
285
|
continue;
|
|
265
286
|
if (typeof f.name !== 'string')
|
|
266
287
|
continue;
|
|
288
|
+
names ??= [];
|
|
267
289
|
names.push(f.name);
|
|
268
290
|
}
|
|
269
|
-
if (names.length === 0)
|
|
291
|
+
if (names === undefined || names.length === 0)
|
|
270
292
|
return;
|
|
271
293
|
for (const row of rows) {
|
|
272
294
|
for (const name of names) {
|
|
@@ -296,7 +318,7 @@ function shapeResult(result, fields) {
|
|
|
296
318
|
* deadlock / lock-wait-timeout become retryable (E012/E013). The original mysql2
|
|
297
319
|
* error (with its real message) is preserved as the wrapped error's `.cause`
|
|
298
320
|
* downstream. Returns the value unchanged when it is not a recognizable mysql2
|
|
299
|
-
* error.
|
|
321
|
+
* error. This only annotates the error; `wrapPgError` (invoked downstream in the query
|
|
300
322
|
* executor / transaction proxy) does the actual translation.
|
|
301
323
|
*/
|
|
302
324
|
function augmentMysqlError(err) {
|
|
@@ -409,6 +431,43 @@ function normalizeQueryArgs(arg, values) {
|
|
|
409
431
|
return { text: arg, params: values ?? [] };
|
|
410
432
|
return { text: arg.text, params: arg.values ?? values ?? [] };
|
|
411
433
|
}
|
|
434
|
+
/**
|
|
435
|
+
* Only the bulk INSERT builder knows that its placeholders occur exactly once,
|
|
436
|
+
* in parameter order, with no value expressions or SQL literals between them.
|
|
437
|
+
* Keep its positional driver statement private, keyed by the actual parameter
|
|
438
|
+
* array. The public DeferredQuery still contains the same named SQL. A copied
|
|
439
|
+
* array, edited SQL (including comments), or changed arity uses normal binding.
|
|
440
|
+
* No values or statements outlive the parameter array.
|
|
441
|
+
*/
|
|
442
|
+
const bulkInsertBindings = new WeakMap();
|
|
443
|
+
/** Arity-only templates: eight entries of at most 8,192 cells, never caller values or identifiers. */
|
|
444
|
+
const bulkInsertTuples = new Map();
|
|
445
|
+
function mysqlParamPlaceholder(index) {
|
|
446
|
+
return `:p${index}`;
|
|
447
|
+
}
|
|
448
|
+
function bulkTuples(rows) {
|
|
449
|
+
const width = rows[0]?.length ?? 0;
|
|
450
|
+
const uniform = rows.every((row) => row.length === width);
|
|
451
|
+
const cacheable = uniform && width > 0 && rows.length * width <= 8192;
|
|
452
|
+
const key = `${rows.length}:${width}`;
|
|
453
|
+
const cached = cacheable ? bulkInsertTuples.get(key) : undefined;
|
|
454
|
+
if (cached)
|
|
455
|
+
return cached;
|
|
456
|
+
let n = 0;
|
|
457
|
+
const named = rows.map((row) => `(${row.map(() => `:p${++n}`).join(', ')})`).join(', ');
|
|
458
|
+
const positional = uniform
|
|
459
|
+
? Array(rows.length)
|
|
460
|
+
.fill(`(${Array(width).fill('?').join(', ')})`)
|
|
461
|
+
.join(', ')
|
|
462
|
+
: rows.map((row) => `(${row.map(() => '?').join(', ')})`).join(', ');
|
|
463
|
+
const tuples = { named, positional };
|
|
464
|
+
if (cacheable) {
|
|
465
|
+
if (bulkInsertTuples.size >= 8)
|
|
466
|
+
bulkInsertTuples.delete(bulkInsertTuples.keys().next().value);
|
|
467
|
+
bulkInsertTuples.set(key, tuples);
|
|
468
|
+
}
|
|
469
|
+
return tuples;
|
|
470
|
+
}
|
|
412
471
|
/**
|
|
413
472
|
* Run one statement against a mysql2 queryable (pool or connection). Parameterized
|
|
414
473
|
* statements use `.execute()` (mysql2 server-side prepared statements, cached per
|
|
@@ -417,10 +476,15 @@ function normalizeQueryArgs(arg, values) {
|
|
|
417
476
|
* the `{ p1, p2, … }` object built from the positional params.
|
|
418
477
|
*/
|
|
419
478
|
async function execOne(runner, sql, params) {
|
|
420
|
-
const
|
|
421
|
-
const
|
|
479
|
+
const bulk = bulkInsertBindings.get(params);
|
|
480
|
+
const bound = bulk && bulk.sql === sql && bulk.count === params.length && !params.some((v) => v instanceof MysqlInList)
|
|
481
|
+
? { sql: bulk.positional, binding: Array.from(params, toMysqlParam) }
|
|
482
|
+
: bindStatement(sql, params);
|
|
483
|
+
const binding = bound?.binding;
|
|
422
484
|
try {
|
|
423
|
-
const [result, fields] = binding
|
|
485
|
+
const [result, fields] = binding
|
|
486
|
+
? await runner.execute(bound.sql, binding)
|
|
487
|
+
: await runner.query(bound?.sql ?? sql);
|
|
424
488
|
return shapeResult(result, fields);
|
|
425
489
|
}
|
|
426
490
|
catch (err) {
|
|
@@ -438,16 +502,335 @@ async function execOne(runner, sql, params) {
|
|
|
438
502
|
*/
|
|
439
503
|
async function runOnConnection(conn, sql, params) {
|
|
440
504
|
if (params.length === 0 && /^SET TRANSACTION ISOLATION LEVEL /i.test(sql) && sql.includes('; ')) {
|
|
441
|
-
let last
|
|
505
|
+
let last;
|
|
442
506
|
for (const part of sql.split('; ')) {
|
|
443
507
|
const trimmed = part.trim();
|
|
444
508
|
if (trimmed)
|
|
445
509
|
last = await execOne(conn, trimmed, []);
|
|
446
510
|
}
|
|
447
|
-
|
|
511
|
+
// The first real statement supplies the result; only an empty split needs
|
|
512
|
+
// a fallback. Do not allocate a discarded row array and result per BEGIN.
|
|
513
|
+
return last ?? shapeResult([]);
|
|
448
514
|
}
|
|
449
515
|
return execOne(conn, sql, params);
|
|
450
516
|
}
|
|
517
|
+
/**
|
|
518
|
+
* Whether the server answered with `err`: an error packet on a live connection
|
|
519
|
+
* (a numeric `errno`, not fatal), as the error or its cause. A lost or
|
|
520
|
+
* timed-out connection is no answer. So are a shutdown (1053), an interrupted
|
|
521
|
+
* statement (1317) and a killed connection (1927), which can arrive while a
|
|
522
|
+
* COMMIT is being written.
|
|
523
|
+
*/
|
|
524
|
+
function answeredByServer(err) {
|
|
525
|
+
for (let e = err, depth = 0; depth < 4 && e !== null && typeof e === 'object'; depth++) {
|
|
526
|
+
const { errno, fatal } = e;
|
|
527
|
+
if (typeof errno === 'number')
|
|
528
|
+
return errno > 0 && fatal !== true && ![1053, 1317, 1927].includes(errno);
|
|
529
|
+
e = e.cause;
|
|
530
|
+
}
|
|
531
|
+
return false;
|
|
532
|
+
}
|
|
533
|
+
/**
|
|
534
|
+
* Close a connection Turbine is discarding, in both directions, so the server
|
|
535
|
+
* ends its session now.
|
|
536
|
+
*
|
|
537
|
+
* mysql2's own `destroy()` is `stream.end()`, a half-close, and it drops the
|
|
538
|
+
* connection from the pool at once. A server still writing a result to a
|
|
539
|
+
* client that stopped reading (a stream returned early) never reads that close,
|
|
540
|
+
* so its session stayed in "Sending to client", holding its metadata lock,
|
|
541
|
+
* until `net_write_timeout`, outside the pool limit. The half-closed client
|
|
542
|
+
* also kept reading: the execute mysql2 queues behind a prepare was sent on the
|
|
543
|
+
* closed socket, and the server's parting error packet arrived as its answer,
|
|
544
|
+
* which mysql2 prints as "got packets out of order".
|
|
545
|
+
*
|
|
546
|
+
* Destroying the socket closes both directions (a reset while unread rows are
|
|
547
|
+
* buffered), which the server sees on its next read or write. mysql2 handles it
|
|
548
|
+
* as any lost connection: queued commands fail, and the pool drops the
|
|
549
|
+
* connection when the socket closes. Nothing waits on this connection any
|
|
550
|
+
* more, so the error mysql2 reports for it is absorbed.
|
|
551
|
+
*/
|
|
552
|
+
function destroyConnection(raw) {
|
|
553
|
+
raw.on?.('error', () => { });
|
|
554
|
+
if (typeof raw.stream?.destroy === 'function')
|
|
555
|
+
raw.stream.destroy();
|
|
556
|
+
else
|
|
557
|
+
raw.destroy?.();
|
|
558
|
+
}
|
|
559
|
+
/** A checked-out connection never queues another statement behind a paused result. */
|
|
560
|
+
class MysqlStreamClient {
|
|
561
|
+
conn;
|
|
562
|
+
released = false;
|
|
563
|
+
discarded = false;
|
|
564
|
+
inTransaction = false;
|
|
565
|
+
pending = 0;
|
|
566
|
+
committing = false;
|
|
567
|
+
deadlineError;
|
|
568
|
+
active;
|
|
569
|
+
constructor(conn) {
|
|
570
|
+
this.conn = conn;
|
|
571
|
+
}
|
|
572
|
+
timeoutError(timeout, confirmed = false) {
|
|
573
|
+
return new errors_js_1.TimeoutError(timeout, 'Transaction', {
|
|
574
|
+
outcome: confirmed ? 'not-executed' : 'unknown',
|
|
575
|
+
message: `Transaction timed out after ${timeout}ms. ${confirmed ? 'Rollback was confirmed.' : 'Cancellation and rollback are not confirmed; its outcome is unknown.'}`,
|
|
576
|
+
});
|
|
577
|
+
}
|
|
578
|
+
transactionRecovery = {
|
|
579
|
+
assertTimeout: () => { },
|
|
580
|
+
pendingMessage: 'transaction cannot commit; rollback is not yet confirmed. ',
|
|
581
|
+
sessionMessage: 'Your callback did not run; rollback is not yet confirmed.',
|
|
582
|
+
timeoutError: (timeout) => (this.deadlineError = this.timeoutError(timeout)),
|
|
583
|
+
rollback: async (running, send, graceMs) => {
|
|
584
|
+
// mysql2 cannot cancel a running statement. A failed COMMIT response is
|
|
585
|
+
// uncertain even if a later ROLLBACK answers successfully.
|
|
586
|
+
if (running || this.pending || this.committing)
|
|
587
|
+
return false;
|
|
588
|
+
let timer;
|
|
589
|
+
try {
|
|
590
|
+
return await Promise.race([
|
|
591
|
+
send().then(() => true, () => false),
|
|
592
|
+
new Promise((resolve) => {
|
|
593
|
+
timer = setTimeout(() => resolve(false), graceMs);
|
|
594
|
+
}),
|
|
595
|
+
]);
|
|
596
|
+
}
|
|
597
|
+
finally {
|
|
598
|
+
clearTimeout(timer);
|
|
599
|
+
}
|
|
600
|
+
},
|
|
601
|
+
finish: (state, clean, error, logger) => {
|
|
602
|
+
state.end(clean ? 'was rolled back' : 'ended with an unknown outcome');
|
|
603
|
+
if (!clean && logger)
|
|
604
|
+
(0, logger_js_1.logTo)(logger, 'debug', 'Transaction ended with an unknown outcome', {
|
|
605
|
+
code: 'transaction-outcome-unknown',
|
|
606
|
+
operation: '$transaction',
|
|
607
|
+
});
|
|
608
|
+
if (clean && this.deadlineError === error && this.deadlineError)
|
|
609
|
+
return this.timeoutError(this.deadlineError.timeoutMs, true);
|
|
610
|
+
// A COMMIT the server did not answer (a lost or timed-out connection)
|
|
611
|
+
// may have committed. An error the server answered with keeps its class.
|
|
612
|
+
return this.committing && !answeredByServer(error) ? new errors_js_1.TransactionOutcomeUnknownError(error) : error;
|
|
613
|
+
},
|
|
614
|
+
};
|
|
615
|
+
assertOpen() {
|
|
616
|
+
if (this.released || this.discarded)
|
|
617
|
+
throw new errors_js_1.ConnectionError('This MySQL checkout has been released or discarded.');
|
|
618
|
+
}
|
|
619
|
+
// biome-ignore lint/suspicious/noExplicitAny: pg-compat query is generic over the row shape.
|
|
620
|
+
async query(text, values) {
|
|
621
|
+
this.pending++;
|
|
622
|
+
try {
|
|
623
|
+
return await this.runQuery(text, values);
|
|
624
|
+
}
|
|
625
|
+
finally {
|
|
626
|
+
this.pending--;
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
// biome-ignore lint/suspicious/noExplicitAny: see query().
|
|
630
|
+
async runQuery(text, values) {
|
|
631
|
+
this.assertOpen();
|
|
632
|
+
const { text: sql, params } = normalizeQueryArgs(text, values);
|
|
633
|
+
if (this.active) {
|
|
634
|
+
if (params.length === 0 && /^\s*(?:COMMIT|ROLLBACK|SAVEPOINT|RELEASE SAVEPOINT)\b/i.test(sql)) {
|
|
635
|
+
await this.active.close();
|
|
636
|
+
this.assertOpen();
|
|
637
|
+
}
|
|
638
|
+
else
|
|
639
|
+
throw new errors_js_1.ValidationError('A MySQL native stream is active on this connection. Close it before another statement.');
|
|
640
|
+
}
|
|
641
|
+
if (sql === 'COMMIT' && params.length === 0)
|
|
642
|
+
this.committing = true;
|
|
643
|
+
const result = await runOnConnection(this.conn, sql, params);
|
|
644
|
+
if (/^\s*(?:(?:SET TRANSACTION ISOLATION LEVEL [A-Z ]+; )?START TRANSACTION|BEGIN)\b/i.test(sql) &&
|
|
645
|
+
params.length === 0)
|
|
646
|
+
this.inTransaction = true;
|
|
647
|
+
else if (/^\s*(?:COMMIT|ROLLBACK(?!\s+TO))\b/i.test(sql) && params.length === 0)
|
|
648
|
+
this.inTransaction = false;
|
|
649
|
+
return result;
|
|
650
|
+
}
|
|
651
|
+
async *streamBatches(text, values, batchSize, signal) {
|
|
652
|
+
this.assertOpen();
|
|
653
|
+
if (this.active)
|
|
654
|
+
throw new errors_js_1.ValidationError('A MySQL native stream is already active on this connection.');
|
|
655
|
+
if (this.pending)
|
|
656
|
+
throw new errors_js_1.ValidationError('A MySQL statement is still running on this connection.');
|
|
657
|
+
if (!Number.isSafeInteger(batchSize) || batchSize < 1)
|
|
658
|
+
throw new errors_js_1.ValidationError('Native stream batchSize must be a positive safe integer.');
|
|
659
|
+
signal?.throwIfAborted();
|
|
660
|
+
const raw = this.conn.connection;
|
|
661
|
+
if (!raw ||
|
|
662
|
+
typeof raw.destroy !== 'function' ||
|
|
663
|
+
typeof raw.pause !== 'function' ||
|
|
664
|
+
typeof raw.resume !== 'function' ||
|
|
665
|
+
typeof raw.execute !== 'function' ||
|
|
666
|
+
typeof raw.query !== 'function') {
|
|
667
|
+
throw new errors_js_1.UnsupportedFeatureError('native streaming', 'mysql', 'The mysql2 callback connection with pause(), resume() and destroy() is required.');
|
|
668
|
+
}
|
|
669
|
+
const bound = bindStatement(text, values);
|
|
670
|
+
let command;
|
|
671
|
+
let fields;
|
|
672
|
+
let rows = [];
|
|
673
|
+
let wake;
|
|
674
|
+
const notify = () => {
|
|
675
|
+
const resolve = wake;
|
|
676
|
+
wake = undefined;
|
|
677
|
+
resolve?.();
|
|
678
|
+
};
|
|
679
|
+
let resultSets = 0;
|
|
680
|
+
let complete = false;
|
|
681
|
+
let closed = false;
|
|
682
|
+
let failure;
|
|
683
|
+
let settle;
|
|
684
|
+
const settled = new Promise((resolve) => {
|
|
685
|
+
settle = resolve;
|
|
686
|
+
});
|
|
687
|
+
const discard = () => {
|
|
688
|
+
if (this.discarded)
|
|
689
|
+
return;
|
|
690
|
+
this.discarded = true;
|
|
691
|
+
destroyConnection(raw);
|
|
692
|
+
};
|
|
693
|
+
const onEnd = () => {
|
|
694
|
+
complete = true;
|
|
695
|
+
notify();
|
|
696
|
+
settle();
|
|
697
|
+
};
|
|
698
|
+
const onError = (error) => {
|
|
699
|
+
if (failure === undefined)
|
|
700
|
+
failure = augmentMysqlError(error);
|
|
701
|
+
notify();
|
|
702
|
+
settle();
|
|
703
|
+
};
|
|
704
|
+
const onFields = (next) => {
|
|
705
|
+
if (++resultSets > 1)
|
|
706
|
+
cancel(new errors_js_1.UnsupportedFeatureError('multiple native stream result sets', 'mysql', 'Stream a single row result set per statement.'));
|
|
707
|
+
else
|
|
708
|
+
fields = next;
|
|
709
|
+
};
|
|
710
|
+
const onRow = (row) => {
|
|
711
|
+
// Callbackless mysql2 commands never collect rows. Keep exactly one
|
|
712
|
+
// batch here and pause packet decoding until the consumer asks again.
|
|
713
|
+
// ResultSetHeader has no fields and must not become a streamed row.
|
|
714
|
+
if (closed || failure !== undefined || !Array.isArray(fields))
|
|
715
|
+
return;
|
|
716
|
+
if (rows.length === batchSize) {
|
|
717
|
+
cancel(new errors_js_1.ConnectionError('The MySQL driver exceeded native stream backpressure.'));
|
|
718
|
+
return;
|
|
719
|
+
}
|
|
720
|
+
rows.push(row);
|
|
721
|
+
if (rows.length === batchSize) {
|
|
722
|
+
raw.pause();
|
|
723
|
+
notify();
|
|
724
|
+
}
|
|
725
|
+
};
|
|
726
|
+
const cancel = (error) => {
|
|
727
|
+
if (failure === undefined)
|
|
728
|
+
failure = error;
|
|
729
|
+
closed = true;
|
|
730
|
+
command?.removeListener('result', onRow);
|
|
731
|
+
discard();
|
|
732
|
+
rows = [];
|
|
733
|
+
notify();
|
|
734
|
+
settle();
|
|
735
|
+
signal?.removeEventListener('abort', onAbort);
|
|
736
|
+
if (this.active === state)
|
|
737
|
+
this.active = undefined;
|
|
738
|
+
};
|
|
739
|
+
let closing;
|
|
740
|
+
const close = () => (closing ??= (async () => {
|
|
741
|
+
const priorFailure = failure;
|
|
742
|
+
closed = true;
|
|
743
|
+
command?.removeListener('result', onRow);
|
|
744
|
+
rows = [];
|
|
745
|
+
notify();
|
|
746
|
+
if (!complete && failure === undefined) {
|
|
747
|
+
// Callbackless commands do not collect result arrays. Detach delivery
|
|
748
|
+
// and resume the wire to discard a transaction's remainder. Standalone
|
|
749
|
+
// streams can discard their checkout instead of draining.
|
|
750
|
+
if (this.inTransaction) {
|
|
751
|
+
raw.resume();
|
|
752
|
+
await settled;
|
|
753
|
+
}
|
|
754
|
+
else
|
|
755
|
+
discard();
|
|
756
|
+
}
|
|
757
|
+
if (failure !== undefined && !complete)
|
|
758
|
+
discard();
|
|
759
|
+
if (this.active === state)
|
|
760
|
+
this.active = undefined;
|
|
761
|
+
signal?.removeEventListener('abort', onAbort);
|
|
762
|
+
command?.removeListener('end', onEnd);
|
|
763
|
+
command?.removeListener('fields', onFields);
|
|
764
|
+
if (!this.discarded)
|
|
765
|
+
raw.removeListener?.('error', onError);
|
|
766
|
+
if (priorFailure === undefined && failure !== undefined)
|
|
767
|
+
throw failure;
|
|
768
|
+
})());
|
|
769
|
+
const state = { close, cancel };
|
|
770
|
+
this.active = state;
|
|
771
|
+
const onAbort = () => cancel(signal.reason);
|
|
772
|
+
try {
|
|
773
|
+
// Fatal parser/socket failures can bypass a callbackless command and
|
|
774
|
+
// reach only the connection's error event.
|
|
775
|
+
raw.on?.('error', onError);
|
|
776
|
+
command = bound?.binding ? raw.execute(bound.sql, bound.binding) : raw.query(bound?.sql ?? text);
|
|
777
|
+
command.on('end', onEnd);
|
|
778
|
+
command.on('error', onError);
|
|
779
|
+
command.on('fields', onFields);
|
|
780
|
+
command.on('result', onRow);
|
|
781
|
+
signal?.addEventListener('abort', onAbort, { once: true });
|
|
782
|
+
if (signal?.aborted)
|
|
783
|
+
onAbort();
|
|
784
|
+
while (true) {
|
|
785
|
+
if (failure !== undefined)
|
|
786
|
+
throw failure;
|
|
787
|
+
if (closed)
|
|
788
|
+
throw new errors_js_1.ValidationError('This MySQL native stream has been closed.');
|
|
789
|
+
if (rows.length === batchSize || (complete && rows.length > 0)) {
|
|
790
|
+
const batch = rows;
|
|
791
|
+
rows = [];
|
|
792
|
+
coerceBooleanColumns(batch, fields);
|
|
793
|
+
yield batch;
|
|
794
|
+
if (!closed && failure === undefined && !complete)
|
|
795
|
+
raw.resume();
|
|
796
|
+
}
|
|
797
|
+
else if (complete)
|
|
798
|
+
return;
|
|
799
|
+
else
|
|
800
|
+
await new Promise((resolve) => {
|
|
801
|
+
wake = resolve;
|
|
802
|
+
});
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
catch (error) {
|
|
806
|
+
if (failure === undefined)
|
|
807
|
+
failure = closed ? new errors_js_1.ValidationError('This MySQL native stream has been closed.') : augmentMysqlError(error);
|
|
808
|
+
throw failure;
|
|
809
|
+
}
|
|
810
|
+
finally {
|
|
811
|
+
signal?.removeEventListener('abort', onAbort);
|
|
812
|
+
await close();
|
|
813
|
+
// A destroyed mysql2 command may still report a late connection error.
|
|
814
|
+
// Keep its harmless error listener until the command is collected.
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
release(error) {
|
|
818
|
+
if (this.released)
|
|
819
|
+
return;
|
|
820
|
+
this.released = true;
|
|
821
|
+
if (this.active)
|
|
822
|
+
this.active.cancel(new errors_js_1.ConnectionError('The MySQL checkout was released during a native stream.'));
|
|
823
|
+
if (!this.discarded) {
|
|
824
|
+
const raw = this.conn.connection;
|
|
825
|
+
if ((error || this.pending) && typeof raw?.destroy === 'function') {
|
|
826
|
+
this.discarded = true;
|
|
827
|
+
destroyConnection(raw);
|
|
828
|
+
}
|
|
829
|
+
else
|
|
830
|
+
this.conn.release();
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
}
|
|
451
834
|
/**
|
|
452
835
|
* A {@link PgCompatPool} backed by a `mysql2` pool. Non-transaction queries run
|
|
453
836
|
* on the pool directly (any connection); `connect()` checks out a dedicated
|
|
@@ -468,14 +851,7 @@ class MysqlPool {
|
|
|
468
851
|
}
|
|
469
852
|
async connect() {
|
|
470
853
|
const conn = await this.pool.getConnection();
|
|
471
|
-
return
|
|
472
|
-
// biome-ignore lint/suspicious/noExplicitAny: see query() above.
|
|
473
|
-
query: async (text, values) => {
|
|
474
|
-
const { text: sql, params } = normalizeQueryArgs(text, values);
|
|
475
|
-
return runOnConnection(conn, sql, params);
|
|
476
|
-
},
|
|
477
|
-
release: () => conn.release(),
|
|
478
|
-
};
|
|
854
|
+
return new MysqlStreamClient(conn);
|
|
479
855
|
}
|
|
480
856
|
async end() {
|
|
481
857
|
if (this.closed)
|
|
@@ -691,7 +1067,9 @@ exports.mysqlDialect = {
|
|
|
691
1067
|
name: 'mysql',
|
|
692
1068
|
capabilities: Object.freeze({
|
|
693
1069
|
distinctOn: false,
|
|
1070
|
+
tupleCursorPredicate: false,
|
|
694
1071
|
positionalJson: false,
|
|
1072
|
+
jsonObjectKeysAsWritten: false,
|
|
695
1073
|
nullsOrderingClause: false,
|
|
696
1074
|
nullsSortHigh: false,
|
|
697
1075
|
insensitiveInList: false,
|
|
@@ -724,6 +1102,7 @@ exports.mysqlDialect = {
|
|
|
724
1102
|
backendCancel: false,
|
|
725
1103
|
idleTransactionTimeout: false,
|
|
726
1104
|
abortsTransactionOnError: false,
|
|
1105
|
+
classifiesCommitAnswer: false,
|
|
727
1106
|
connectionDriver: 'engine-driver',
|
|
728
1107
|
// mysql2 execute() prepares each statement text; max_prepared_stmt_count caps them server-wide.
|
|
729
1108
|
preparesEveryStatement: true,
|
|
@@ -733,7 +1112,7 @@ exports.mysqlDialect = {
|
|
|
733
1112
|
// TEXT / BLOB need a prefix length in a key (ER_BLOB_KEY_WITHOUT_LENGTH).
|
|
734
1113
|
unboundedTextKeys: false,
|
|
735
1114
|
}),
|
|
736
|
-
// No RETURNING → run the write, then re-SELECT by PK/where
|
|
1115
|
+
// No RETURNING → run the write, then re-SELECT by PK/where.
|
|
737
1116
|
resultStrategy: 'reselect',
|
|
738
1117
|
supportsReturning: false,
|
|
739
1118
|
// `ON DUPLICATE KEY UPDATE` has no predicate slot, so `buildUpsertStatement`
|
|
@@ -781,9 +1160,7 @@ exports.mysqlDialect = {
|
|
|
781
1160
|
// text position; positional `?` mis-binds. mysql2 named parameters bind by
|
|
782
1161
|
// name, so `:pN` ↔ `params[N-1]` mirrors Postgres' `$N` regardless of text
|
|
783
1162
|
// order. The driver shim binds via a `{ p1, p2, … }` object.
|
|
784
|
-
paramPlaceholder
|
|
785
|
-
return `:p${index}`;
|
|
786
|
-
},
|
|
1163
|
+
paramPlaceholder: mysqlParamPlaceholder,
|
|
787
1164
|
quoteIdentifier(name) {
|
|
788
1165
|
return `\`${name.replace(/`/g, '``')}\``;
|
|
789
1166
|
},
|
|
@@ -956,19 +1333,32 @@ exports.mysqlDialect = {
|
|
|
956
1333
|
return `INSERT INTO ${input.table} (${input.columns.join(', ')}) VALUES (${input.valuePlaceholders.join(', ')})`;
|
|
957
1334
|
},
|
|
958
1335
|
buildBulkInsertStatement(input) {
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
1336
|
+
const standard = this.paramPlaceholder === mysqlParamPlaceholder;
|
|
1337
|
+
let next = 0;
|
|
1338
|
+
const tuples = standard
|
|
1339
|
+
? bulkTuples(input.rowValues)
|
|
1340
|
+
: {
|
|
1341
|
+
named: input.rowValues
|
|
1342
|
+
.map((row) => `(${row.map(() => this.paramPlaceholder(++next)).join(', ')})`)
|
|
1343
|
+
.join(', '),
|
|
1344
|
+
positional: '',
|
|
1345
|
+
};
|
|
965
1346
|
// skipDuplicates → no-op ON DUPLICATE KEY UPDATE (keeps the existing row).
|
|
966
1347
|
const firstCol = input.columns[0] ?? '`id`';
|
|
967
1348
|
const conflict = input.skipDuplicates ? ` ON DUPLICATE KEY UPDATE ${firstCol} = ${firstCol}` : '';
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
1349
|
+
const prefix = `INSERT INTO ${input.table} (${input.columns.join(', ')}) VALUES `;
|
|
1350
|
+
const sql = `${prefix}${tuples.named}${conflict}`;
|
|
1351
|
+
const params = [];
|
|
1352
|
+
for (const row of input.rowValues)
|
|
1353
|
+
for (const value of row)
|
|
1354
|
+
params.push(value);
|
|
1355
|
+
if (standard && params.length > 0)
|
|
1356
|
+
bulkInsertBindings.set(params, {
|
|
1357
|
+
sql,
|
|
1358
|
+
positional: `${prefix}${tuples.positional}${conflict}`,
|
|
1359
|
+
count: params.length,
|
|
1360
|
+
});
|
|
1361
|
+
return { sql, params };
|
|
972
1362
|
},
|
|
973
1363
|
buildBulkUpsertStatement(input) {
|
|
974
1364
|
// 8.0.19's row alias (`VALUES(col)` is deprecated since 8.0.20). There is
|
|
@@ -1010,7 +1400,7 @@ exports.mysqlDialect = {
|
|
|
1010
1400
|
// MySQL ignores the explicit conflict target, ON DUPLICATE KEY UPDATE keys
|
|
1011
1401
|
// off the table's PK/unique indexes. The `where`-derived conflictColumns
|
|
1012
1402
|
// (input.conflictColumns) must therefore correspond to a real unique/PK index
|
|
1013
|
-
// for the upsert to target the intended row
|
|
1403
|
+
// for the upsert to target the intended row.
|
|
1014
1404
|
return (`INSERT INTO ${input.table} (${input.insertColumns.join(', ')}) VALUES (${input.valuePlaceholders.join(', ')})` +
|
|
1015
1405
|
` ON DUPLICATE KEY UPDATE ${input.updateSetClauses.join(', ')}`);
|
|
1016
1406
|
},
|
|
@@ -1136,17 +1526,11 @@ exports.mysqlDialect = {
|
|
|
1136
1526
|
throw new errors_js_1.UnsupportedFeatureError('sessionContext (RLS session GUCs)', 'mysql', 'MySQL has no transaction-local GUCs / set_config equivalent.');
|
|
1137
1527
|
},
|
|
1138
1528
|
// ---- Streaming ----------------------------------------------------------
|
|
1139
|
-
/**
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
*/
|
|
1145
|
-
async *openStream(connection, sql, params, batchSize) {
|
|
1146
|
-
const result = await connection.query(sql, params);
|
|
1147
|
-
for (let i = 0; i < result.rows.length; i += batchSize) {
|
|
1148
|
-
yield result.rows.slice(i, i + batchSize);
|
|
1149
|
-
}
|
|
1529
|
+
/** Incremental mysql2 consumption; query-only connections cannot stream. */
|
|
1530
|
+
async *openStream(connection, sql, params, batchSize, options) {
|
|
1531
|
+
if (!connection.streamBatches)
|
|
1532
|
+
throw new errors_js_1.UnsupportedFeatureError('native streaming', 'mysql', 'An acquired MysqlPool connection is required.');
|
|
1533
|
+
yield* connection.streamBatches(sql, params, batchSize, options?.signal);
|
|
1150
1534
|
},
|
|
1151
1535
|
// ---- Introspection ------------------------------------------------------
|
|
1152
1536
|
introspector: {
|
|
@@ -1164,46 +1548,117 @@ const num = (v) => (typeof v === 'string' ? Number(v) : (v ?? 0));
|
|
|
1164
1548
|
* same logical schema, legacy-first naming, per-column disambiguation, and
|
|
1165
1549
|
* collision resolution against scalar column fields included.
|
|
1166
1550
|
*/
|
|
1167
|
-
function buildRelationsFromForeignKeys(tableNames, foreignKeys, pkByTable, columnsByTable, logger) {
|
|
1168
|
-
return (0, introspect_js_1.deriveEngineRelations)(tableNames, foreignKeys, pkByTable, columnsByTable, logger);
|
|
1551
|
+
function buildRelationsFromForeignKeys(tableNames, foreignKeys, pkByTable, columnsByTable, logger, isToOne) {
|
|
1552
|
+
return (0, introspect_js_1.deriveEngineRelations)(tableNames, foreignKeys, pkByTable, columnsByTable, logger, isToOne);
|
|
1553
|
+
}
|
|
1554
|
+
/** Only comparison domains whose native equality also enforces the unique key. */
|
|
1555
|
+
function mysqlSameKeyEquality(child, parent) {
|
|
1556
|
+
if (!child || !parent)
|
|
1557
|
+
return false;
|
|
1558
|
+
const type = child.COLUMN_TYPE.toLowerCase();
|
|
1559
|
+
if (type !== parent.COLUMN_TYPE.toLowerCase())
|
|
1560
|
+
return false;
|
|
1561
|
+
if (/^(?:char|varchar)\(\d+\)$/.test(type)) {
|
|
1562
|
+
return (typeof child.CHARACTER_SET_NAME === 'string' &&
|
|
1563
|
+
child.CHARACTER_SET_NAME === parent.CHARACTER_SET_NAME &&
|
|
1564
|
+
typeof child.COLLATION_NAME === 'string' &&
|
|
1565
|
+
child.COLLATION_NAME === parent.COLLATION_NAME);
|
|
1566
|
+
}
|
|
1567
|
+
// ENUM/SET, approximate numbers and unrecognized domains stay conservative.
|
|
1568
|
+
return /^(?:(?:tinyint|smallint|mediumint|int|bigint)(?:\(\d+\))?(?: unsigned)?|decimal\(\d+,\d+\)(?: unsigned)?|(?:var)?binary\(\d+\)|date|(?:datetime|timestamp|time)(?:\(\d+\))?|year)$/.test(type);
|
|
1569
|
+
}
|
|
1570
|
+
/** Decode COLUMN_TYPE's catalog serialization, independently of DDL sql_mode. */
|
|
1571
|
+
function parseMysqlEnum(source) {
|
|
1572
|
+
const labels = [];
|
|
1573
|
+
const token = /'((?:[^'\\]|''|\\[\\0nr])*)'([,)])/gy;
|
|
1574
|
+
token.lastIndex = 5;
|
|
1575
|
+
if (/^enum\(/i.test(source)) {
|
|
1576
|
+
for (let match = token.exec(source); match; match = token.exec(source)) {
|
|
1577
|
+
labels.push(match[1].replace(/''|\\[\\0nr]/g, (escaped) => escaped === "''"
|
|
1578
|
+
? "'"
|
|
1579
|
+
: escaped === '\\0'
|
|
1580
|
+
? '\u0000'
|
|
1581
|
+
: escaped === '\\n'
|
|
1582
|
+
? '\n'
|
|
1583
|
+
: escaped === '\\r'
|
|
1584
|
+
? '\r'
|
|
1585
|
+
: '\\'));
|
|
1586
|
+
if (match[2] === ')') {
|
|
1587
|
+
if (token.lastIndex === source.length)
|
|
1588
|
+
return labels;
|
|
1589
|
+
break;
|
|
1590
|
+
}
|
|
1591
|
+
}
|
|
1592
|
+
}
|
|
1593
|
+
throw new errors_js_1.ValidationError('Invalid MySQL ENUM catalog definition.');
|
|
1594
|
+
}
|
|
1595
|
+
/**
|
|
1596
|
+
* Character sets that can encode a code point the catalog text cannot.
|
|
1597
|
+
* `information_schema` reports `COLUMN_TYPE` in utf8mb3 (verified on MySQL
|
|
1598
|
+
* 8.4.0: `SELECT CHARSET(COLUMN_TYPE)` is `utf8mb3`, and the bytes are `?`
|
|
1599
|
+
* where a supplementary character was), so only a column in one of these
|
|
1600
|
+
* sets can hold a label the catalog rendering loses. Every other MySQL
|
|
1601
|
+
* charset has a BMP-only repertoire, which utf8mb3 renders exactly (a
|
|
1602
|
+
* literal `?` in such a label really is a question mark).
|
|
1603
|
+
*/
|
|
1604
|
+
const SUPPLEMENTARY_CHARSETS = new Set(['utf8mb4', 'utf16', 'utf16le', 'utf32', 'gb18030']);
|
|
1605
|
+
/**
|
|
1606
|
+
* Whether catalog-decoded `labels` may have lost a supplementary character:
|
|
1607
|
+
* some label holds a `?` and the column's charset can encode what utf8mb3
|
|
1608
|
+
* cannot. The loss always surfaces as `?` (the conversion has no other
|
|
1609
|
+
* substitute), so its absence proves the labels exact; its presence is
|
|
1610
|
+
* ambiguous with a literal question mark, which catalog text cannot settle,
|
|
1611
|
+
* so a suspect list is withheld whatever it holds. A missing charset is
|
|
1612
|
+
* suspect too: the catalog always reports one for an ENUM, so a custom
|
|
1613
|
+
* executor that omits it has not proven the column BMP-only.
|
|
1614
|
+
*/
|
|
1615
|
+
function enumLabelsSuspect(labels, charset) {
|
|
1616
|
+
if (!labels.some((label) => label.includes('?')))
|
|
1617
|
+
return false;
|
|
1618
|
+
// Loose null on purpose: a custom executor's row can omit the field the
|
|
1619
|
+
// catalog query selected, and absent is not proof of a BMP-only column.
|
|
1620
|
+
return charset == null || SUPPLEMENTARY_CHARSETS.has(charset.toLowerCase());
|
|
1169
1621
|
}
|
|
1170
1622
|
/**
|
|
1171
1623
|
* Introspect a MySQL database into the same {@link SchemaMetadata} shape the
|
|
1172
1624
|
* Postgres catalog introspector produces, using a caller-supplied query
|
|
1173
1625
|
* executor (so tests can dogfood an already-open mysql2 pool/connection).
|
|
1174
1626
|
*
|
|
1627
|
+
* Every statement is a `SELECT`. An ENUM column whose catalog labels may have
|
|
1628
|
+
* lost a supplementary character (the utf8mb3 `COLUMN_TYPE` text holds `?` on
|
|
1629
|
+
* a charset that can encode past the BMP) is marked
|
|
1630
|
+
* `enumLabelsUnrecoverable`, warned about by name, and typed `string` instead
|
|
1631
|
+
* of a union guessed from the damaged text; labels declared explicitly (an
|
|
1632
|
+
* `enums` entry, or a `columnTypes` override at generation) outrank it.
|
|
1633
|
+
*
|
|
1175
1634
|
* @param exec Runs a parameterized (`:p1`, `:p2`, …) query and returns rows.
|
|
1176
1635
|
* @param schema The MySQL database (schema) name to introspect.
|
|
1177
|
-
* @param options
|
|
1178
|
-
*
|
|
1636
|
+
* @param options Table-name filters, relation-naming logger, and the legacy
|
|
1637
|
+
* opt-out from proven unique-FK reverse to-one cardinality.
|
|
1179
1638
|
*/
|
|
1180
1639
|
async function introspectMysqlWith(exec, schema, options = {}) {
|
|
1181
1640
|
// ----- Tables -----
|
|
1182
1641
|
const candidateTables = (await exec("SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA = :p1 AND TABLE_TYPE = 'BASE TABLE' ORDER BY TABLE_NAME", [schema])).map((r) => String(r.TABLE_NAME));
|
|
1183
|
-
// include / exclude + default bookkeeping-table exclusions
|
|
1642
|
+
// include / exclude + default bookkeeping-table exclusions.
|
|
1184
1643
|
const tableNames = (0, introspect_js_1.applyTableFilters)(candidateTables, options);
|
|
1185
1644
|
const tableSet = new Set(tableNames);
|
|
1186
1645
|
// ----- Columns -----
|
|
1187
1646
|
const columnRows = (await exec(`SELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE, COLUMN_TYPE, IS_NULLABLE, COLUMN_KEY,
|
|
1188
|
-
COLUMN_DEFAULT, EXTRA, CHARACTER_MAXIMUM_LENGTH
|
|
1647
|
+
COLUMN_DEFAULT, EXTRA, CHARACTER_MAXIMUM_LENGTH, CHARACTER_SET_NAME, COLLATION_NAME,
|
|
1648
|
+
GENERATION_EXPRESSION
|
|
1189
1649
|
FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = :p1 ORDER BY TABLE_NAME, ORDINAL_POSITION`, [schema]));
|
|
1190
1650
|
const columnsByTable = new Map();
|
|
1651
|
+
const nativeColumns = new Map();
|
|
1191
1652
|
const enums = (0, introspect_js_1.nullRecord)();
|
|
1653
|
+
const logger = options.logger ?? logger_js_1.consoleLogger;
|
|
1192
1654
|
for (const c of columnRows) {
|
|
1193
1655
|
if (!tableSet.has(c.TABLE_NAME))
|
|
1194
1656
|
continue;
|
|
1657
|
+
nativeColumns.set(JSON.stringify([c.TABLE_NAME, c.COLUMN_NAME]), c);
|
|
1195
1658
|
const nullable = c.IS_NULLABLE === 'YES' && c.COLUMN_KEY !== 'PRI';
|
|
1659
|
+
const computed = /\b(?:VIRTUAL|STORED) GENERATED\b/i.test(c.EXTRA) || !!c.GENERATION_EXPRESSION;
|
|
1196
1660
|
const dataType = c.DATA_TYPE.toLowerCase();
|
|
1197
|
-
|
|
1198
|
-
if (dataType === 'enum') {
|
|
1199
|
-
const m = /^enum\((.*)\)$/i.exec(c.COLUMN_TYPE);
|
|
1200
|
-
if (m?.[1]) {
|
|
1201
|
-
enums[`${c.TABLE_NAME}.${c.COLUMN_NAME}`] = m[1].split(',').map((s) => s
|
|
1202
|
-
.trim()
|
|
1203
|
-
.replace(/^'(.*)'$/, '$1')
|
|
1204
|
-
.replace(/''/g, "'"));
|
|
1205
|
-
}
|
|
1206
|
-
}
|
|
1661
|
+
const enumLabels = dataType === 'enum' ? parseMysqlEnum(c.COLUMN_TYPE) : undefined;
|
|
1207
1662
|
const maxLen = c.CHARACTER_MAXIMUM_LENGTH != null ? num(c.CHARACTER_MAXIMUM_LENGTH) : undefined;
|
|
1208
1663
|
// `tinyint(1)` is the one type whose DATA_TYPE is not enough to identify it
|
|
1209
1664
|
// (see MYSQL_BOOLEAN_TYPE); everything else keeps the bare DATA_TYPE.
|
|
@@ -1215,15 +1670,38 @@ async function introspectMysqlWith(exec, schema, options = {}) {
|
|
|
1215
1670
|
pgType: recordedType,
|
|
1216
1671
|
tsType: mysqlTypeToTs(dataType, nullable, c.COLUMN_TYPE),
|
|
1217
1672
|
nullable,
|
|
1218
|
-
|
|
1673
|
+
// Nullable MySQL columns have an effective DEFAULT NULL even when the
|
|
1674
|
+
// catalog cannot distinguish an explicit NULL from an implicit default.
|
|
1675
|
+
hasDefault: nullable || c.COLUMN_DEFAULT !== null || /auto_increment/i.test(c.EXTRA) || computed,
|
|
1219
1676
|
// The server numbers it, so a create's re-read can use the insert id.
|
|
1220
1677
|
isGenerated: /auto_increment/i.test(c.EXTRA),
|
|
1678
|
+
// The existing flag protects BOTH virtual and stored computed values.
|
|
1679
|
+
...(computed ? { isGeneratedStored: true } : {}),
|
|
1680
|
+
...(computed && c.GENERATION_EXPRESSION ? { generationExpression: c.GENERATION_EXPRESSION } : {}),
|
|
1221
1681
|
isArray: false,
|
|
1222
1682
|
arrayType: undefined,
|
|
1223
1683
|
pgArrayType: 'text[]',
|
|
1224
1684
|
};
|
|
1225
1685
|
if (maxLen !== undefined)
|
|
1226
1686
|
col.maxLength = maxLen;
|
|
1687
|
+
if (enumLabels !== undefined) {
|
|
1688
|
+
// Exact unless suspect (see enumLabelsSuspect). A suspect list is
|
|
1689
|
+
// withheld, never recorded from the damaged text, so no consumer can type
|
|
1690
|
+
// or validate against a label the column does not have.
|
|
1691
|
+
const key = `${c.TABLE_NAME}.${c.COLUMN_NAME}`;
|
|
1692
|
+
if (!enumLabelsSuspect(enumLabels, c.CHARACTER_SET_NAME)) {
|
|
1693
|
+
enums[key] = enumLabels;
|
|
1694
|
+
}
|
|
1695
|
+
else {
|
|
1696
|
+
col.enumLabelsUnrecoverable = true;
|
|
1697
|
+
(0, logger_js_1.logTo)(logger, 'warn', `MySQL introspection: the ENUM labels of "${key}" may hold characters outside the BMP, which the MySQL ` +
|
|
1698
|
+
'catalog reports as "?" (a label that really contains "?" reads the same), so the column is typed as ' +
|
|
1699
|
+
'string instead of a literal union. For exact literal types, declare its labels explicitly: with the ' +
|
|
1700
|
+
`CLI, a \`columnTypes\` entry in turbine.config.ts (\`columnTypes: { "${key}": "'a' | 'b'" }\`); in code, ` +
|
|
1701
|
+
`an \`enums\` entry on the introspected metadata before calling generate() (\`schema.enums["${key}"] = ` +
|
|
1702
|
+
"['a', 'b']`). The stored labels and row data are unaffected.", { code: 'introspect-enum-labels-unrecoverable', table: c.TABLE_NAME });
|
|
1703
|
+
}
|
|
1704
|
+
}
|
|
1227
1705
|
if (!columnsByTable.has(c.TABLE_NAME))
|
|
1228
1706
|
columnsByTable.set(c.TABLE_NAME, []);
|
|
1229
1707
|
columnsByTable.get(c.TABLE_NAME).push(col);
|
|
@@ -1240,15 +1718,18 @@ async function introspectMysqlWith(exec, schema, options = {}) {
|
|
|
1240
1718
|
pkByTable.get(r.TABLE_NAME).push(r.COLUMN_NAME);
|
|
1241
1719
|
}
|
|
1242
1720
|
// ----- Foreign keys (grouped by constraint for composite FKs) -----
|
|
1243
|
-
const fkRows = (await exec(`SELECT TABLE_NAME, COLUMN_NAME, REFERENCED_TABLE_NAME, REFERENCED_COLUMN_NAME, CONSTRAINT_NAME, ORDINAL_POSITION
|
|
1721
|
+
const fkRows = (await exec(`SELECT TABLE_NAME, COLUMN_NAME, REFERENCED_TABLE_SCHEMA, REFERENCED_TABLE_NAME, REFERENCED_COLUMN_NAME, CONSTRAINT_NAME, ORDINAL_POSITION
|
|
1244
1722
|
FROM information_schema.KEY_COLUMN_USAGE
|
|
1245
1723
|
WHERE TABLE_SCHEMA = :p1 AND REFERENCED_TABLE_NAME IS NOT NULL
|
|
1724
|
+
AND REFERENCED_TABLE_SCHEMA = :p1
|
|
1246
1725
|
ORDER BY CONSTRAINT_NAME, ORDINAL_POSITION`, [schema]));
|
|
1247
1726
|
const fkByConstraint = new Map();
|
|
1248
1727
|
for (const r of fkRows) {
|
|
1249
1728
|
if (!tableSet.has(r.TABLE_NAME))
|
|
1250
1729
|
continue;
|
|
1251
|
-
|
|
1730
|
+
if (r.REFERENCED_TABLE_SCHEMA !== undefined && r.REFERENCED_TABLE_SCHEMA !== schema)
|
|
1731
|
+
continue;
|
|
1732
|
+
const key = JSON.stringify([r.TABLE_NAME, r.CONSTRAINT_NAME]);
|
|
1252
1733
|
let entry = fkByConstraint.get(key);
|
|
1253
1734
|
if (!entry) {
|
|
1254
1735
|
entry = {
|
|
@@ -1265,44 +1746,70 @@ async function introspectMysqlWith(exec, schema, options = {}) {
|
|
|
1265
1746
|
}
|
|
1266
1747
|
const foreignKeys = [...fkByConstraint.values()].filter((fk) => tableSet.has(fk.targetTable));
|
|
1267
1748
|
// ----- Indexes + unique constraints -----
|
|
1268
|
-
const idxRows = (await exec(`SELECT TABLE_NAME, INDEX_NAME, NON_UNIQUE, COLUMN_NAME, SEQ_IN_INDEX
|
|
1749
|
+
const idxRows = (await exec(`SELECT TABLE_NAME, INDEX_NAME, NON_UNIQUE, COLUMN_NAME, SEQ_IN_INDEX,
|
|
1750
|
+
SUB_PART, EXPRESSION, COLLATION, INDEX_TYPE, IS_VISIBLE, INDEX_COMMENT
|
|
1751
|
+
FROM information_schema.STATISTICS
|
|
1269
1752
|
WHERE TABLE_SCHEMA = :p1 ORDER BY TABLE_NAME, INDEX_NAME, SEQ_IN_INDEX`, [schema]));
|
|
1270
1753
|
const indexGroups = new Map();
|
|
1271
1754
|
for (const r of idxRows) {
|
|
1272
1755
|
if (!tableSet.has(r.TABLE_NAME))
|
|
1273
1756
|
continue;
|
|
1274
|
-
const key =
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
indexGroups.set(key, g);
|
|
1279
|
-
}
|
|
1280
|
-
g.columns.push(r.COLUMN_NAME);
|
|
1757
|
+
const key = JSON.stringify([r.TABLE_NAME, r.INDEX_NAME]);
|
|
1758
|
+
if (!indexGroups.has(key))
|
|
1759
|
+
indexGroups.set(key, []);
|
|
1760
|
+
indexGroups.get(key).push(r);
|
|
1281
1761
|
}
|
|
1282
1762
|
const indexesByTable = new Map();
|
|
1283
1763
|
const uniqueByTable = new Map();
|
|
1284
|
-
for (const
|
|
1285
|
-
|
|
1764
|
+
for (const rows of indexGroups.values()) {
|
|
1765
|
+
rows.sort((a, b) => num(a.SEQ_IN_INDEX) - num(b.SEQ_IN_INDEX));
|
|
1766
|
+
const first = rows[0];
|
|
1767
|
+
if (first.INDEX_NAME === 'PRIMARY')
|
|
1286
1768
|
continue; // PK is tracked separately
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1769
|
+
const plain = rows.every((r) => typeof r.COLUMN_NAME === 'string' && r.EXPRESSION == null && r.SUB_PART == null);
|
|
1770
|
+
// Never publish a subset of a functional/prefix key as a complete key.
|
|
1771
|
+
const columns = plain ? rows.map((r) => r.COLUMN_NAME) : [];
|
|
1772
|
+
const unique = num(first.NON_UNIQUE) === 0;
|
|
1773
|
+
if (!indexesByTable.has(first.TABLE_NAME))
|
|
1774
|
+
indexesByTable.set(first.TABLE_NAME, []);
|
|
1775
|
+
indexesByTable.get(first.TABLE_NAME).push({
|
|
1776
|
+
name: first.INDEX_NAME,
|
|
1777
|
+
columns,
|
|
1778
|
+
unique,
|
|
1779
|
+
// Opaque, non-executable catalog facts. In particular, expressions must
|
|
1780
|
+
// never be converted into guessed migration DDL. MySQL has no partial
|
|
1781
|
+
// indexes; SUB_PART is a key prefix length, not a WHERE predicate.
|
|
1782
|
+
definition: `MySQL index metadata: ${JSON.stringify({
|
|
1783
|
+
type: first.INDEX_TYPE ?? null,
|
|
1784
|
+
visible: first.IS_VISIBLE ?? null,
|
|
1785
|
+
comment: first.INDEX_COMMENT ?? null,
|
|
1786
|
+
keys: rows.map((r) => ({
|
|
1787
|
+
column: r.COLUMN_NAME,
|
|
1788
|
+
expression: r.EXPRESSION ?? null,
|
|
1789
|
+
prefixLength: r.SUB_PART == null ? null : num(r.SUB_PART),
|
|
1790
|
+
order: r.COLLATION ?? null,
|
|
1791
|
+
})),
|
|
1792
|
+
})}`,
|
|
1294
1793
|
});
|
|
1295
|
-
if (
|
|
1296
|
-
if (!uniqueByTable.has(
|
|
1297
|
-
uniqueByTable.set(
|
|
1298
|
-
uniqueByTable.get(
|
|
1794
|
+
if (unique && columns.length > 0) {
|
|
1795
|
+
if (!uniqueByTable.has(first.TABLE_NAME))
|
|
1796
|
+
uniqueByTable.set(first.TABLE_NAME, []);
|
|
1797
|
+
uniqueByTable.get(first.TABLE_NAME).push(columns);
|
|
1299
1798
|
}
|
|
1300
1799
|
}
|
|
1301
1800
|
// ----- Relations -----
|
|
1302
1801
|
// One field per column, as the PostgreSQL introspector requires.
|
|
1303
1802
|
for (const [tableName, cols] of columnsByTable)
|
|
1304
1803
|
(0, introspect_js_1.assertDistinctColumnFields)(tableName, cols);
|
|
1305
|
-
|
|
1804
|
+
// A to-one is decided per foreign key BEFORE naming, so it is named as
|
|
1805
|
+
// PostgreSQL names it (`users.profile`): the child's columns are exactly its
|
|
1806
|
+
// primary key or a unique key, and each column pair compares the way the
|
|
1807
|
+
// enforced key does.
|
|
1808
|
+
const relationsByTable = buildRelationsFromForeignKeys(tableNames, foreignKeys, pkByTable, columnsByTable, options.logger, options.legacyToManyUniques
|
|
1809
|
+
? undefined
|
|
1810
|
+
: (fk) => fk.sourceColumns.length === fk.targetColumns.length &&
|
|
1811
|
+
fk.sourceColumns.every((name, i) => mysqlSameKeyEquality(nativeColumns.get(JSON.stringify([fk.sourceTable, name])), nativeColumns.get(JSON.stringify([fk.targetTable, fk.targetColumns[i]])))) &&
|
|
1812
|
+
[pkByTable.get(fk.sourceTable) ?? [], ...(uniqueByTable.get(fk.sourceTable) ?? [])].some((key) => key.length === fk.sourceColumns.length && key.every((name) => fk.sourceColumns.includes(name))));
|
|
1306
1813
|
// ----- Assemble TableMetadata -----
|
|
1307
1814
|
const tables = (0, introspect_js_1.nullRecord)();
|
|
1308
1815
|
for (const tableName of tableNames) {
|
|
@@ -1367,6 +1874,7 @@ async function introspectMysql(options) {
|
|
|
1367
1874
|
include: options.include,
|
|
1368
1875
|
exclude: options.exclude,
|
|
1369
1876
|
logger: options.logger,
|
|
1877
|
+
legacyToManyUniques: options.legacyToManyUniques,
|
|
1370
1878
|
});
|
|
1371
1879
|
}
|
|
1372
1880
|
finally {
|
|
@@ -1517,8 +2025,8 @@ async function turbineMysql(target, schema, options = {}) {
|
|
|
1517
2025
|
// NOTE: even on a `mysql2/promise` pool, the 'connection' event yields the
|
|
1518
2026
|
// *raw* (callback-style) connection, its `.query()` returns a non-thenable
|
|
1519
2027
|
// `Query`, so `.catch()`/`await` on it throws "result of query that is not a
|
|
1520
|
-
// promise". Use the callback form here (fire-and-forget): if the SET fails
|
|
1521
|
-
//
|
|
2028
|
+
// promise". Use the callback form here (fire-and-forget): if the SET fails,
|
|
2029
|
+
// MySQL keeps its default escaping, harmless since every value is a param.
|
|
1522
2030
|
mysql2Pool.on?.('connection', (rawConn) => {
|
|
1523
2031
|
rawConn.query("SET SESSION sql_mode = CONCAT(@@sql_mode, ',NO_BACKSLASH_ESCAPES')", () => { });
|
|
1524
2032
|
});
|