mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-07 00:55:55 +00:00
report an error when an ID is used on a keyed field
This commit is contained in:
parent
9e3e0a6be7
commit
353fd3937d
2 changed files with 9 additions and 1 deletions
|
|
@ -5593,7 +5593,7 @@ func fieldValidateValue(f *Field, val interface{}) error {
|
|||
switch val := val.(type) {
|
||||
case string:
|
||||
if !f.Keys() {
|
||||
return errors.Errorf("string value on an unkeyed field %q", f.Name())
|
||||
return errors.Errorf("string value on unkeyed field %q", f.Name())
|
||||
}
|
||||
return nil
|
||||
case *pql.Condition:
|
||||
|
|
@ -5628,6 +5628,9 @@ func fieldValidateValue(f *Field, val interface{}) error {
|
|||
default:
|
||||
return errors.Errorf("invalid value %v for field %q of type %s", v, f.Name(), f.Type())
|
||||
}
|
||||
if f.Keys() {
|
||||
return errors.Errorf("found integer ID %d on keyed field %q", val, f.Name())
|
||||
}
|
||||
case FieldTypeBool:
|
||||
switch v := val.(type) {
|
||||
case bool:
|
||||
|
|
|
|||
|
|
@ -4933,6 +4933,7 @@ func TestExecutor_Execute_Query_Error(t *testing.T) {
|
|||
c.CreateField(t, "i", pilosa.IndexOptions{}, "integer", pilosa.OptFieldTypeInt(-1000, 1000))
|
||||
c.CreateField(t, "i", pilosa.IndexOptions{}, "decimal", pilosa.OptFieldTypeDecimal(2))
|
||||
c.CreateField(t, "i", pilosa.IndexOptions{}, "bool", pilosa.OptFieldTypeBool())
|
||||
c.CreateField(t, "i", pilosa.IndexOptions{}, "keys", pilosa.OptFieldKeys())
|
||||
|
||||
tests := []struct {
|
||||
query string
|
||||
|
|
@ -4978,6 +4979,10 @@ func TestExecutor_Execute_Query_Error(t *testing.T) {
|
|||
query: "Rows(bool)",
|
||||
error: "bool fields not supported by Rows() query",
|
||||
},
|
||||
{
|
||||
query: `Row(keys=1)`,
|
||||
error: `found integer ID 1 on keyed field "keys"`,
|
||||
},
|
||||
}
|
||||
|
||||
for i, test := range tests {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue