Flowdock
method

can_perform_case_insensitive_comparison_for?

Importance_0
v7.1.3.2 - Show latest stable - 0 notes - Class: ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
can_perform_case_insensitive_comparison_for?(column) private

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

Hide source
# File activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb, line 1098
        def can_perform_case_insensitive_comparison_for?(column)
          # NOTE: citext is an exception. It is possible to perform a
          #       case-insensitive comparison using `LOWER()`, but it is
          #       unnecessary, as `citext` is case-insensitive by definition.
          @case_insensitive_cache ||= { "citext" => false }
          @case_insensitive_cache.fetch(column.sql_type) do
            @case_insensitive_cache[column.sql_type] = begin
              sql = <<~SQL
                SELECT exists(
                  SELECT * FROM pg_proc
                  WHERE proname = 'lower'
                    AND proargtypes = ARRAY[#{quote column.sql_type}::regtype]::oidvector
                ) OR exists(
                  SELECT * FROM pg_proc
                  INNER JOIN pg_cast
                    ON ARRAY[casttarget]::oidvector = proargtypes
                  WHERE proname = 'lower'
                    AND castsource = #{quote column.sql_type}::regtype
                )
              SQL
              execute_and_clear(sql, "SCHEMA", [], allow_retry: true, materialize_transactions: false) do |result|
                result.getvalue(0, 0)
              end
            end
          end
        end
Register or log in to add new notes.