Skip to content

Fix bugs found by the independent pre-release check; E2E on every supported Ruby - #49

Merged
doron050 merged 9 commits into
mainfrom
devin/1793729686-sweep-fixes
Nov 3, 2026
Merged

doron050 merged 9 commits into
mainfrom
devin/1793729686-sweep-fixes

Conversation

@devin-ai-integration

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

Copy link
Copy Markdown
Contributor

Summary

Fixes for the issues found by an independent pre-release check of main (7194e3b) against real PostgreSQL 16, MySQL 8.4 and SQLite on Ruby 3.1–4.0. Each fix comes with E2E coverage that fails on main.

Fixes

  • Timeout inside transaction committed the partial work on Ruby 3.1/3.2 (all drivers). timeout < 0.4 exits the block with throw, which transaction treated as success.
    • For rubyVersion < 3.3, the generated transaction now records normal completion. If the block exits without completing or raising while the loaded timeout is < 0.4 (timeout_exits_with_throw?), it rolls back.
    • The generated Gemfile adds gem 'timeout', '>= 0.4'.
    • Output for rubyVersion >= 3.3 is unchanged.
  • SQLite numbered parameters were bound in the wrong order. sqlc writes sqlc.arg as ?N on SQLite, but the generated code bound params positionally.
    • sqlc.slice followed by a named arg raised RangeException.
    • Mixing repeated sqlc.arg with ? silently returned wrong rows. This also affected :batch*.
    • The sqlite3 driver now scans the SQL, skipping literals and comments, and rewrites ?N to ?. It binds params in occurrence order, repeating values when a param appears more than once.
  • pg: json/jsonb parameters true/false failed. encode_json now JSON-encodes booleans as well as Arrays.
  • Query names Raise/Rand/Format shadowed Kernel methods the generated class calls. They are now generation errors (Code::KERNEL_METHODS). A unit test scans the generated examples and golden files for unreserved bare Kernel calls.
  • Keyword order. Required keywords now come before optional ones (def m(lim:, name_filter: nil)), so generated code stays RuboCop-clean (Style/KeywordParametersOrder). Binding order is unchanged.
  • README.
    • The fiber-scheduler claim now says mysql2 prepared statements block the scheduler; use threads.
    • The Transactions section documents the timeout behaviour and when parent-object calls reuse the transaction's connection.

Test coverage

  • E2E now runs on Ruby 3.1, 3.2, 3.3, 3.4 and 4.0 for all three engines.
    • On 3.1/3.2, scripts/tests/generate_examples.rb regenerates the examples for that rubyVersion (Struct rows) into a scratch dir (EXAMPLES_DIR), and the jobs install from Gemfile.e2e.
    • The tests build rows with keywords, so they work for both Data and Struct.
  • New E2E cases:
    • transactions: Timeout during a DB call and during Ruby code; break/return/throw semantics; Thread#kill; nested savepoint rollback; parent-object calls inside a transaction
    • pg: deferred FK failing at COMMIT, terminated backend
    • mysql2: KILLed connection
    • JSON value types
    • SQLite mixed placeholders (direct and :batchone)
    • named :copyfrom
    • generated-method concurrency (pg under Sync, mysql2 across threads)
    • seeded randomized :copyfrom, batch and concurrent-transaction plans
  • New examples queries cover the cases above. Fixtures were recaptured (scripts/tests/capture_fixtures.rb) and goldens updated.

Follow-up in this PR: mysql2 Fiber concurrency and full E2E coverage

  • mysql2 queries now run concurrently under Sync.
    • The mysql2 driver now quotes parameters client-side (quote, using Mysql2::Client#escape; hex literals for binary strings; unsupported types raise TypeError). This is the same approach as ActiveRecord's mysql2 adapter.
    • It binds them with a literal- and comment-aware bind_params and sends one Client#query. There are no server-side prepared statements anymore.
    • E2E tests cover the concurrency (generated methods under Sync), quoting and injection, and the absence of prepared statements.
  • E2E coverage of every documented feature. docs/Coverage.md maps each README claim to the E2E test(s) per engine. A unit test fails if a referenced test does not exist.
  • New CI jobs.
    • Option-variant E2E jobs: moduleName: MyApp::Db for all engines, plus pg preparedStatements: false running the whole pg suite.
    • tests/end2end_options.rb (rename, exactTableNames, overrides, global options, several query files, generateTypes: false, generated-Gemfile-only load).
    • The 3.1/3.2 jobs install from the generated Gemfiles.
  • New checks inside the suites.
    • Automatic runtime RBS checks of every value returned by generated methods.
    • Row frozen / pattern-matching assertions.
    • More types and engine-specific gaps: isolation actually applied, SQLite lock modes, logger, enums, names, outer-join embeds, batch non-atomicity.
  • Testing policy in CLAUDE.md and docs/Testing.md: every supported feature needs an E2E test per engine (listed in docs/Coverage.md); bug fixes start with a failing E2E test; unit tests only where E2E cannot reach.

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

devin-ai-integration Bot and others added 2 commits November 3, 2026 19:00
Co-Authored-By: Doron Eli Rachman <doron050@gmail.com>
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
devin-ai-integration Bot and others added 5 commits November 3, 2026 20:26
Co-Authored-By: Doron Eli Rachman <doron050@gmail.com>
Co-Authored-By: Doron Eli Rachman <doron050@gmail.com>
Co-Authored-By: Doron Eli Rachman <doron050@gmail.com>
Co-Authored-By: Doron Eli Rachman <doron050@gmail.com>
Co-Authored-By: Doron Eli Rachman <doron050@gmail.com>
@devin-ai-integration devin-ai-integration Bot added the enhancement New feature or request label Nov 3, 2026
devin-ai-integration Bot and others added 2 commits November 3, 2026 21:09
Co-Authored-By: Doron Eli Rachman <doron050@gmail.com>
Co-Authored-By: Doron Eli Rachman <doron050@gmail.com>
@doron050
doron050 merged commit b66aab5 into main Nov 3, 2026
33 checks passed
@doron050
doron050 deleted the devin/1793729686-sweep-fixes branch November 3, 2026 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant