Skip to content

Remove Connection#select after migrating spec call sites off the internal helper #2769

@yahonda

Description

@yahonda

Background

OracleEnhanced::OCIConnection#select and OracleEnhanced::JDBCConnection#select have no callers inside the library (grep against lib/ returns zero hits). PR #2768 marks both :nodoc: because they remain spec-only helpers. The deprecation_warning that PR #2768 briefly added is dropped in the same PR — the retry behaviour that vanished with the driver-level with_retry removal only fired under auto_retry = true, which already raises NotImplementedError through OracleEnhancedAdapter#auto_retry=, so there are no real users to warn.

This issue tracks the removal step on its own, so the spec migration scope stays separate from #2768.

Goal

Delete Connection#select (and the Connection#select_no_retry companion on JDBC) once spec call sites have been migrated to an alternative. Driver-level query helpers that bypass the AR adapter add internal-API surface that does not pull its weight (only specs use it, and only for admin / V$ queries that the AR adapter can serve too).

Steps

  1. Catalog the remaining call sites in spec/active_record/connection_adapters/oracle_enhanced/connection_spec.rb:
    • should execute SQL select (@conn.select("SELECT * FROM dual")) and should execute SQL select and return also columns — these are literal regression tests for the helper. Delete or rewrite to assert the equivalent AR-API behaviour.
    • kill_current_session helper — @conn.select(...) for userenv('sessionid') lookup. @sys_conn.select(...) for the v$session lookup. The latter needs SYS privileges, so it cannot trivially move to ActiveRecord::Base.lease_connection (which is the application user).
    • connection_id_from_server helper — same @sys_conn.select(...) SYS-only lookup.
  2. For the @conn.select(...) lookups, replace with ActiveRecord::Base.lease_connection.select_one(...) (or select_all(...).to_a.first).
  3. For the @sys_conn.select(...) SYS-only lookups, pick one of:
    • Replace with @sys_conn.exec(...) + manual cursor iteration (cursor.fetch; cursor[col_index]; cursor.close).
    • Add a small spec helper module that wraps the cursor iteration so the call sites stay readable.
    • Establish a separate AR connection pool for the SYS user and route the SYS lookup through lease_connection.select_one on that pool.
  4. Once all call sites are gone, remove Connection#select from both oci_connection.rb and jdbc_connection.rb, and remove Connection#select_no_retry from jdbc_connection.rb (it has no other callers).

Out of scope

Connection#exec is not part of this cleanup. It is reached widely from lib/ (DDL, prepared statements, schema introspection) and is part of how the adapter actually talks to OCI / JDBC.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions