ParsePy icon indicating copy to clipboard operation
ParsePy copied to clipboard

enhancement proposal - objectsId argument for relation methods is error prone

Open farin opened this issue 11 years ago • 1 comments

Imagine you want to add one object to relation (imho the most common case)

s.addRelation('network', '_User', ['nUFjOYqcG4']) vs s.addRelation('network', '_User', 'nUFjOYqcG4')

first is correct and adds relation, second do nothing silently because string is iterable

There can be explicit check to disallow strings - not much pythonic Better aPI woudle be accepting *args s.addRelation('network', '_User', 'nUFjOYqcG4') s.addRelation('network', '_User', 'nUFjOYqcG4', 'secondID') but this is API incompatible

There is also option deprecate old style, accepts both *args or list for some time. What do you think about it?

farin avatar Jul 22 '14 08:07 farin

This API has definitely some smells. It was easy to do it this way because it reflects the HTTP API, but the whole thing about using only IDs seems just bad.

To be quite honest, I think that since we started with a Django-ish design to querying, we should take a good look at the ContentType model in Django and see how we can do Generic Relations.

lullis avatar Jul 28 '14 14:07 lullis