Skip to content

Move ora_number_to_ruby_number to Connection base class#296

Merged
yahonda merged 1 commit into
rsim:masterfrom
yahonda:consolidate-ora-number-to-ruby-number
May 13, 2026
Merged

Move ora_number_to_ruby_number to Connection base class#296
yahonda merged 1 commit into
rsim:masterfrom
yahonda:consolidate-ora-number-to-ruby-number

Conversation

@yahonda
Copy link
Copy Markdown
Collaborator

@yahonda yahonda commented May 13, 2026

Summary

ora_number_to_ruby_number was duplicated character-for-character as a private method in both OCIConnection and JDBCConnection:

def ora_number_to_ruby_number(num)
  # return BigDecimal instead of Float to avoid rounding errors
  num == (num_to_i = num.to_i) ? num_to_i : (num.is_a?(BigDecimal) ? num : BigDecimal(num.to_s))
end

Pull it up into the Connection base class. Both subclasses keep calling it unchanged via inheritance (3 call sites: 1 in oci_connection.rb, 2 in jdbc_connection.rb). The rule "return BigDecimal instead of Float to avoid rounding errors" now lives in one place.

Diff stat:

 lib/plsql/connection.rb      | 7 +++++++
 lib/plsql/jdbc_connection.rb | 5 -----
 lib/plsql/oci_connection.rb  | 5 -----
 3 files changed, 7 insertions(+), 10 deletions(-)

Net -3 LOC.

Test plan

  • bundle exec rspec — 468 examples, 0 failures, 1 pre-existing pending
  • ruby -c on each of the three modified files passes
  • Grep confirms the method is defined exactly once (in connection.rb) and call sites remain in the two driver files
  • CI matrix exercises both the OCI (MRI) and JDBC (JRuby) paths

🤖 Generated with Claude Code

The exact same private method was duplicated character-for-character in
both OCIConnection and JDBCConnection. Pull it up into Connection so the
"return BigDecimal instead of Float to avoid rounding errors" rule lives
in one place; subclasses keep calling it as before via inheritance.

Net change: -3 LOC. No behavior change. Full suite is green
(468 examples, 0 failures, 1 pre-existing pending).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@yahonda yahonda merged commit e12dd09 into rsim:master May 13, 2026
20 checks passed
@yahonda yahonda deleted the consolidate-ora-number-to-ruby-number branch May 13, 2026 01:54
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