Skip to content

Commit 8d1fc8b

Browse files
Fix MySQL :copyfrom into mixed-case tables; ArgumentError for unknown isolation:; doc gaps (#57)
## 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 - [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>
1 parent 65c6a45 commit 8d1fc8b

75 files changed

Lines changed: 1196 additions & 135 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎README.md‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ end
134134
transaction is over. Other query objects (the parent `queries`, another generated class sharing the pool) used from
135135
another fiber or thread check out their own connection and run outside the transaction: pass `tx` instead.
136136
* `isolation:` (`pg`, `mysql2`) takes `:read_uncommitted`, `:read_committed`, `:repeatable_read`, `:serializable`;
137-
`mode:` (`sqlite3`) takes `:deferred`, `:immediate`, `:exclusive`. Other values raise before anything runs, and so
137+
`mode:` (`sqlite3`) takes `:deferred`, `:immediate`, `:exclusive`. Other values raise `ArgumentError` before anything runs, and so
138138
do `isolation:` / `mode:` on a nested `transaction` (a savepoint cannot change them).
139139
* PostgreSQL: if a statement fails and the block rescues the error, PostgreSQL still rolls the whole transaction
140140
back, so `transaction` raises `PG::InFailedSqlTransaction` instead of pretending it committed. In a nested
@@ -166,6 +166,8 @@ server; duplicate keys and invalid values raise `Mysql2::Error` instead of being
166166
`INSERT OR REPLACE` / `OR IGNORE` / `ON CONFLICT ... DO ...` on SQLite, `INSERT IGNORE` (duplicates skipped) and
167167
`REPLACE` on MySQL. Clauses `COPY` / `LOAD DATA` cannot express (`ON CONFLICT` / `RETURNING` on PostgreSQL,
168168
`ON DUPLICATE KEY UPDATE` on MySQL) are generation errors; use `:batchexec` for those.
169+
* MySQL: `LOAD DATA` names the table and columns as the `INSERT` writes them (`` `MixedCase` ``): sqlc reports MySQL
170+
names in lowercase, but table names are case-sensitive on Linux.
169171
* MySQL: `LOAD DATA` commits an open transaction that was started with raw SQL (`BEGIN`); call `:copyfrom` inside
170172
`transaction` instead.
171173

@@ -195,14 +197,17 @@ server; duplicate keys and invalid values raise `Mysql2::Error` instead of being
195197
* SQLite follows its [type affinity rules](https://www.sqlite.org/datatype3.html#determination_of_column_affinity)
196198
(`VARCHAR(255)` → `String`, `DECIMAL(10,5)` → `Float`, `UNSIGNED BIG INT` → `Integer`); `JSON` and `UUID` columns are `String`s,
197199
also when SQLite stored numeric-looking text as a number (`'42'` → `"42"`, in SQLite's spelling: `'1.50'` → `"1.5"`).
198-
The generated SQLite code uses `Monitor`: if you run Steep, add `library "monitor"` to your `Steepfile`.
200+
The generated SQLite code uses `Monitor`: if you run Steep, add `library "monitor"` to your `Steepfile`. Code
201+
generated for a `rubyVersion` below 3.3 also uses `Timeout` (see [Transactions](#transactions)): add `library "timeout"` too.
199202

200203
### Names
201204
* Query methods and keyword arguments are snake_cased, with acronyms kept together (`MIN_ID` → `min_id`,
202205
`HTTPServer` → `http_server`); Ruby keywords get a trailing `_` (`end_:`). Row members use the column spelling
203206
reported by sqlc for the engine, except names that conflict with row methods, including the private ones `Data` / `Struct` call while building and copying rows (`class_`, `hash_`, `initialize_`):
204207
PostgreSQL and SQLite keep `"camelCase"` as `:camelCase`, while MySQL reports it as `:camelcase`. A column named
205-
`end` is the row member `:end` but the argument `end_:`.
208+
`end` is the row member `:end` but the argument `end_:`. `Struct` rows (`rubyVersion` below 3.2) have more methods
209+
than `Data` rows, so more names get the `_`: a column `count` is `:count` from 3.2 but `:count_` below
210+
(`Struct#count` would otherwise be `Enumerable#count`); check the generated `.rbs` when changing `rubyVersion`.
206211
* A parameter used twice is one keyword when named with `sqlc.arg`; repeated `?` / `$n` of one column become `id:`, `id_2:`.
207212
* Models may be named like Ruby or driver constants (tables `exceptions`, `data`, `threads`, `sets`, ...): the
208213
generated code and `.rbs` refer to those as `::Exception`, `::Data`, `::Thread`, ... so the models cannot shadow them.
@@ -212,6 +217,9 @@ server; duplicate keys and invalid values raise `Mysql2::Error` instead of being
212217
### Limitations
213218
* Two result columns with the same name (e.g. `a.id, b.id`) are an error: alias one (`b.id AS book_id`) or use `sqlc.embed`.
214219
* SQLite's `NUMERIC` affinity can return an `Integer` where `Float` is declared.
220+
* SQLite: a statement takes at most 32,766 parameters (`SQLITE_MAX_VARIABLE_NUMBER`), so a `sqlc.slice` with more
221+
elements raises `SQLite3::SQLException: too many SQL variables`; on MySQL the limit is the server's
222+
`max_allowed_packet`. Load larger sets into a table (`:copyfrom`) and join it instead.
215223
* `:batchexec` / `:batchone` / `:batchmany` are not atomic on their own: wrap them in `transaction` for all-or-nothing.
216224
* SQLite: sqlc does not see parameters in `ON CONFLICT ... DO UPDATE SET` (it leaves `sqlc.arg(...)` in the SQL or
217225
reports fewer parameters than there are `?`), so such queries are generation errors. Use `excluded.<column>`

‎docs/Coverage.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ only when the behavior is rejected or decided during generation and generated co
2424
| Names: keywords, method collisions (also private row hooks such as `initialize`), acronyms, quoted mixed case, repeated `$n`, plural models | [`test_keyword_and_method_names_keep_distinct_row_and_argument_names`](../tests/end2end_pg.rb#test_keyword_and_method_names_keep_distinct_row_and_argument_names), [`test_repeated_column_parameters_get_distinct_names`](../tests/end2end_pg.rb#test_repeated_column_parameters_get_distinct_names) | [`test_keyword_and_method_names_keep_distinct_row_and_argument_names`](../tests/end2end_mysql2.rb#test_keyword_and_method_names_keep_distinct_row_and_argument_names), [`test_repeated_positional_parameters_get_distinct_names`](../tests/end2end_mysql2.rb#test_repeated_positional_parameters_get_distinct_names) | [`test_keyword_and_method_names_keep_distinct_row_and_argument_names`](../tests/end2end_sqlite3.rb#test_keyword_and_method_names_keep_distinct_row_and_argument_names) | [`test_snake_case_keeps_acronyms_together`](../test/features_test.rb#test_snake_case_keeps_acronyms_together), [`test_query_names_cannot_replace_generated_methods`](../test/features_test.rb#test_query_names_cannot_replace_generated_methods), [`test_tables_with_the_same_singular_get_distinct_models`](../test/features_test.rb#test_tables_with_the_same_singular_get_distinct_models), [`test_columns_named_like_row_methods_still_build_and_read_rows`](../test/features_test.rb#test_columns_named_like_row_methods_still_build_and_read_rows) |
2525
| Connections, injected pools, reconnect behavior and SQLite serialization | [`test_queries_can_share_an_injected_pool`](../tests/end2end_pg.rb#test_queries_can_share_an_injected_pool), [`test_a_connection_closed_by_the_server_is_reconnected`](../tests/end2end_pg.rb#test_a_connection_closed_by_the_server_is_reconnected), [`test_connection_lost_inside_transaction_is_not_reconnected_until_the_transaction_ends`](../tests/end2end_pg.rb#test_connection_lost_inside_transaction_is_not_reconnected_until_the_transaction_ends) | [`test_queries_can_share_an_injected_pool`](../tests/end2end_mysql2.rb#test_queries_can_share_an_injected_pool), [`test_a_connection_closed_by_the_server_is_replaced`](../tests/end2end_mysql2.rb#test_a_connection_closed_by_the_server_is_replaced), [`test_a_stopped_async_task_does_not_leave_a_closed_connection_in_the_pool`](../tests/end2end_mysql2.rb#test_a_stopped_async_task_does_not_leave_a_closed_connection_in_the_pool) | [`test_fibers_sharing_a_database_take_turns`](../tests/end2end_sqlite3.rb#test_fibers_sharing_a_database_take_turns), [`test_threads_sharing_a_database_take_turns_in_transactions`](../tests/end2end_sqlite3.rb#test_threads_sharing_a_database_take_turns_in_transactions), [`test_a_database_returning_hash_rows_still_builds_rows`](../tests/end2end_sqlite3.rb#test_a_database_returning_hash_rows_still_builds_rows) | [`test_engine_must_match_the_driver`](../test/features_test.rb#test_engine_must_match_the_driver) |
2626
| Transaction result, commit/rollback, nested savepoint, exit semantics and rescued PostgreSQL error | [`test_nested_savepoint_rolls_back_while_outer_transaction_commits`](../tests/end2end_pg.rb#test_nested_savepoint_rolls_back_while_outer_transaction_commits), [`test_transaction_nonlocal_exit_semantics_follow_timeout_version`](../tests/end2end_pg.rb#test_transaction_nonlocal_exit_semantics_follow_timeout_version), [`test_transaction_whose_failed_statement_was_rescued_raises_instead_of_committing`](../tests/end2end_pg.rb#test_transaction_whose_failed_statement_was_rescued_raises_instead_of_committing) | [`test_nested_savepoint_rolls_back_while_outer_transaction_commits`](../tests/end2end_mysql2.rb#test_nested_savepoint_rolls_back_while_outer_transaction_commits), [`test_transaction_nonlocal_exit_semantics_follow_timeout_version`](../tests/end2end_mysql2.rb#test_transaction_nonlocal_exit_semantics_follow_timeout_version) | [`test_nested_transaction_rolls_back_to_a_savepoint`](../tests/end2end_sqlite3.rb#test_nested_transaction_rolls_back_to_a_savepoint), [`test_transaction_nonlocal_exit_semantics_follow_timeout_version`](../tests/end2end_sqlite3.rb#test_transaction_nonlocal_exit_semantics_follow_timeout_version) | [`test_nested_transactions_reject_isolation_and_mode`](../test/features_test.rb#test_nested_transactions_reject_isolation_and_mode) |
27-
| Isolation applied; invalid isolation/mode rejected before begin; SQLite locks | [`test_transaction_isolation_level`](../tests/end2end_pg.rb#test_transaction_isolation_level) | [`test_transaction_isolation_level_is_applied`](../tests/end2end_mysql2.rb#test_transaction_isolation_level_is_applied) | [`test_transaction_mode`](../tests/end2end_sqlite3.rb#test_transaction_mode), [`test_immediate_and_exclusive_transactions_block_a_second_connection`](../tests/end2end_sqlite3.rb#test_immediate_and_exclusive_transactions_block_a_second_connection), [`test_unknown_transaction_mode_is_rejected_before_beginning`](../tests/end2end_sqlite3.rb#test_unknown_transaction_mode_is_rejected_before_beginning) | [`test_nested_transactions_reject_isolation_and_mode`](../test/features_test.rb#test_nested_transactions_reject_isolation_and_mode) |
27+
| Isolation applied; invalid isolation/mode rejected with `ArgumentError` before begin; SQLite locks | [`test_transaction_isolation_level`](../tests/end2end_pg.rb#test_transaction_isolation_level) | [`test_transaction_isolation_level_is_applied`](../tests/end2end_mysql2.rb#test_transaction_isolation_level_is_applied) | [`test_transaction_mode`](../tests/end2end_sqlite3.rb#test_transaction_mode), [`test_immediate_and_exclusive_transactions_block_a_second_connection`](../tests/end2end_sqlite3.rb#test_immediate_and_exclusive_transactions_block_a_second_connection), [`test_unknown_transaction_mode_is_rejected_before_beginning`](../tests/end2end_sqlite3.rb#test_unknown_transaction_mode_is_rejected_before_beginning) | [`test_nested_transactions_reject_isolation_and_mode`](../test/features_test.rb#test_nested_transactions_reject_isolation_and_mode) |
2828
| Logger debug format, transaction logs, secret-free parameters | [`test_logger_receives_query_names_and_durations`](../tests/end2end_pg.rb#test_logger_receives_query_names_and_durations) | [`test_logger_receives_query_names_and_durations`](../tests/end2end_mysql2.rb#test_logger_receives_query_names_and_durations) | [`test_logger_receives_query_names_and_durations`](../tests/end2end_sqlite3.rb#test_logger_receives_query_names_and_durations) | [`test_logger_support`](../test/features_test.rb#test_logger_support) |
2929
| Fiber scheduler concurrency / MySQL no prepared-statement leaks | [`test_queries_run_concurrently_under_the_fiber_scheduler`](../tests/end2end_pg.rb#test_queries_run_concurrently_under_the_fiber_scheduler) | [`test_generated_queries_overlap_under_sync_including_transactions`](../tests/end2end_mysql2.rb#test_generated_queries_overlap_under_sync_including_transactions), [`test_generated_queries_do_not_create_server_side_prepared_statements`](../tests/end2end_mysql2.rb#test_generated_queries_do_not_create_server_side_prepared_statements) | [`test_fibers_sharing_a_database_take_turns`](../tests/end2end_sqlite3.rb#test_fibers_sharing_a_database_take_turns) | |
3030
| Duplicate result columns, unsupported options, invalid `:copyfrom` clauses and generation errors | E2E cannot reach generation-time rejection | E2E cannot reach generation-time rejection | E2E cannot reach generation-time rejection | [`test_duplicate_result_columns_are_rejected`](../test/features_test.rb#test_duplicate_result_columns_are_rejected), [`test_copyfrom_keeps_or_rejects_conflict_clauses`](../test/features_test.rb#test_copyfrom_keeps_or_rejects_conflict_clauses), [`test_unknown_options_are_rejected_with_a_hint`](../test/options_test.rb#test_unknown_options_are_rejected_with_a_hint), [`test_query_names_cannot_replace_generated_methods`](../test/features_test.rb#test_query_names_cannot_replace_generated_methods) |
@@ -43,6 +43,7 @@ CI runs `test/coverage_map_test.rb`, which checks every linked test method exist
4343
| Interrupts at `BEGIN` / `COMMIT` (`Thread#raise`, raised by the statement) roll back and leave no open transaction | [`test_interrupts_around_begin_and_commit_never_leave_the_connection_in_a_transaction`](../tests/end2end_pg.rb#test_interrupts_around_begin_and_commit_never_leave_the_connection_in_a_transaction) | [`test_interrupts_around_begin_and_commit_never_leave_the_connection_in_a_transaction`](../tests/end2end_mysql2.rb#test_interrupts_around_begin_and_commit_never_leave_the_connection_in_a_transaction) | [`test_interrupts_around_begin_and_commit_never_leave_the_database_in_a_transaction`](../tests/end2end_sqlite3.rb#test_interrupts_around_begin_and_commit_never_leave_the_database_in_a_transaction) | |
4444
| PostgreSQL statements dropped by `DEALLOCATE ALL` / `DISCARD ALL` are prepared again | [`test_statements_are_prepared_again_after_deallocate_all`](../tests/end2end_pg.rb#test_statements_are_prepared_again_after_deallocate_all) | not MySQL (no server-side prepared statements) | not SQLite | [`test_statements_are_named_after_the_module_and_query_class`](../test/features_test.rb#test_statements_are_named_after_the_module_and_query_class) |
4545
| `:execresult` with `RETURNING` runs the statement | covered by `:execresult` semantics | covered by `:execresult` semantics | [`test_execresult_with_returning_runs_the_statement`](../tests/end2end_sqlite3.rb#test_execresult_with_returning_runs_the_statement) | |
46+
| `:copyfrom` keeps the case of quoted / mixed-case table and column names (MySQL `LOAD DATA`) | [`test_copyfrom_keeps_the_case_of_table_and_column_names`](../tests/end2end_pg.rb#test_copyfrom_keeps_the_case_of_table_and_column_names) | [`test_copyfrom_keeps_the_case_of_table_and_column_names`](../tests/end2end_mysql2.rb#test_copyfrom_keeps_the_case_of_table_and_column_names) | [`test_copyfrom_keeps_the_case_of_table_and_column_names`](../tests/end2end_sqlite3.rb#test_copyfrom_keeps_the_case_of_table_and_column_names) | |
4647
| `:copyfrom` takes any `Enumerable` (empty, lazy, `Enumerator`) | [`test_copyfrom_takes_any_enumerable`](../tests/end2end_pg.rb#test_copyfrom_takes_any_enumerable) | [`test_copyfrom_takes_any_enumerable`](../tests/end2end_mysql2.rb#test_copyfrom_takes_any_enumerable) | [`test_copyfrom_takes_any_enumerable`](../tests/end2end_sqlite3.rb#test_copyfrom_takes_any_enumerable) | |
4748
| Query names like `HasAuthors` / `IsActive` keep their name and stay RuboCop-clean | [`test_predicate_like_query_names_are_kept`](../tests/end2end_pg.rb#test_predicate_like_query_names_are_kept) | [`test_predicate_like_query_names_are_kept`](../tests/end2end_mysql2.rb#test_predicate_like_query_names_are_kept) | [`test_predicate_like_query_names_are_kept`](../tests/end2end_sqlite3.rb#test_predicate_like_query_names_are_kept) | [`test_predicate_like_query_names_are_rubocop_clean`](../test/features_test.rb#test_predicate_like_query_names_are_rubocop_clean) |
4849
| SQLite `JSON` / `UUID` columns are `String`s, also numeric-looking text | not PostgreSQL | not MySQL | [`test_json_and_uuid_columns_return_strings_that_look_numeric`](../tests/end2end_sqlite3.rb#test_json_and_uuid_columns_return_strings_that_look_numeric) | |

‎examples/authors/mysql/query.sql‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,19 @@ SELECT * FROM name_cases WHERE id = sqlc.arg(id);
207207
-- name: TruncateNameCases :exec
208208
TRUNCATE TABLE name_cases;
209209

210+
-- name: CopyMixedCaseCopies :copyfrom
211+
-- MySQL table names are case-sensitive on Linux: LOAD DATA must use `MixedCaseCopies`, not sqlc's lowercased name.
212+
INSERT INTO `MixedCaseCopies` (`Id`, `SomeValue`) VALUES (?, ?);
213+
214+
-- name: CopyMixedCaseCopiesUnquoted :copyfrom
215+
INSERT INTO MixedCaseCopies (SomeValue, Id) VALUES (?, ?);
216+
217+
-- name: ListMixedCaseCopies :many
218+
SELECT * FROM `MixedCaseCopies` ORDER BY `Id`;
219+
220+
-- name: TruncateMixedCaseCopies :exec
221+
TRUNCATE TABLE `MixedCaseCopies`;
222+
210223
-- name: GetUnnamedColumns :one
211224
SELECT 1, 'two';
212225

‎examples/authors/mysql/schema.sql‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ CREATE TABLE mysql_binding_values (
100100
json_unicode JSON
101101
);
102102

103+
CREATE TABLE `MixedCaseCopies` (`Id` BIGINT NOT NULL PRIMARY KEY, `SomeValue` TEXT);
104+
103105
CREATE TABLE name_cases (
104106
id BIGINT NOT NULL PRIMARY KEY,
105107
`class` TEXT NOT NULL,

‎examples/authors/postgresql/query.sql‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,15 @@ SELECT * FROM name_cases WHERE id = sqlc.arg(id);
243243
-- name: TruncateNameCases :exec
244244
TRUNCATE TABLE name_cases;
245245

246+
-- name: CopyMixedCaseCopies :copyfrom
247+
INSERT INTO "MixedCaseCopies" ("Id", "SomeValue") VALUES ($1, $2);
248+
249+
-- name: ListMixedCaseCopies :many
250+
SELECT * FROM "MixedCaseCopies" ORDER BY "Id";
251+
252+
-- name: TruncateMixedCaseCopies :exec
253+
TRUNCATE TABLE "MixedCaseCopies";
254+
246255
-- name: GetUnnamedColumns :one
247256
SELECT 1, 'two';
248257

‎examples/authors/postgresql/schema.sql‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ CREATE TABLE batch_types (
137137
stamps timestamptz[]
138138
);
139139

140+
CREATE TABLE "MixedCaseCopies" ("Id" BIGINT NOT NULL PRIMARY KEY, "SomeValue" TEXT);
141+
140142
CREATE TABLE name_cases (
141143
id BIGINT PRIMARY KEY,
142144
"class" TEXT NOT NULL,

‎examples/authors/sqlite/query.sql‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,12 @@ SELECT * FROM name_cases WHERE id = sqlc.arg(id);
200200
-- name: TruncateNameCases :exec
201201
DELETE FROM name_cases;
202202

203+
-- name: CopyMixedCaseCopies :copyfrom
204+
INSERT INTO "MixedCaseCopies" ("Id", "SomeValue") VALUES (?, ?);
205+
206+
-- name: ListMixedCaseCopies :many
207+
SELECT * FROM "MixedCaseCopies" ORDER BY "Id";
208+
203209
-- name: GetUnnamedColumns :one
204210
SELECT 1, 'two';
205211

‎examples/authors/sqlite/schema.sql‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ CREATE TABLE tags (
3535
uses INTEGER NOT NULL DEFAULT 0
3636
);
3737

38+
CREATE TABLE "MixedCaseCopies" ("Id" INTEGER NOT NULL PRIMARY KEY, "SomeValue" TEXT);
39+
3840
CREATE TABLE name_cases (
3941
id INTEGER PRIMARY KEY,
4042
"class" TEXT NOT NULL,

‎examples/mysql2/models.rb‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ class MysqlBindingValu < ::Data.define(
117117
end
118118
# rubocop:enable Naming/VariableNumber
119119

120+
class Mixedcasecopy < ::Data.define(:id, :somevalue)
121+
end
122+
120123
class NameCase < ::Data.define(
121124
:id,
122125
:class_,

‎examples/mysql2/models.rbs‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,12 @@ module Mysql2Codegen
193193
) -> void
194194
end
195195

196+
class Mixedcasecopy
197+
attr_reader id: ::Integer
198+
attr_reader somevalue: ::String?
199+
def initialize: ( ::Integer id, ::String? somevalue) -> void
200+
end
201+
196202
class NameCase
197203
attr_reader id: ::Integer
198204
attr_reader class_: ::String

0 commit comments

Comments
 (0)