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:
parent
aded63f76f
commit
2db5ce544f
@ -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)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user