Repository: ovn-org/libovsdb (go)
Issue: `Where(...).Update(...)` throws server side OVS DB error: `syntax error: Member 'where' is present but not allowed here.`
Whenever a client performs an `Update` on an object using `Where*` (i.e: `Where`/ `WhereAll`/ `WhereCache`) the operation is invalidated on the OVS DB server's side. The error message presented is: `syntax error: Parsing ovsdb operation 1 of 1 failed: Member 'where' is present but not allowed here.`

This is the following operation causing this error: 

```
o: [{Op:insert Table:Load_Balancer Row:map[name:alex-hi] Rows:[] Columns:[] Mutations:[] Timeout:0 Where:[where column _uuid == {9fc3c02e-7bf8-4d5b-8a14-82257597e221}] Until: Durable:<nil> Comment:<nil> Lock:<nil> UUIDName:}]
```

By nullifying `.Where`, the operation passes...but that results in a `Create`. 

Let me know if you need more information. 

/assign @amorenoz 
Pull request description: api: fix update is using wrong 'op'
Fixes #193 
Signed-off-by: Adrian Moreno <amorenoz@redhat.com>

Patch:
diff --git a/client/api.go b/client/api.go
index 8353435..038c839 100644
--- a/client/api.go
+++ b/client/api.go
@@ -11,13 +11,6 @@ import (
 	"github.com/ovn-org/libovsdb/ovsdb"
 )
 
