ovn-org/libovsdb

Cannot Mutate an optional string (uuid) field

amorenoz opened this issue · 1 comments

Now that we have optional fields (sets with len <=1), there is a Type error with Mutations.
Example:

// bridgeType is the simplified ORM model of the Bridge table
type bridgeType struct {
	UUID           string            `ovsdb:"_uuid"`
	Name           string            `ovsdb:"name"`
	IPFIX          *string           `ovsdb:"ipfix"`
}
bridge := bridgeType {
	Name: "br-int",
}
	mutateOps, err := o.client.Where(bridge).Mutate(bridge, model.Mutation{
		Field:   &bridge.IPFIX,
		Mutator: ovsdb.MutateOperationInsert,
		Value:   &ipfix.UUID,
	})

Returns:

Wrong Type (Mutation insert of single value in to column [] [IPFIX (strong)] (min: 0, max: 1) [M]): expected *string but got []*string (string)

I think there is (what I perceive as) a semantic incoherence of "inserting into a pointer". As @dave-tucker rightfully argues, we might want to use an Update here. True, but an operation supported by ovsdb would be not supported any more by libovsdb because we decided to lean towards golang semantics over ovsdb ones. If that's the end conclusion we should at least document it clearly.

Closed via #230