Sha256: e2b7f99b1c1805b54910eda1efc1b590a6af771a043a89e8b4802c4001f21361

Contents?: true

Size: 688 Bytes

Versions: 1

Compression:

Stored size: 688 Bytes

Contents

module ActiveRecord
  class Relation
    class WhereClause
      def to_h(table_name = nil)
        equalities = equalities(predicates)

        # CPK Adds this line, because ours are coming in with AND->{EQUALITY, EQUALITY}
        equalities = predicates.grep(Arel::Nodes::And).map(&:children).flatten.grep(Arel::Nodes::Equality) if equalities.empty?

        if table_name
          equalities = equalities.select do |node|
            node.left.relation.name == table_name
          end
        end

        equalities.map { |node|
          name = node.left.name.to_s
          value = extract_node_value(node.right)
          [name, value]
        }.to_h
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
composite_primary_keys-12.0.10 lib/composite_primary_keys/relation/where_clause.rb