Repository navigation
Fix bugs found by end-to-end testing of v0.13.0 - #45
Merged
Merged
Conversation
…exits Co-Authored-By: Doron Eli Rachman <doron050@gmail.com>
- MySQL: a reused sqlc.arg is one keyword; repeated ? get id, id_2, ...; rows are read by position so unaliased expressions (count(*)) work; :copyfrom quotes values so "NULL" stays a string - SQLite: types with modifiers (VARCHAR(255), DECIMAL(10,2)); :exec / :execrows with RETURNING run every row - PostgreSQL: bytea with NUL / non-UTF-8 bytes (parameters and COPY), JSON array parameters, enum[] / uuid[] decoded to arrays, :execlastid without a row returns nil, prepared statements are re-prepared after PG::Connection#reset - All drivers: transactions commit on break / return / throw instead of leaking an open transaction; :copyfrom quotes identifiers; casted sqlc.narg is optional; untyped (any) expressions generate as untyped - Names: parameters / columns that collide with generated locals or row methods, or are not valid identifiers, are renamed; colliding constants / methods are reported; lowercase query names get a valid Row class - Ruby 3.1: keyword_init Structs (+ RBS), RuboCop-clean output; rubyVersion 3.4 accepted; unknown options and preparedStatements on non-pg drivers are errors; nested moduleName output is self-contained 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)".
|
…ry Ruby Co-Authored-By: Doron Eli Rachman <doron050@gmail.com>
doron050
approved these changes
Nov 3, 2026
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 19 bugs found by end-to-end testing of the published v0.13.0 WASM against real PostgreSQL 16, MySQL 8.3 and SQLite (Ruby 3.1 – 3.4).
MySQL (
mysql2)sqlc.argused twice generateddef f(term:, term:)(syntax error, the whole file failed to load): now one keyword, sent twice. Repeated?of one column becomeid:, id_2:, id_3:.SELECT count(*)) were alwaysnil: rows are now read by position (as: :array).:copyfromstored the string"NULL"as SQLNULL: values are quoted, onlynilbecomes\N. The CSV is built without thecsvgem, so the generated Gemfile no longer needs it.SQLite (
sqlite3)VARCHAR(255),DECIMAL(10,2)) aborted generation:Base#column_typestrips the modifier, and its prefix check was reversed.:exec/:execrowswithRETURNINGnever ran, or only touched the first row: the result is now drained.PostgreSQL (
pg)byteacontaining NUL or non-UTF-8 bytes failed, both as a parameter and in COPY: now encoded withPG::TextEncoder::Bytea.Arraywere sent as a PG array literal: nowPG::TextEncoder::JSON.enum[]/uuid[]columns came back as the raw"{a,b}"string: they are decoded into arrays by aPG::TypeMapByOidbuilt frompg_type.:execlastidcrashed whenRETURNINGproduced no row: it now returnsnil.PG::Connection#reset, every prepared query failed permanently: prepared state is now tracked per backend PID, so statements are prepared again.All drivers
transactionwithbreak/return/throwneither committed nor rolled back, so the pooled connection kept an open transaction. It now commits, and rolls back on an exception or a killed thread.:copyfromdidn't quote identifiers (a column namedorderbroke it): now quoted per driver.sqlc.narg(x)::textbecame a required keyword: it now defaults tonil, as the README says.any, e.g.coalesce(max(n), 0)) aborted generation: it is nowuntyped. Type errors also name the query.client,sql, ...) are renamed (client_:).hash) are renamed (hash_), and columns that aren't valid identifiers are snake_cased....Rowclass.keyword_initStructs (Row.new(name: ...)used to put the whole hash into the first field), RBS uses::Struct[untyped]with keywordinitialize/self.new, and long row constructors wrap, so the output is RuboCop-clean.moduleName(MyApp::Db) is emitted as nestedmoduleblocks, so the files load withoutMyAppbeing defined first.rubyVersion: "3.4"is accepted. Unknown option keys, andpreparedStatementswith a driver other thanpg, are now errors instead of being silently ignored.Tests
regressionstable and queries toexamples/authors/{postgresql,mysql,sqlite};examples/and thetest/fixtures/*.bincaptures are regenerated from them.tests/end2end_{pg,mysql2,sqlite3}.rbcover each runtime bug.test/features_test.rbcover the generation bugs.test/options_test.rbis updated for 3.4.steep_expectations.ymlare regenerated; the new expected diagnostics are thePG::constants used by the array decoder.Docs (README options table and semantics,
docs/Design.md,CLAUDE.md) now say Ruby 3.1–3.4 and describe the new validation and naming rules.Local results:
rake test: 62 runs, 0 failuresexamples/: cleanscripts/tests/run_codegen.rbpasses on Ruby 3.1 and 3.4Worth reviewing:
pgconnection setup now runs onepg_typequery, to build the array decoder.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)feature,bug,breaking,documentation) so the release notes are grouped correctly