mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-10-08 11:57:51 +00:00
don't look up a field by name to find out its name
If a field doesn't exist, looking up that field produces a nil, and querying the name of a nil field fails. Don't do that. Instead, just use the name you're looking it up by. We could in theory return an error here, but we already handle nonexistent fields elsewhere and checking this when we already have checks for it seems unnecessary, I think? Also, we add a test for this. The test is over in server/grpc_test.go because we have infrastructure there for testing the SQL server functionality, and you can't actually write reasonable self-contained tests for the SQL stuff because it has no way to create a working server.
This commit is contained in:
parent
87300e27f1
commit
21a478a728
2 changed files with 5 additions and 2 deletions
|
|
@ -1007,6 +1007,10 @@ func TestQuerySQLWithError(t *testing.T) {
|
|||
sql: "select _id, age, field_not_found from grouper",
|
||||
err: pilosa.ErrFieldNotFound,
|
||||
},
|
||||
{
|
||||
sql: "select age, color, count(*) from grouper group by field_not_found, age, color",
|
||||
err: pilosa.ErrFieldNotFound,
|
||||
},
|
||||
}
|
||||
|
||||
for i, test := range tests {
|
||||
|
|
|
|||
|
|
@ -598,8 +598,7 @@ func (h handlerSelectGroupBy) Apply(stmt *sqlparser.Select, qm QueryMask, indexF
|
|||
|
||||
rowsQueries := []string{}
|
||||
for _, fieldName := range groupByFieldNames {
|
||||
field := index.Field(fieldName)
|
||||
rowsQueries = append(rowsQueries, Rows(field.Name()))
|
||||
rowsQueries = append(rowsQueries, Rows(fieldName))
|
||||
}
|
||||
|
||||
var wherePQL string
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue