You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The idea is to be able to clear out sets or maps in an update. If you provide a non-nil empty slice/map in an update that does not explicitly specify that field, libovsdb will consider it as a default value and filter it out of the update:
The expected behavior was that libovsdb would consider a nil map/slice (the zero value of a slice/map) as a default but not a non-nil empty slice/map and thus that it could be used to clear out the value from DB.
Currently with nbctl you can do something as <set>=[] to clear a value out.
Alternatives in user code are:
Check the current values in the map/slice from cache and clear them out with a Mutate. This seems more complex than what should be needed.
Calculate your own list of non default values and explicitly specify those in the Update. This might lead to code that needs to be kept current with future updates of the schema.
Is there any specific reason why non-nil empty slice/map is considered default instead of just only a nil slice/map?
Could this be changed as the expected behavior described?
How would this affect arrays? Would they need to be changed to pointers?
The text was updated successfully, but these errors were encountered:
If 'nil' is the only way for libovsdb to distinguish 'no change' from 'update', then everything will become a pointer. Does not seem ideal either. I am thinking that mutate -- as you proposed above -- is a more natural approach to explicitly clearing the column. Just a thought.
ovs.ExternalIDs = map[string]string {}
err := c.impl.Where(&ovs).Update(&ovs, %ovs.ExternalIDs) // The `external_ids` will be replaced by the empty set.
The idea is to be able to clear out sets or maps in an update. If you provide a non-nil empty slice/map in an update that does not explicitly specify that field, libovsdb will consider it as a default value and filter it out of the update:
https://github.com/ovn-org/libovsdb/blob/586143b8fd0f643ad582ae5e29f42e9063d12a30/ovsdb/bindings.go#L352-L372
https://github.com/ovn-org/libovsdb/blob/586143b8fd0f643ad582ae5e29f42e9063d12a30/mapper/mapper.go#L152-L154
The expected behavior was that libovsdb would consider a nil map/slice (the zero value of a slice/map) as a default but not a non-nil empty slice/map and thus that it could be used to clear out the value from DB.
Currently with nbctl you can do something as
<set>=[]
to clear a value out.Alternatives in user code are:
Is there any specific reason why non-nil empty slice/map is considered default instead of just only a nil slice/map?
Could this be changed as the expected behavior described?
How would this affect arrays? Would they need to be changed to pointers?
The text was updated successfully, but these errors were encountered: