Skip to content

Commit

Permalink
Fix Oracle issues
Browse files Browse the repository at this point in the history
  • Loading branch information
mayorova committed Dec 4, 2024
1 parent fbbe29d commit ea69c96
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion config/initializers/oracle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
require 'arel/visitors/oracle12_hack'

ENV['SCHEMA'] = 'db/oracle_schema.rb'
Rails.configuration.active_record.schema_format = ActiveRecord::Base.schema_format = :ruby
Rails.configuration.active_record.schema_format = ActiveRecord.schema_format = :ruby

ActiveRecord::ConnectionAdapters::TableDefinition.prepend(Module.new do
def column(name, type, **options)
Expand Down
8 changes: 6 additions & 2 deletions lib/arel/visitors/oracle12_hack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ def visit_Arel_Nodes_NotIn(o, collector)
# Fixes ORA-00932: inconsistent datatypes: expected - got CLOB
# remove if https://github.com/rsim/oracle-enhanced/issues/2239 is fixed (in Rails 7.0.1)
def visit_Arel_Nodes_Equality(o, collector)
right = o.right

return super if right.nil?

case (left = o.left)
when Arel::Attributes::Attribute
table = left.relation.table_name
Expand All @@ -42,7 +46,7 @@ def visit_Arel_Nodes_Equality(o, collector)
when :text, :binary
# https://docs.oracle.com/cd/B19306_01/appdev.102/b14258/d_lob.htm#i1016668
# returns 0 when the comparison succeeds
comparator = Arel::Nodes::NamedFunction.new('DBMS_LOB.COMPARE', [left, o.right])
comparator = Arel::Nodes::NamedFunction.new('DBMS_LOB.COMPARE', [left, right])
collector = visit comparator, collector
collector << ' = 0'
collector
Expand All @@ -54,7 +58,7 @@ def visit_Arel_Nodes_Equality(o, collector)
end
end

# remove when addressed: https://github.com/rsim/oracle-enhanced/pull/2247
# remove when addressed: https://github.com/rsim/oracle-enhanced/pull/2247 - included in v7.1.0
def visit_Arel_Nodes_Matches o, collector
if !o.case_sensitive && o.left && o.right
o.left = Arel::Nodes::NamedFunction.new('UPPER', [o.left])
Expand Down

0 comments on commit ea69c96

Please sign in to comment.