Skip to content

Fix bugs found by the second pre-release check - #51

Merged
doron050 merged 1 commit into
mainfrom
devin/1793742867-prerelease-fixes
Nov 3, 2026
Merged

doron050 merged 1 commit into
mainfrom
devin/1793742867-prerelease-fixes

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes the bugs found by an independent pre-release check of main. Each fix comes with an E2E test that fails without it.

  • pg: modules sharing a connection ran each other's statements. Prepared statement names were <file>_<query>. Two generated modules with the same query file name and the same query name used one server-side statement, so the second module silently ran the first module's SQL. Names now include the module (pg_codegen_query_sql_get_author).
  • pg: unnamed result columns were always nil. SELECT 1, now() read row['']. Rows with an unnamed column are now read by position, and the column gets a position name: column_1, column_2, ... Before, two such columns failed generation with duplicate column names ... _ on every engine. A single one was named _ (it worked on mysql2/sqlite3, was nil on pg); that member is now column_N.
  • pg: an alias containing ' (AS "it's") generated invalid Ruby. Column names are now written as escaped string literals (Code.string_literal).
  • pg: top-level Float json/jsonb parameters lost precision. 0.3304 was stored as 0.3304000000000001, also through :copyfrom and batches. encode_json now sends Float#to_s.
  • pg: a query abandoned by Timeout kept the connection busy. The next caller on that connection waited for the server to finish the statement. with_client and the rescue in transaction now cancel a statement that is still running.
  • mysql2 / sqlite3: when the database already ended the transaction, the real error was lost. This covers an InnoDB deadlock in a nested transaction, and SQLite ON CONFLICT ROLLBACK / INSERT OR ROLLBACK. The caller got SAVEPOINT ... does not exist / cannot rollback - no transaction is active instead of the deadlock / ConstraintException.
  • mysql2 / sqlite3: NOT IN (sqlc.slice(ids)) with [] matched nothing. The empty slice was rendered as NULL. It is now rendered as SELECT NULL WHERE FALSE, so IN matches nothing and NOT IN matches every row.
  • mysql2: Symbol parameters raised TypeError. They are now bound as their name, as pg already does.

New tests: examples/authors/*/query.sql gained GetUnnamedColumns, GetQuotedAlias, GetAuthorsNotInIds and (sqlite) CreateAuthorOrRollback. There are new tests in tests/end2end_{pg,mysql2,sqlite3}.rb. tests/options now has two prepared-statement pg modules on one pool. docs/Coverage.md and the README are updated. steep_expectations.yml was refreshed: line shifts plus 4 new UnknownConstant warnings for PG / Mysql2.

Verified locally:

  • rake test, rubocop, steep and sqlc diff are all green.
  • The plugin unit tests pass on Ruby 3.1 without bundler.
  • E2E pg / mysql2 / sqlite3 / options pass on Ruby 3.1.7, 3.2.11, 3.3.13, 3.4.12 and 4.0.9, against PostgreSQL 16 and MySQL 8.4.

Checklist

  • examples/ is regenerated (rake sqlc_generate_process) and committed
  • Tests added or updated (rake test, and rake end2end_* when the generated code changes)
  • The generated code stays RuboCop-clean (rake rubocop) and Steep-clean (rake steep)
  • Labelled (bug, enhancement, documentation, or breaking) so the release notes are grouped correctly

- pg: prepared statement names include the module, so modules sharing a connection no longer run each other's SQL
- pg: unnamed result columns (SELECT 1, now()) are read by position and named column_1, column_2, ...
  (also on mysql2/sqlite3, where two of them failed generation)
- pg: aliases with a quote no longer generate invalid Ruby
- pg: top-level Float json/jsonb parameters keep their exact value
- pg: a query abandoned by Timeout / Thread#raise is cancelled before the connection is reused
- mysql2/sqlite3: a transaction already ended by the database (deadlock, ON CONFLICT ROLLBACK) raises the
  original error instead of the failed ROLLBACK's
- mysql2/sqlite3: NOT IN (sqlc.slice(ids)) with [] matches every row
- mysql2: Symbol parameters are bound as their name

Co-Authored-By: Doron Eli Rachman <doron050@gmail.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration devin-ai-integration Bot added the bug Something isn't working label Nov 3, 2026
@doron050
doron050 merged commit c77b2de into main Nov 3, 2026
33 checks passed
@doron050
doron050 deleted the devin/1793742867-prerelease-fixes branch November 3, 2026 22:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant