sewenew / redis-protobuf

Redis module for reading and writing Protobuf messages
Apache License 2.0
204 stars 22 forks source link

Merging booleans #20

Closed maddypj closed 2 years ago

maddypj commented 4 years ago

Hello sewnew,

I was trying merging booleans with protobuf. If a value is set as "True" and I am trying to merge "False" to it ; I expect the end result to be "False" stored in the redis-object. Once the value is set to True; it remains True. The protobuf merge API also behaves the same way. Is there any different method of merging?

Obj1 merging with obj2 -> I expect Obj1 already set attributes remain as they are. Obj2 attributes get updated in Obj1.

Regards, Maddy

sewenew commented 4 years ago

Hi @maddypj

YES, redis-protobuf behaves the same as protobuf API, since it calls the corresponding API to do the job.

Is there any different method of merging?

AFAIK, there's no built-in way to do that. You have to write this merging logic by yourself.

Also, since protobuf 3, there's no has_xxx method for the generated protobuf message, and I think there's no way to distinguish whether an attribute of boolean type has already been set to False or it has never been set (the default value is False). So it might be hard to implement the merging method that you expect.

Regards