Skip to content

Commit

Permalink
excluding schema alias from count function
Browse files Browse the repository at this point in the history
Signed-off-by: Marcos Minond <minond.marcos@gmail.com>
  • Loading branch information
minond committed Aug 8, 2018
1 parent a97563e commit 216fe6b
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions store.go
Expand Up @@ -439,13 +439,11 @@ 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)", all.QualifiedName(q.Schema()))).
err = builder.Column("COUNT(*)").
RunWith(s.runner).
QueryRow().
Scan(&count)
Expand Down

0 comments on commit 216fe6b

Please sign in to comment.