Sha256: a0ad7db489666a8b22e3a99447c03ee4f99cda82e5cd4b4985a02d513c614127

Contents?: true

Size: 865 Bytes

Versions: 39

Compression:

Stored size: 865 Bytes

Contents

# frozen_string_literal: true

module ActiveRecord
  class Relation
    class WhereClauseFactory # :nodoc:
      def initialize(klass, predicate_builder)
        @klass = klass
        @predicate_builder = predicate_builder
      end

      def build(opts, other)
        case opts
        when String, Array
          parts = [klass.sanitize_sql(other.empty? ? opts : ([opts] + other))]
        when Hash
          attributes = predicate_builder.resolve_column_aliases(opts)
          attributes.stringify_keys!

          parts = predicate_builder.build_from_hash(attributes)
        when Arel::Nodes::Node
          parts = [opts]
        else
          raise ArgumentError, "Unsupported argument type: #{opts} (#{opts.class})"
        end

        WhereClause.new(parts)
      end

      private
        attr_reader :klass, :predicate_builder
    end
  end
end

Version data entries

39 entries across 39 versions & 4 rubygems

Version Path
activerecord-6.0.3 lib/active_record/relation/where_clause_factory.rb
activerecord-6.0.3.rc1 lib/active_record/relation/where_clause_factory.rb
activerecord-6.0.2.2 lib/active_record/relation/where_clause_factory.rb
argon-1.3.1 vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.2.1/lib/active_record/relation/where_clause_factory.rb
symbolic_enum-1.1.5 vendor/bundle/ruby/2.7.0/gems/activerecord-6.0.2.1/lib/active_record/relation/where_clause_factory.rb
activerecord-6.0.2.1 lib/active_record/relation/where_clause_factory.rb
activerecord-6.0.2 lib/active_record/relation/where_clause_factory.rb
activerecord-6.0.2.rc2 lib/active_record/relation/where_clause_factory.rb
activerecord-6.0.2.rc1 lib/active_record/relation/where_clause_factory.rb
activerecord-6.0.1 lib/active_record/relation/where_clause_factory.rb
chatops-rpc-0.0.2 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/activerecord-6.0.0/lib/active_record/relation/where_clause_factory.rb
activerecord-6.0.1.rc1 lib/active_record/relation/where_clause_factory.rb
chatops-rpc-0.0.1 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/activerecord-6.0.0/lib/active_record/relation/where_clause_factory.rb
activerecord-6.0.0 lib/active_record/relation/where_clause_factory.rb
activerecord-6.0.0.rc2 lib/active_record/relation/where_clause_factory.rb
activerecord-6.0.0.rc1 lib/active_record/relation/where_clause_factory.rb
activerecord-6.0.0.beta3 lib/active_record/relation/where_clause_factory.rb
activerecord-6.0.0.beta2 lib/active_record/relation/where_clause_factory.rb
activerecord-6.0.0.beta1 lib/active_record/relation/where_clause_factory.rb