-const (
-	opInsert string = "insert"
-	opMutate string = "mutate"
-	opUpdate string = "insert"
-	opDelete string = "delete"
-)
-
 // API defines basic operations to interact with the database
 type API interface {
 	// List populates a slice of Models objects based on their type
@@ -264,7 +257,7 @@ func (a api) Create(models ...model.Model) ([]ovsdb.Operation, error) {
 		}
 
 		operations = append(operations, ovsdb.Operation{
-			Op:       opInsert,
+			Op:       ovsdb.OperationInsert,
 			Table:    tableName,
 			Row:      row,
 			UUIDName: namedUUID,
@@ -316,7 +309,7 @@ func (a api) Mutate(model model.Model, mutationObjs ...model.Mutation) ([]ovsdb.
 	for _, condition := range conditions {
 		operations = append(operations,
 			ovsdb.Operation{
-				Op:        opMutate,
+				Op:        ovsdb.OperationMutate,
 				Table:     tableName,
 				Mutations: mutations,
 				Where:     condition,
@@ -349,7 +342,7 @@ func (a api) Update(model model.Model, fields ...interface{}) ([]ovsdb.Operation
 	for _, condition := range conditions {
 		operations = append(operations,
 			ovsdb.Operation{
-				Op:    opUpdate,
+				Op:    ovsdb.OperationUpdate,
 				Table: table,
 				Row:   row,
 				Where: condition,
@@ -370,7 +363,7 @@ func (a api) Delete() ([]ovsdb.Operation, error) {
 	for _, condition := range conditions {
 		operations = append(operations,
 			ovsdb.Operation{
-				Op:    opDelete,
+				Op:    ovsdb.OperationDelete,
 				Table: a.cond.Table(),
 				Where: condition,
 			},


Test patch:
diff --git a/client/api_test.go b/client/api_test.go
index b5323da..bb6724b 100644
--- a/client/api_test.go
+++ b/client/api_test.go
@@ -674,7 +674,7 @@ func TestAPIMutate(t *testing.T) {
 			},
 			result: []ovsdb.Operation{
 				{
-					Op:        opMutate,
+					Op:        ovsdb.OperationMutate,
 					Table:     "Logical_Switch_Port",
 					Mutations: []ovsdb.Mutation{{Column: "tag", Mutator: ovsdb.MutateOperationInsert, Value: testOvsSet(t, []int{5})}},
 					Where:     []ovsdb.Condition{{Column: "_uuid", Function: ovsdb.ConditionEqual, Value: ovsdb.UUID{GoUUID: aUUID0}}},
@@ -698,7 +698,7 @@ func TestAPIMutate(t *testing.T) {
 			},
 			result: []ovsdb.Operation{
 				{
-					Op:        opMutate,
+					Op:        ovsdb.OperationMutate,
 					Table:     "Logical_Switch_Port",
 					Mutations: []ovsdb.Mutation{{Column: "external_ids", Mutator: ovsdb.MutateOperationDelete, Value: testOvsSet(t, []string{"foo"})}},
 					Where:     []ovsdb.Condition{{Column: "name", Function: ovsdb.ConditionEqual, Value: "lsp2"}},
@@ -722,7 +722,7 @@ func TestAPIMutate(t *testing.T) {
 			},
 			result: []ovsdb.Operation{
 				{
-					Op:        opMutate,
+					Op:        ovsdb.OperationMutate,
 					Table:     "Logical_Switch_Port",
 					Mutations: []ovsdb.Mutation{{Column: "external_ids", Mutator: ovsdb.MutateOperationInsert, Value: testOvsMap(t, map[string]string{"bar": "baz"})}},
 					Where:     []ovsdb.Condition{{Column: "_uuid", Function: ovsdb.ConditionEqual, Value: ovsdb.UUID{GoUUID: aUUID2}}},
@@ -746,13 +746,13 @@ func TestAPIMutate(t *testing.T) {
 			},
 			result: []ovsdb.Operation{
 				{
-					Op:        opMutate,
+					Op:        ovsdb.OperationMutate,
 					Table:     "Logical_Switch_Port",
 					Mutations: []ovsdb.Mutation{{Column: "external_ids", Mutator: ovsdb.MutateOperationInsert, Value: testOvsMap(t, map[string]string{"bar": "baz"})}},
 					Where:     []ovsdb.Condition{{Column: "_uuid", Function: ovsdb.ConditionEqual, Value: ovsdb.UUID{GoUUID: aUUID0}}},
 				},
 				{
-					Op:        opMutate,
+					Op:        ovsdb.OperationMutate,
 					Table:     "Logical_Switch_Port",
 					Mutations: []ovsdb.Mutation{{Column: "external_ids", Mutator: ovsdb.MutateOperationInsert, Value: testOvsMap(t, map[string]string{"bar": "baz"})}},
 					Where:     []ovsdb.Condition{{Column: "_uuid", Function: ovsdb.ConditionEqual, Value: ovsdb.UUID{GoUUID: aUUID1}}},
@@ -840,7 +840,7 @@ func TestAPIUpdate(t *testing.T) {
 			},
 			result: []ovsdb.Operation{
 				{
-					Op:    opUpdate,
+					Op:    ovsdb.OperationUpdate,
 					Table: "Logical_Switch_Port",
 					Row:   testRow,
 					Where: []ovsdb.Condition{{Column: "_uuid", Function: ovsdb.ConditionEqual, Value: ovsdb.UUID{GoUUID: aUUID0}}},
@@ -861,7 +861,7 @@ func TestAPIUpdate(t *testing.T) {
 			},
 			result: []ovsdb.Operation{
 				{
-					Op:    opUpdate,
+					Op:    ovsdb.OperationUpdate,
 					Table: "Logical_Switch_Port",
 					Row:   testRow,
 					Where: []ovsdb.Condition{{Column: "name", Function: ovsdb.ConditionEqual, Value: "lsp1"}},
@@ -887,7 +887,7 @@ func TestAPIUpdate(t *testing.T) {
 			},
 			result: []ovsdb.Operation{
 				{
-					Op:    opUpdate,
+					Op:    ovsdb.OperationUpdate,
 					Table: "Logical_Switch_Port",
 					Row:   tagRow,
 					Where: []ovsdb.Condition{{Column: "type", Function: ovsdb.ConditionEqual, Value: "sometype"}},
@@ -916,13 +916,13 @@ func TestAPIUpdate(t *testing.T) {
 			},
 			result: []ovsdb.Operation{
 				{
-					Op:    opUpdate,
+					Op:    ovsdb.OperationUpdate,
 					Table: "Logical_Switch_Port",
 					Row:   tagRow,
 					Where: []ovsdb.Condition{{Column: "type", Function: ovsdb.ConditionEqual, Value: "sometype"}},
 				},
 				{
-					Op:    opUpdate,
+					Op:    ovsdb.OperationUpdate,
 					Table: "Logical_Switch_Port",
 					Row:   tagRow,
 					Where: []ovsdb.Condition{{Column: "enabled", Function: ovsdb.ConditionIncludes, Value: testOvsSet(t, []bool{true})}},
@@ -951,7 +951,7 @@ func TestAPIUpdate(t *testing.T) {
 			},
 			result: []ovsdb.Operation{
 				{
-					Op:    opUpdate,
+					Op:    ovsdb.OperationUpdate,
 					Table: "Logical_Switch_Port",
 					Row:   tagRow,
 					Where: []ovsdb.Condition{
@@ -980,7 +980,7 @@ func TestAPIUpdate(t *testing.T) {
 			},
 			result: []ovsdb.Operation{
 				{
-					Op:    opUpdate,
+					Op:    ovsdb.OperationUpdate,
 					Table: "Logical_Switch_Port",
 					Row:   tagRow,
 					Where: []ovsdb.Condition{{Column: "type", Function: ovsdb.ConditionNotEqual, Value: "sometype"}},
@@ -1001,13 +1001,13 @@ func TestAPIUpdate(t *testing.T) {
 			},
 			result: []ovsdb.Operation{
 				{
-					Op:    opUpdate,
+					Op:    ovsdb.OperationUpdate,
 					Table: "Logical_Switch_Port",
 					Row:   testRow,
 					Where: []ovsdb.Condition{{Column: "_uuid", Function: ovsdb.ConditionEqual, Value: ovsdb.UUID{GoUUID: aUUID0}}},
 				},
 				{
-					Op:    opUpdate,
+					Op:    ovsdb.OperationUpdate,
 					Table: "Logical_Switch_Port",
 					Row:   testRow,
 					Where: []ovsdb.Condition{{Column: "_uuid", Function: ovsdb.ConditionEqual, Value: ovsdb.UUID{GoUUID: aUUID1}}},
@@ -1080,7 +1080,7 @@ func TestAPIDelete(t *testing.T) {
 			},
 			result: []ovsdb.Operation{
 				{
-					Op:    opDelete,
+					Op:    ovsdb.OperationDelete,
 					Table: "Logical_Switch",
 					Where: []ovsdb.Condition{{Column: "_uuid", Function: ovsdb.ConditionEqual, Value: ovsdb.UUID{GoUUID: aUUID0}}},
 				},
@@ -1096,7 +1096,7 @@ func TestAPIDelete(t *testing.T) {
 			},
 			result: []ovsdb.Operation{
 				{
-					Op:    opDelete,
+					Op:    ovsdb.OperationDelete,
 					Table: "Logical_Switch_Port",
 					Where: []ovsdb.Condition{{Column: "name", Function: ovsdb.ConditionEqual, Value: "lsp1"}},
 				},
@@ -1117,7 +1117,7 @@ func TestAPIDelete(t *testing.T) {
 			},
 			result: []ovsdb.Operation{
 				{
-					Op:    opDelete,
+					Op:    ovsdb.OperationDelete,
 					Table: "Logical_Switch_Port",
 					Where: []ovsdb.Condition{{Column: "type", Function: ovsdb.ConditionEqual, Value: "sometype"}},
 				},
@@ -1143,12 +1143,12 @@ func TestAPIDelete(t *testing.T) {
 			},
 			result: []ovsdb.Operation{
 				{
-					Op:    opDelete,
+					Op:    ovsdb.OperationDelete,
 					Table: "Logical_Switch_Port",
 					Where: []ovsdb.Condition{{Column: "type", Function: ovsdb.ConditionEqual, Value: "sometype"}},
 				},
 				{
-					Op:    opDelete,
+					Op:    ovsdb.OperationDelete,
 					Table: "Logical_Switch_Port",
 					Where: []ovsdb.Condition{{Column: "name", Function: ovsdb.ConditionEqual, Value: "foo"}},
 				},
@@ -1174,7 +1174,7 @@ func TestAPIDelete(t *testing.T) {
 			},
 			result: []ovsdb.Operation{
 				{
-					Op:    opDelete,
+					Op:    ovsdb.OperationDelete,
 					Table: "Logical_Switch_Port",
 					Where: []ovsdb.Condition{
 						{Column: "type", Function: ovsdb.ConditionEqual, Value: "sometype"},
@@ -1193,12 +1193,12 @@ func TestAPIDelete(t *testing.T) {
 			},
 			result: []ovsdb.Operation{
 				{
-					Op:    opDelete,
+					Op:    ovsdb.OperationDelete,
 					Table: "Logical_Switch_Port",
 					Where: []ovsdb.Condition{{Column: "_uuid", Function: ovsdb.ConditionEqual, Value: ovsdb.UUID{GoUUID: aUUID0}}},
 				},
 				{
-					Op:    opDelete,
+					Op:    ovsdb.OperationDelete,
 					Table: "Logical_Switch_Port",
 					Where: []ovsdb.Condition{{Column: "_uuid", Function: ovsdb.ConditionEqual, Value: ovsdb.UUID{GoUUID: aUUID1}}},
 				},