Repository navigation
Fix bugs found by the second pre-release check - #51
Merged
Merged
Conversation
- pg: prepared statement names include the module, so modules sharing a connection no longer run each other's SQL - pg: unnamed result columns (SELECT 1, now()) are read by position and named column_1, column_2, ... (also on mysql2/sqlite3, where two of them failed generation) - pg: aliases with a quote no longer generate invalid Ruby - pg: top-level Float json/jsonb parameters keep their exact value - pg: a query abandoned by Timeout / Thread#raise is cancelled before the connection is reused - mysql2/sqlite3: a transaction already ended by the database (deadlock, ON CONFLICT ROLLBACK) raises the original error instead of the failed ROLLBACK's - mysql2/sqlite3: NOT IN (sqlc.slice(ids)) with [] matches every row - mysql2: Symbol parameters are bound as their name 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 the bugs found by an independent pre-release check of
main. Each fix comes with an E2E test that fails without it.<file>_<query>. Two generated modules with the same query file name and the same query name used one server-side statement, so the second module silently ran the first module's SQL. Names now include the module (pg_codegen_query_sql_get_author).nil.SELECT 1, now()readrow['']. Rows with an unnamed column are now read by position, and the column gets a position name:column_1,column_2, ... Before, two such columns failed generation withduplicate column names ... _on every engine. A single one was named_(it worked on mysql2/sqlite3, wasnilon pg); that member is nowcolumn_N.'(AS "it's") generated invalid Ruby. Column names are now written as escaped string literals (Code.string_literal).0.3304was stored as0.3304000000000001, also through:copyfromand batches.encode_jsonnow sendsFloat#to_s.Timeoutkept the connection busy. The next caller on that connection waited for the server to finish the statement.with_clientand the rescue intransactionnowcancela statement that is still running.ON CONFLICT ROLLBACK/INSERT OR ROLLBACK. The caller gotSAVEPOINT ... does not exist/cannot rollback - no transaction is activeinstead of the deadlock /ConstraintException.NOT IN (sqlc.slice(ids))with[]matched nothing. The empty slice was rendered asNULL. It is now rendered asSELECT NULL WHERE FALSE, soINmatches nothing andNOT INmatches every row.TypeError. They are now bound as their name, as pg already does.New tests:
examples/authors/*/query.sqlgainedGetUnnamedColumns,GetQuotedAlias,GetAuthorsNotInIdsand (sqlite)CreateAuthorOrRollback. There are new tests intests/end2end_{pg,mysql2,sqlite3}.rb.tests/optionsnow has two prepared-statement pg modules on one pool.docs/Coverage.mdand the README are updated.steep_expectations.ymlwas refreshed: line shifts plus 4 newUnknownConstantwarnings forPG/Mysql2.Verified locally:
rake test,rubocop,steepandsqlc diffare all green.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