myyang / django-pb-model

Protobuf mixin for django model
Other
112 stars 22 forks source link

Adding depth to the to_pb to constraint recursively convert relation #19

Closed cecilulysess closed 4 years ago

cecilulysess commented 4 years ago

Currently the logic recursively convert all relations. This will be undesirable in many cases.

How about change ProtoBufMixin's to_pb method from

def to_pb(self):

to

def to_pb(self, depth=None):

for example depth = 0 does not convert any relation, depth = 1 convert only direct relation etc.

Does this make sense? Happy to PR if owner agree on this feature.

myyang commented 4 years ago

great, but considering backward compatibility what value would be the default value ?

myyang commented 4 years ago

Oops, I missed None. So None would be the original flow, right?

cecilulysess commented 4 years ago

Yes

myyang commented 4 years ago

link #20