Module: ActiveRecord::Bitwise::WhereChainExtension

Extended by:
T::Sig
Defined in:
lib/active_record/bitwise.rb

Overview

Prepended to ActiveRecord::QueryMethods::WhereChain to handle negation where poisoning

Instance Method Summary collapse

Instance Method Details

#not(*args) ⇒ Object



251
252
253
254
255
256
257
258
259
260
261
262
263
264
# File 'lib/active_record/bitwise.rb', line 251

def not(*args)
  scope = T.unsafe(self).instance_variable_get(:@scope)
  if args.first.is_a?(Hash) && scope && T.unsafe(scope).klass.respond_to?(:bitwise_definitions)
    T.unsafe(scope).klass.bitwise_definitions.each_key do |column_name|
      [column_name, column_name.to_s].each do |key|
        if args.first.key?(key)
          Kernel.raise ActiveRecord::Bitwise::NotSupportedError,
                       "Direct querying of bitwise column #{column_name} via where.not is not supported. Use without_#{column_name} scope instead."
        end
      end
    end
  end
  super
end