Module: Arel::Visitors::NotNilOverride

Included in:
ToSql
Defined in:
lib/activerecord-not_nil/arel/visitors/to_sql.rb

Overview

Module to override Arel::Visitors::ToSql#visit_Arel_Nodes_Equality

Instance Method Summary collapse

Instance Method Details

#visit_Arel_Nodes_Equality(o, collector) ⇒ Object

rubocop:disable Naming/MethodName



7
8
9
10
11
12
13
14
# File 'lib/activerecord-not_nil/arel/visitors/to_sql.rb', line 7

def visit_Arel_Nodes_Equality(o, collector) # rubocop:disable Naming/MethodName
  return super if o.right.is_a?(Arel::Attributes::Attribute)
  return super if o.right.is_a?(Arel::Nodes::NamedFunction)
  return super unless o.right.value.is_a?(::NotNilClass)

  collector = visit o.left, collector
  collector << ' IS NOT NULL'
end