Repository navigation
Fix interrupted PostgreSQL PREPAREs, SQLite JSON/UUID read as numbers, Has/Is query names; MySQL :copyfrom takes any Enumerable - #56
Merged
Conversation
…, Has/Is query names; :copyfrom takes any Enumerable on MySQL - pg: prepare and record a statement with interrupts deferred, and use a statement the server already has (PG::DuplicatePstatement) instead of failing on every later call - sqlite3: JSON / UUID columns (NUMERIC affinity) are always read as Strings - query names starting with has_ / is_ / have_ get Naming/PredicatePrefix disabled - mysql2: :copyfrom no longer calls rows.empty?, so lazy enumerators work like on PostgreSQL / SQLite - README: document the sqlc bug that cuts SQLite query text after a non-ASCII character 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)".
|
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 three bugs found in a pre-release sweep. Each one has a test that fails on
main.PostgreSQL: an interrupted
PREPAREbroke a query on that connection for good. If a Timeout,Thread#raiseor a stopped Async task hit after the server had prepared the statement but beforerun_preparedrecorded it, every later call on that pooled connection raisedPG::DuplicatePstatement.drivers/pg.rb): a new privatepreparehelper prepares and records the statement insideThread.handle_interrupt(::Object => :never). It also rescuesPG::DuplicatePstatementand records the statement. Outside a transaction the call then continues; inside one the error has already aborted the transaction, so it is raised, the same rule asInvalidSqlStatementName.tests/end2end_pg.rb):test_an_interrupt_during_prepare_leaves_the_statement_usablesendsThread#raisewhile a hookedPREPAREis still running after the server prepared the statement.test_a_statement_left_prepared_by_a_failed_prepare_is_usedmakesPREPAREraise after the server ran it, both outside and inside a transaction. Both are deterministic: they hookPG::Connection#prepare.SQLite:
JSON/UUIDcolumns did not always come back as Strings. These columns have NUMERIC affinity, so SQLite stores numeric-looking text ('42','1.5') as a number and the row held an Integer or Float.decode_value(default: unchanged).drivers/sqlite3.rbreadsjson/jsonb/uuidcolumns asrow[i]&.to_s.test_json_and_uuid_columns_return_strings_that_look_numeric(tests/end2end_sqlite3.rb), which includes the RBS runtime type check.Has…/Is…query names were not RuboCop-clean.Naming/PredicatePrefixflaggedhas_authors/has_authors!.method_gen.rb): methods whose names start withis_/has_/have_get# rubocop:disable Naming/PredicatePrefix, the bang method too. The names are not changed.HasAuthors :oneexample query for every engine, sorake rubocoponexamples/catches a regression. Alsotest_predicate_like_query_names_are_kept(each engine's E2E suite) and the unit testtest_predicate_like_query_names_are_rubocop_clean.MySQL
:copyfromnow takes any Enumerable (lazy enumerators,Enumerator), like PostgreSQL and SQLite. Before, it calledrows.empty?. Now the rows are written to the temporary CSV andLOAD DATAis skipped when the file is empty (file.pos.positive?). Test:test_copyfrom_takes_any_enumerableon all three engines.Docs
:copyfromtakes any Enumerable; SQLite JSON/UUID are Strings; predicate-like query names.FROM userinstead ofFROM users. The README'snaïvenaming example now points to this limitation.docs/Coverage.mdanddocs/Testing.md: new rows and test names.Preparewas added to the reserved query names test, because the new helper is a generated method.Steep: the new
preparehelper adds two expectedPGunknown-constant diagnostics and onehandle_interruptblock diagnostic, the same kinds already insteep_expectations.yml. The fixtures intest/fixtures/*.binwere re-captured with sqlc 1.27.0.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)bug,enhancement,documentation, orbreaking) so the release notes are grouped correctly