mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-07 00:55:55 +00:00
Updates
This commit is contained in:
parent
7a5459da73
commit
f756e9eee6
3 changed files with 7 additions and 11 deletions
|
|
@ -1907,11 +1907,7 @@ func (h *Handler) InputJSONDataParser(req map[string]interface{}, index *Index,
|
|||
for _, field := range inputDef.Fields() {
|
||||
validFields[field.Name] = true
|
||||
if field.PrimaryKey {
|
||||
primaryKey := field.Name
|
||||
if primaryKey != DefaultColumnLabel {
|
||||
return nil, fmt.Errorf("Primary key field should have the name: %s", DefaultColumnLabel)
|
||||
}
|
||||
value, ok := req[primaryKey]
|
||||
value, ok := req[field.Name]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("primary key does not exist")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,7 +105,6 @@ func (i *InputDefinition) LoadDefinition(pb *internal.InputDefinition) error {
|
|||
|
||||
for _, field := range pb.Fields {
|
||||
var actions []Action
|
||||
fieldName := field.Name
|
||||
for _, action := range field.InputDefinitionActions {
|
||||
actions = append(actions, Action{
|
||||
Frame: action.Frame,
|
||||
|
|
@ -116,14 +115,11 @@ func (i *InputDefinition) LoadDefinition(pb *internal.InputDefinition) error {
|
|||
}
|
||||
|
||||
if field.PrimaryKey {
|
||||
// Deprecating column labels per #810.
|
||||
// So, setting the default column label here.
|
||||
fieldName = DefaultColumnLabel
|
||||
primaryKeyGiven = true
|
||||
}
|
||||
|
||||
inputField := InputDefinitionField{
|
||||
Name: fieldName,
|
||||
Name: field.Name,
|
||||
PrimaryKey: field.PrimaryKey,
|
||||
Actions: actions,
|
||||
}
|
||||
|
|
@ -296,6 +292,9 @@ func (i *InputDefinitionInfo) Validate() error {
|
|||
|
||||
// Validate columnLabel and duplicate primaryKey.
|
||||
for _, field := range i.Fields {
|
||||
if field.Name == "" {
|
||||
return ErrInputDefinitionNameRequired
|
||||
}
|
||||
for _, action := range field.Actions {
|
||||
if err := action.Validate(); err != nil {
|
||||
return err
|
||||
|
|
|
|||
|
|
@ -64,6 +64,7 @@ func TestInputDefinition_Encoding(t *testing.T) {
|
|||
}],
|
||||
"fields": [
|
||||
{
|
||||
"name": "id",
|
||||
"primaryKey": true
|
||||
},
|
||||
{
|
||||
|
|
@ -173,7 +174,7 @@ func TestActionValidation(t *testing.T) {
|
|||
t.Fatalf("Expected duplicate rowID with other field error, actual error: %s", err)
|
||||
}
|
||||
|
||||
field = pilosa.InputDefinitionField{PrimaryKey: true}
|
||||
field = pilosa.InputDefinitionField{Name: "id", PrimaryKey: true}
|
||||
field1 = pilosa.InputDefinitionField{Name: "test", PrimaryKey: false}
|
||||
info = pilosa.InputDefinitionInfo{Frames: []pilosa.InputFrame{frame}, Fields: []pilosa.InputDefinitionField{field, field1}}
|
||||
err = info.Validate()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue