Skip to content

Commit

Permalink
Define test models for Serialized LOB columns
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Thoman committed Oct 21, 2024
1 parent 29c8d6c commit e871d2a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
11 changes: 11 additions & 0 deletions spec/active_record/oracle_enhanced/type/binary_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
end
class ::TestEmployee < ActiveRecord::Base
end
class ::TestSerializedHashEmployee < ActiveRecord::Base
self.table_name = "test_employees"
serialize :binary_data, type: Hash, coder: YAML
end
@binary_data = "\0\1\2\3\4\5\6\7\8\9" * 10000
@binary_data2 = "\1\2\3\4\5\6\7\8\9\0" * 10000
end
Expand Down Expand Up @@ -117,6 +121,13 @@ class ::TestEmployee < ActiveRecord::Base
expect(@employee.binary_data).to eq(@binary_data)
end

it "should find NULL BLOB data when queried with nil" do
TestEmployee.delete_all
TestEmployee.create!(binary_data: nil)
TestEmployee.create!(binary_data: @binary_data)
expect(TestEmployee.where(binary_data: nil)).to have_attributes(count: 1)
end

it "should find serialized NULL BLOB data when queried with nil" do
TestEmployee.delete_all
TestEmployee.create!(binary_data: nil)
Expand Down
4 changes: 4 additions & 0 deletions spec/active_record/oracle_enhanced/type/text_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ class ::TestEmployee < ActiveRecord::Base; end
class ::Test2Employee < ActiveRecord::Base
serialize :comments
end
class ::TestSerializedHashEmployee < ActiveRecord::Base
self.table_name = "test_employees"
serialize :comments, type: Hash, coder: YAML
end
class ::TestEmployeeReadOnlyClob < ActiveRecord::Base
self.table_name = "test_employees"
attr_readonly :comments
Expand Down

0 comments on commit e871d2a

Please sign in to comment.