method
distinct_relation_for_primary_key
v7.0.0 -
Show latest stable
-
0 notes -
Class: ActiveRecord::ConnectionAdapters::SchemaStatements
- 1.0.0
- 1.1.6
- 1.2.6
- 2.0.3
- 2.1.0
- 2.2.1
- 2.3.8
- 3.0.0
- 3.0.9
- 3.1.0
- 3.2.1
- 3.2.8
- 3.2.13
- 4.0.2
- 4.1.8
- 4.2.1
- 4.2.7
- 4.2.9
- 5.0.0.1
- 5.1.7
- 5.2.3
- 6.0.0
- 6.1.3.1
- 6.1.7.7
- 7.0.0 (0)
- 7.1.3.2 (0)
- 7.1.3.4 (0)
- What's this?
distinct_relation_for_primary_key(relation)
public
Hide source
# File activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb, line 1292 def distinct_relation_for_primary_key(relation) # :nodoc: values = columns_for_distinct( visitor.compile(relation.table[relation.primary_key]), relation.order_values ) limited = relation.reselect(values).distinct! limited_ids = select_rows(limited.arel, "SQL").map(&:last) if limited_ids.empty? relation.none! else relation.where!(relation.primary_key => limited_ids) end relation.limit_value = relation.offset_value = nil relation end