Fix row estimation bug

The variable `table` is mutated from `schema.tablename` to `tablename`
before being passed to other functions, which try to parse the schema
from the name. This results in schema name being `public` because it's
missing from the given table name.
This commit is contained in:
Dan Sosedoff 2018-12-12 13:33:55 -06:00
parent aded63f76f
commit 2db5ce544f

View File

@ -237,8 +237,8 @@ func (client *Client) EstimatedTableRowsCount(table string, opts RowsOptions) (*
} }
func (client *Client) TableRowsCount(table string, opts RowsOptions) (*Result, error) { func (client *Client) TableRowsCount(table string, opts RowsOptions) (*Result, error) {
schema, table := getSchemaAndTable(table) schema, tableName := getSchemaAndTable(table)
sql := fmt.Sprintf(`SELECT COUNT(1) FROM "%s"."%s"`, schema, table) sql := fmt.Sprintf(`SELECT COUNT(1) FROM "%s"."%s"`, schema, tableName)
if opts.Where != "" { if opts.Where != "" {
sql += fmt.Sprintf(" WHERE %s", opts.Where) sql += fmt.Sprintf(" WHERE %s", opts.Where)