Skip to content

Commit

Permalink
Merge pull request #208 from erizocosmico/fix/select-all-count
Browse files Browse the repository at this point in the history
select all in count instead of specific col
  • Loading branch information
erizocosmico committed Jul 18, 2017
2 parents 92d4718 + 23654b7 commit f676efd
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion store.go
Expand Up @@ -367,11 +367,13 @@ func (s *Store) Reload(schema Schema, record Record) error {
return rs.Scan(record)
}

var all = NewSchemaField("*")

// Count returns the number of rows selected by the given query.
func (s *Store) Count(q Query) (count int64, err error) {
_, queryBuilder := q.compile()
builder := builder.Set(queryBuilder, "Columns", nil).(squirrel.SelectBuilder)
err = builder.Column(fmt.Sprintf("COUNT(%s)", q.Schema().ID())).
err = builder.Column(fmt.Sprintf("COUNT(%s)", all.QualifiedName(q.Schema()))).
RunWith(s.proxy).
QueryRow().
Scan(&count)
Expand Down

0 comments on commit f676efd

Please sign in to comment.