Skip to content

Document.update doesn't allow updates with InnerDoc #1535

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kaiix opened this issue Sep 29, 2021 · 0 comments · Fixed by #1784
Closed

Document.update doesn't allow updates with InnerDoc #1535

kaiix opened this issue Sep 29, 2021 · 0 comments · Fixed by #1784
Labels
Category: Bug Something isn't right

Comments

@kaiix
Copy link

kaiix commented Sep 29, 2021

For example:

class Location(InnerDoc):
  country = Text()
  city = Text()
  
class User(Document):
  name = Text()
  location = Object(Location)

  class Index:
    ...

user = User(name='alice', location=Location(country='foo', city='bar'))
user.save()
user.update(location=Location(city='baz'))

then it will raise the following error

image

InnerDoc inherits from AttrDict, and merge method accepts AttrDict to be merged, the problem is that not all AttrDict subclasses implement a dict-like interface for iterate, such as InnerDoc

I think, its better to first convert AttrDict to dict in merge method to make it iterable. After this fix, doc creation & update can both accept InnerDoc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Bug Something isn't right
Projects
None yet
2 participants