Skip to content

Commit e12dd09

Browse files
authored
Merge pull request rsim#296 from yahonda/consolidate-ora-number-to-ruby-number
Move ora_number_to_ruby_number to Connection base class
2 parents 423bd6f + d7f171d commit e12dd09

3 files changed

Lines changed: 7 additions & 10 deletions

File tree

lib/plsql/connection.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,5 +266,12 @@ def drop_session_ruby_temporary_tables
266266
exec "DROP TABLE #{row[0]}"
267267
end
268268
end
269+
270+
private
271+
272+
def ora_number_to_ruby_number(num)
273+
# return BigDecimal instead of Float to avoid rounding errors
274+
num == (num_to_i = num.to_i) ? num_to_i : (num.is_a?(BigDecimal) ? num : BigDecimal(num.to_s))
275+
end
269276
end
270277
end

lib/plsql/jdbc_connection.rb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -588,10 +588,5 @@ def java_timestamp(value)
588588
def java_bigdecimal(value)
589589
value && java.math.BigDecimal.new(value.to_s)
590590
end
591-
592-
def ora_number_to_ruby_number(num)
593-
# return BigDecimal instead of Float to avoid rounding errors
594-
num == (num_to_i = num.to_i) ? num_to_i : (num.is_a?(BigDecimal) ? num : BigDecimal(num.to_s))
595-
end
596591
end
597592
end

lib/plsql/oci_connection.rb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -301,11 +301,6 @@ def raw_oci_connection
301301
end
302302
end
303303

304-
def ora_number_to_ruby_number(num)
305-
# return BigDecimal instead of Float to avoid rounding errors
306-
num == (num_to_i = num.to_i) ? num_to_i : (num.is_a?(BigDecimal) ? num : BigDecimal(num.to_s))
307-
end
308-
309304
def ora_date_to_ruby_date(val)
310305
case val
311306
when DateTime

0 commit comments

Comments
 (0)