Skip to content
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

Undefined document fields should not override instance methods #49

Closed
thomasst opened this issue Jul 30, 2012 · 6 comments
Closed

Undefined document fields should not override instance methods #49

thomasst opened this issue Jul 30, 2012 · 6 comments
Milestone

Comments

@thomasst
Copy link
Member

Mongoengine should not set attributes and potentially override instance methods when initializing a model with fields that are not defined in the document structure. For example, the following code should either trigger an error when creating the document, or create the document silently while keeping the instance method and print hello as expected:

from mongoengine import Document

class Doc(Document):
    def method(self):
        return 'hello'

doc = Doc(method='something')
print doc.method()

Similarly, when a document of the structure { "method": "something" } exists in the database, loading that document (e.g. using get()) should not override the instance method.

@philfreo
Copy link
Contributor

+1

@thomasst
Copy link
Member Author

Any plans on fixing this?

@rozza
Copy link
Contributor

rozza commented Jan 24, 2013

Yes, its assigned to the 0.8 release - which is in active development. Of course pull requests help things get implemented in a more timely fashion ;)

@rozza
Copy link
Contributor

rozza commented Jan 25, 2013

Looking into implementing this today.

@rozza
Copy link
Contributor

rozza commented Jan 25, 2013

Apologies for taking so long but this is now in the 0.8 branch - any undefined data will be put in document._data

@rozza rozza closed this as completed Jan 25, 2013
@thomasst
Copy link
Member Author

Thanks! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants