Module: GraphSQL::Resolver::CountsByPrimaryKey
- Defined in:
- lib/graphsql/resolver.rb
Overview
select_columns always applies a multi-column .select() (primary key +
every mapped column), which makes a bare .count ambiguous: Rails'
default column inference joins every select_value into COUNT(col1, col2, ...), invalid SQL outside Postgres. The primary key is always
among those columns and is always a safe, correct thing to count, so a
bare .count/.count(&block) defaults to it instead of failing —
while .count(:some_column) still passes straight through untouched.
Instance Method Summary collapse
Instance Method Details
#count(column_name = nil, &block) ⇒ Object
18 19 20 21 22 |
# File 'lib/graphsql/resolver.rb', line 18 def count(column_name = nil, &block) return super if column_name || block super(klass.primary_key) end |