aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation/predicate_builder/case_sensitive_handler.rb
blob: acf0bbd829cc54c0a4b8c8e1d85f81f4d6e4d12e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
module ActiveRecord
  class PredicateBuilder
    class CaseSensitiveHandler # :nodoc:
      def call(attribute, value)
        value.call(attribute)
      end

      class Value < Struct.new(:value, :table, :case_sensitive?) # :nodoc:
        def call(attribute)
          klass = table.send(:klass)
          column = klass.column_for_attribute(attribute.name)
          if case_sensitive?
            klass.connection.case_sensitive_comparison(attribute, column, value)
          else
            klass.connection.case_insensitive_comparison(attribute, column, value)
          end
        end
      end
    end
  end
end