Repository navigation
Fix bugs found by the pre-release sweep, update docs - #46
Merged
Merged
Conversation
- pg: :batch* commands encode bytea / json / string-array parameters like the other commands - pg: a transaction whose failed statement was rescued raises PG::InFailedSqlTransaction instead of returning - mysql2: :copyfrom is binary-safe (CHARACTER SET binary), atomic, and raises on duplicate keys / invalid values - sqlite3: :copyfrom runs in a savepoint (all rows or none); one lock per database for threads / fibers; unknown transaction modes raise ArgumentError; JSON / JSONB / UUID declarations are Strings - db_type overrides also type array elements; unknown override keys are rejected - schema names breaking Naming cops get a rubocop:disable / enable pair where they occur - WASM: stub syntax_suggest/core_ext so errors are not prefixed by a load warning - clearer rubyVersion bound errors Co-Authored-By: Doron Eli Rachman <doron050@gmail.com>
- README: quick start, one options table, sections for the generated code, transactions, types, names and limitations - docs: current hooks, commands and files; :copyfrom atomicity, encoded batch params, SQLite locking, WASM stub - labels match the repository (enhancement, not feature) Co-Authored-By: Doron Eli Rachman <doron050@gmail.com>
Contributor
Author
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
Co-Authored-By: Doron Eli Rachman <doron050@gmail.com>
doron050
approved these changes
Nov 3, 2026
4 tasks done
doron050
added a commit
that referenced
this pull request
Nov 3, 2026
## Summary Fixes the bugs found by the final pre-release sweep of 7e813b7, with an end-to-end test for each. - **MySQL `:copyfrom` into JSON columns** (regression from #46): `LOAD DATA ... CHARACTER SET binary` can't create JSON values. JSON columns now load into `@sqlc_vN` with `SET col = CONVERT(@sqlc_vN USING utf8mb4)`. - **PostgreSQL `:copyfrom` with booleans**: the default binary boolean encoder sent invalid COPY text. Booleans now use `PG::TextEncoder::Boolean`. - **PostgreSQL nested `transaction` rescuing a failed statement**: this used to poison the outer transaction. Now only the savepoint is rolled back, `PG::InFailedSqlTransaction` is raised, and the outer block can rescue it and continue. - **PostgreSQL array parameters**: covers `bytea[]` (binary/NUL), `jsonb[]` (Hash elements), `[]` and leading `nil`, and `preparedStatements: false`. These are now sent as array literals (`encode_array`). Floats are sent as exact text (`Float#to_s`). - **`:copyfrom` conflict clauses**: SQLite keeps `INSERT OR REPLACE` / `OR IGNORE` / `ON CONFLICT ... DO ...`. MySQL maps `INSERT IGNORE` and `REPLACE` to `LOAD DATA ... IGNORE|REPLACE INTO TABLE`. Clauses COPY / LOAD DATA can't express are generation errors: `ON CONFLICT` / `RETURNING` on PostgreSQL, `ON DUPLICATE KEY UPDATE` on MySQL. - **Names**: `snake_case` keeps acronyms together (`MIN_ID` → `min_id`, not `m_i_n_i_d`). RuboCop exemptions are emitted only where a name offends, including `Naming/VariableNumber` for repeated parameters (`id_2`). - **mysql2 batches** prepare a statement per row, because reusing one statement broke binary/unsigned values. - **Dead connections**: pg resets a `CONNECTION_BAD` connection on checkout. mysql2 discards a closed connection from the pool. - **Nested `transaction(isolation:)` / `transaction(mode:)`** now raise `ArgumentError` instead of being silently ignored. Drivers get the parsed verb/tail through `copy_from_lines(..., query_name:, sources:, verb:, tail:)` and a `prepares_batch_rows?` hook. New example tables back the e2e tests: `batch_types` (pg), `copy_types` (mysql), `tags` (sqlite). README documents the new behaviour and limitations. ### Behaviour changes (release notes) - A nested `transaction` with `isolation:` / `mode:` raises `ArgumentError`. - A `:copyfrom` query with `ON CONFLICT` / `RETURNING` (PostgreSQL) or `ON DUPLICATE KEY UPDATE` (MySQL) is rejected at generation time. ### Verified locally - `rake test`: Ruby 3.1–3.4. - RuboCop and Steep: clean. Steep expectations were refreshed; only line shifts and new `PG`/`Mysql2` constant references changed. - `sqlc diff`: clean through both the newly built `dist/plugin.wasm` and `exe/plugin.rb`. - E2E on Ruby 3.2–3.4, against PostgreSQL 16, MySQL 8.3 and SQLite. - Randomized round-trip tests (insert/select, batch, copyfrom) on Ruby 3.1–3.4. They include binary `bytea[]`, `jsonb[]`, `Float::MAX` and `5e-324`. ## Checklist - [x] `examples/` is regenerated (`rake sqlc_generate_process`) and committed - [x] Tests added or updated (`rake test`, and `rake end2end_*` when the generated code changes) - [x] The generated code stays RuboCop-clean (`rake rubocop`) and Steep-clean (`rake steep`) - [x] Labelled (`bug`, `enhancement`, `documentation`, or `breaking`) so the release notes are grouped correctly Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Doron Eli Rachman <doron050@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the bugs found by a pre-release sweep of
main(real PostgreSQL 16 / MySQL 8.3 / SQLite apps on Ruby 3.1–3.4), and brings the docs up to date.Fixes
:batchexec/:batchone/:batchmanynow encode parameters like every other command (Driver#encode_param), sobytea,jsonand arrays work. Before:string contains null byte/ type errors.ROLLBACK, silently). It now raisesPG::InFailedSqlTransaction.:copyfrom: binary-safe (CHARACTER SET binary), all-or-nothing (transaction, or savepoint inside one), andLOAD DATA LOCALwarnings (skipped duplicate keys, coerced invalid values) raiseMysql2::Error.:copyfromruns in a savepoint: a failing row no longer leaves earlier batches committed.SQLite3::Databasetake turns (one reentrant lock per database, in the newconnection.rb) instead of breaking each other's savepoints. Unknownmode:values raiseArgumentErrorinstead of producing invalid SQL.JSON/JSONB/UUIDcolumns areString(wereFloat); adb_typeoverride now types the elements of arrays of that type (uuid[]→Array[String]) instead of replacing the array type."UserId", two-letter or non-ASCII parameters) get arubocop:disable/enablepair around only the class or method using them.syntax_suggest/core_ext.rbstub, so plugin errors are no longer prefixed by "`syntax_suggest' was not loaded".rubyVersionrange errors.Behaviour changes worth a release note: pg code that swallowed a failed statement inside
transactionnow raises; MySQL loads that skipped duplicates now fail; users running Steep on generated SQLite code needlibrary "monitor".Docs: README reorganised (quick start, one options table, transactions / types / names / limitations sections) without dropping content; Design / Architecture / Testing / Releasing, CLAUDE.md and the PR template updated to the current code (new commands and hooks, stale limitations removed, labels matching the repo).
Tests: unit tests for each generator change; new E2E tests for batch encoding, the rescued pg statement, MySQL binary / duplicate / invalid / nested
:copyfrom, SQLite copy atomicity, thread-shared transactions and invalid modes.examples/, golden files, request fixtures and Steep expectations regenerated. Locally (Ruby 3.3):rake test85 runs, RuboCop and Steep clean,sqlc diffclean with the rebuilt WASM, E2E SQLite 35 / PostgreSQL 49 / MySQL 41 runs green.Checklist
examples/is regenerated (rake sqlc_generate_process) and committedrake test, andrake end2end_*when the generated code changes)rake rubocop) and Steep-clean (rake steep)bug,enhancement,documentation, orbreaking) so the release notes are grouped correctly