Skip to content

Fix MySQL :copyfrom into mixed-case tables; ArgumentError for unknown isolation:; doc gaps - #57

Merged
devin-ai-integration[bot] merged 2 commits into
mainfrom
devin/1793759282-mysql-copyfrom-case
Nov 4, 2026
Merged

devin-ai-integration[bot] merged 2 commits into
mainfrom
devin/1793759282-mysql-copyfrom-case

Conversation

@devin-ai-integration

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

Copy link
Copy Markdown
Contributor

Summary

MySQL :copyfrom into a table whose name has uppercase letters failed. sqlc lowercases MySQL identifiers, so for INSERT INTO `MixedCaseCopies` … the generated LOAD DATA named `mixedcasecopies`. On Linux MySQL, with the default lower_case_table_names=0, table names are case-sensitive, so the call raised Mysql2::Error: Table '…mixedcasecopies' doesn't exist. Other queries on the same table already worked, because they use the SQL text as written.

  • Fix: :copyfrom gets its table and column names from a new driver hook, copy_target. The default in drivers/base.rb quotes sqlc's names, as before. drivers/mysql2.rb overrides it to take the target table (optionally schema.table) and the column list as the INSERT writes them, quoted or unquoted. It falls back to the old behavior if the text cannot be matched.
  • SQLite fix found by the same test: sqlc 1.27 (the pinned version) reports a quoted SQLite table name with its quotes, so the generated INSERT named """MixedCaseCopies""". drivers/sqlite3.rb overrides copy_target to strip the quotes from sqlc's names ("…", `…`, […]) and then quote each name once.
  • Test: test_copyfrom_keeps_the_case_of_table_and_column_names uses a new MixedCaseCopies table in the example schemas of all three engines. The MySQL test covers both backtick-quoted names and unquoted names in a different column order. On main the MySQL test fails with the error above, and the SQLite test fails with no such table when the code is generated with sqlc 1.27.

Smaller items from the same pre-release check:

  • Unknown isolation: values (pg, mysql2) now raise ArgumentError("unknown isolation level: …") before a connection is checked out. Before, they raised KeyError from ISOLATION_LEVELS.fetch. SQLite's mode: already raised ArgumentError. The existing isolation E2E tests now expect ArgumentError; on main they fail with KeyError.
  • README:
    • Steep needs library "timeout" for code generated with a rubyVersion below 3.3.
    • Struct rows (rubyVersion below 3.2) rename more members than Data rows, for example count → count_.
    • SQLite's 32,766-parameter limit applies to sqlc.slice.
    • MySQL LOAD DATA keeps the table and column names as written.
  • lib/sqlc_gen_ruby/code.rb: removed a duplicated range in a character class, which ruby -w warned about.
  • Regenerated examples/, test/golden, test/fixtures/*.bin and steep_expectations.yml. docs/Coverage.md lists the new test.

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

… with ArgumentError; document Steep timeout, Struct member names and the SQLite slice limit

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 4, 2026
…uotes

Co-Authored-By: Doron Eli Rachman <doron050@gmail.com>
@devin-ai-integration
devin-ai-integration Bot merged commit 8d1fc8b into main Nov 4, 2026
41 checks passed
@devin-ai-integration
devin-ai-integration Bot deleted the devin/1793759282-mysql-copyfrom-case branch November 4, 2026 02:44
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