Commit 5a86ba0c by Miles Richardson

Fix issue #153

parent b2bf2e27
...@@ -126,7 +126,7 @@ class EmbeddedObject(ParseType): ...@@ -126,7 +126,7 @@ class EmbeddedObject(ParseType):
return klass(**kw) return klass(**kw)
@complex_type() @complex_type('Relation')
class Relation(ParseType): class Relation(ParseType):
@classmethod @classmethod
def from_native(cls, **kw): def from_native(cls, **kw):
...@@ -178,10 +178,9 @@ class Relation(ParseType): ...@@ -178,10 +178,9 @@ class Relation(ParseType):
return repr return repr
def _to_native(self): def _to_native(self):
return { # Saving relations is a separate operation and thus should never need
'__type': 'Relation', # to convert this field _to_native
'className': self.relatedClassName return None
}
def add(self, objs): def add(self, objs):
"""Adds a Parse.Object or an array of Parse.Objects to the relation.""" """Adds a Parse.Object or an array of Parse.Objects to the relation."""
......
...@@ -139,7 +139,19 @@ class User(ParseResource): ...@@ -139,7 +139,19 @@ class User(ParseResource):
} }
} }
self.__class__.PUT(self._absolute_url, **payload) self.__class__.PUT(self._absolute_url, **payload)
self.__dict__[key] = ''
# Commented this line out to fix the saving relation issue --
# it's better to just return None in Relation._to_native
# self.__dict__[key] = ''
def relation(self, key):
if not hasattr(self, key):
return Relation(parentObject=self, key=key)
try:
return getattr(self, key).with_parent(parentObject=self, key=key)
except:
raise ParseError("Column '%s' is not a Relation." % (key,))
User.Query = QueryManager(User) User.Query = QueryManager(User)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment