running test locally
akostadinov opened this issue · 3 comments
Steps to reproduce
I tried to follow the instructions to setup dev environment locally. But I get a strange error. Any clues how to fix are very appreciated. I tried to do same as CI does but locally (oracle container image, driver version, SQL commands, etc.) and I still get error inserting records with raw
columns.
Expected behavior
Tests work.
Actual behavior
Trying to run raw_spec.rb I get
ActiveRecord::StatementInvalid: OCIError: ORA-01465: invalid hex number
0) OracleEnhancedAdapter handling of RAW columns should update record with RAW data
Failure/Error: @raw_cursor.exec
ActiveRecord::StatementInvalid:
OCIError: ORA-01465: invalid hex number
# stmt.c:265:in oci8lib_270.so
# /home/avalon/.asdf/installs/ruby/2.7.3/lib/ruby/gems/2.7.0/bundler/gems/ruby-oci8-d7426d763dd0/lib/oci8/cursor.rb:137:in `exec'
System configuration
Rails version: none (from test suite)
Oracle enhanced adapter version:
master
Ruby version:
2.7.3
Oracle Database version:
21.x (from gvenzl/oracle-xe:latest
)
I see that if I put hex characters in the string, then record is inserted:
@binary_data = "abc"
But the insert line in log shows
TestEmployee Create (7.5ms) INSERT INTO "TEST_EMPLOYEES" ("FIRST_NAME", "LAST_NAME", "BINARY_DATA", "ID") VALUES (:a1, :a2, :a3, :a4) [["first_name", "First"], ["last_name", "Last"], ["binary_data", "abc"], ["id", 1]]
So it seems like in my env, the conversion from hex string to binary is happening for some reason while in CI it does not happen. Why is this? I can't understand.
When I'm debugging the test, it seems like it doesn't use the correct filed types:
0> TestEmployee.attribute_types
=> {"id"=>#<ActiveRecord::Type::DecimalWithoutScale:0x0000000003db97c0 @precision=38, @scale=nil, @limit=nil, @range=-Infinity...Infinity>, "first_name"=>#<ActiveModel::Type::String:0x0000000003db8a00 @true="t", @false="f", @precision=nil, @scale=nil, @limit=20>, "last_name"=>#<ActiveModel::Type::String:0x000000000546b8b0 @true="t", @false="f", @precision=nil, @scale=nil, @limit=25>, "binary_data"=>#<ActiveModel::Type::Value:0x000000000533fcc0 @precision=nil, @scale=nil, @limit=nil>}
Why might that be?
I have zero explanation about this. But now everything works fine. The only thing I have done is that oracle container was stopped for awhile and I updated Operating System packages a few times (I think not including the oci8 rpm). Maybe something in master branch changed - really no idea.
0> TestEmployee.attribute_types
=> {"id"=>#<ActiveRecord::Type::OracleEnhanced::Integer:0x0000000004207c50 @precision=38, @scale=nil, @limit=38, @range=-99999999999999999999999999999999999999...99999999999999999999999999999999999999>, "first_name"=>#<ActiveRecord::Type::OracleEnhanced::String:0x0000000004206f08 @true="t", @false="f", @precision=nil, @scale=nil, @limit=20>, "last_name"=>#<ActiveRecord::Type::OracleEnhanced::String:0x0000000004206288 @true="t", @false="f", @precision=nil, @scale=nil, @limit=25>, "signature"=>#<TestEmployee::AttributeSignature:0x00000000041f8228 @true="t", @false="f", @precision=nil, @scale=nil, @limit=nil>}