Skip to content

Unify dictionary queries on plain select_value(s) with bind variables#2652

Merged
yahonda merged 1 commit into
rsim:masterfrom
yahonda:drop-forcing-binds
Apr 29, 2026
Merged

Unify dictionary queries on plain select_value(s) with bind variables#2652
yahonda merged 1 commit into
rsim:masterfrom
yahonda:drop-forcing-binds

Conversation

@yahonda

@yahonda yahonda commented Apr 29, 2026

Copy link
Copy Markdown
Collaborator

Summary

Extends the bind-variable pattern introduced in #2629 to the remaining all_* / user_* dictionary queries that were still routing through the select_values_forcing_binds / select_value_forcing_binds helpers. After this PR every dictionary query in OracleEnhancedAdapter calls plain select_values(sql, name, binds) / select_value(sql, name, binds) with a :placeholder raw SQL and an explicit binds array — one consistent shape across the file.

As a result, the two helpers select_values_forcing_binds and select_value_forcing_binds no longer have any callers and are removed.

Method Helper used before Now
identity_primary_key? select_values_forcing_binds select_values
trigger_backed_primary_key? select_values_forcing_binds select_values
pk_and_sequence_for (×2) select_values_forcing_binds select_values
primary_keys select_values_forcing_binds select_values
temporary_table? select_value_forcing_binds select_value
(helper definitions, private) (deleted)

Diff: +6 / -22 lines, 1 file.

Why the unification is safe now

The _forcing_binds helpers were added in #2125 (2021) to make dictionary queries use bind variables even inside an unprepared_statement do ... end block, by temporarily removing the connection from prepared_statements_disabled_cache so AR's visitor wouldn't inline the binds.

Two recent changes made that mechanism unnecessary:

  1. Bind literals in dictionary queries #2629 finished converting the remaining literal-interpolated dictionary queries to raw SQL with :placeholder markers and explicit binds arrays. AR's visitor isn't involved on the raw-SQL-with-binds path, so there is nothing to inline — the prepared_statements_disabled_cache trick had nothing to defend against on that path.
  2. Honor prepared_statements: false in perform_query and _exec_insert #2651 made OracleEnhanced::DatabaseStatements#perform_query honor prepared_statements? directly. Inside an unprepared_statement block, dictionary queries now prepare-bind-exec-close one-shot instead of caching the cursor in @statements, but bind values still flow to the server. SQL-text matching keeps the shared cursor reusable in the database's shared pool — the original server-side cursor-sharing goal of Usage of bind variables for volatile filter conditions (3) #2125 is preserved without the helper.

The helpers were defined under private and were not part of the documented adapter API.

Test plan

  • CI green (default prepared_statements: true workflow)
  • Daily master test_prepared_statements_false workflow green after merge
  • Local — full suite passes in both modes (verified):
    • prepared_statements: true → 613 examples, 0 failures, 7 pending
    • prepared_statements: false → 613 examples, 0 failures, 8 pending

Related

@yahonda yahonda changed the title Drop select_values_forcing_binds / select_value_forcing_binds helpers Apply #2629's bind pattern to all dictionary queries Apr 29, 2026
@yahonda yahonda changed the title Apply #2629's bind pattern to all dictionary queries Unify dictionary queries on plain select_value(s) with bind variables Apr 29, 2026
Extends the bind-variable pattern introduced in rsim#2629 to the remaining
all_* / user_* dictionary queries that were still routing through the
`select_values_forcing_binds` / `select_value_forcing_binds` helpers.
After this commit every dictionary query in `OracleEnhancedAdapter`
calls plain `select_values(sql, name, binds)` /
`select_value(sql, name, binds)` with a `:placeholder` raw SQL and an
explicit `binds` array — one consistent shape across the file.

As a consequence, the two helpers no longer have any callers and are
removed.

Methods touched (`oracle_enhanced_adapter.rb`):

  * identity_primary_key?
  * trigger_backed_primary_key?
  * pk_and_sequence_for (×2 callsites — sequence lookup and PK lookup)
  * primary_keys
  * temporary_table?

The `_forcing_binds` helpers were added in rsim#2125 (2021) to make
dictionary queries use bind variables even inside an
`unprepared_statement do ... end` block, by temporarily removing the
connection from `prepared_statements_disabled_cache` so AR's visitor
wouldn't inline the binds. Two recent changes made that mechanism
unnecessary:

  1. rsim#2629 finished converting the remaining literal-interpolated
     dictionary queries to raw SQL with `:placeholder` markers and
     explicit `binds` arrays. AR's visitor isn't involved on the
     raw-SQL-with-binds path, so there is nothing to inline.
  2. rsim#2651 made `OracleEnhanced::DatabaseStatements#perform_query`
     honor `prepared_statements?` directly. Inside an
     `unprepared_statement` block, dictionary queries now
     prepare-bind-exec-close one-shot instead of caching the cursor
     in `@statements`, but bind values still flow to the server.
     SQL-text matching keeps the shared cursor reusable in the
     database's shared pool — the original server-side cursor-sharing
     goal of rsim#2125 is preserved without the helper.

The helpers were defined under `private` and were not part of the
documented adapter API.
@yahonda yahonda force-pushed the drop-forcing-binds branch from 41fc5ca to 905d11c Compare April 29, 2026 15:13
@yahonda yahonda merged commit e063f29 into rsim:master Apr 29, 2026
12 checks passed
@yahonda yahonda deleted the drop-forcing-binds branch April 29, 2026 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant