Skip to content

Commit eba28b5

Browse files
Artis Aboltsjavornikolov
authored andcommitted
Force to convert String type value as real string to avoid 'no method setStringAtName for arguments (org.jruby.RubyString,org.jruby.RubyFloat) on Java::OracleJdbcDriver::OracleCallableStatementWrapper' error when used JRuby and for Varchar2 paramater is assigned non String value
1 parent 45b90c7 commit eba28b5

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/plsql/jdbc_connection.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,8 +371,10 @@ def plsql_to_ruby_data_type(metadata)
371371
def ruby_value_to_ora_value(value, type=nil, metadata={})
372372
type ||= value.class
373373
case type.to_s.to_sym
374-
when :Fixnum, :String
374+
when :Fixnum
375375
value
376+
when :String
377+
value.to_s
376378
when :BigDecimal
377379
case value
378380
when TrueClass

spec/plsql/connection_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,10 @@
145145
expect(@conn.ruby_value_to_ora_value(100, BigDecimal)).to eq java.math.BigDecimal.new(100)
146146
end
147147

148+
it "should translate Ruby String to string value" do
149+
expect(@conn.ruby_value_to_ora_value(1.1, String)).to eq '1.1'
150+
end
151+
148152
it "should translate Ruby Bignum value to BigDecimal when BigDecimal type specified" do
149153
big_decimal = @conn.ruby_value_to_ora_value(12345678901234567890, BigDecimal)
150154
expect(big_decimal).to eq java.math.BigDecimal.new("12345678901234567890")

0 commit comments

Comments
 (0)