Drop support for positional arguments when instantiating a document
For example, if you had the following class: ``` class Person(Document): name = StringField() age = IntField() ``` You could instantiate an object of such class by doing one of the following: 1. `new_person = Person('Tom', 30)` 2. `new_person = Person('Tom', age=30)` 3. `new_person = Person(name='Tom', age=30)` From now on, only option (3) is allowed. Supporting positional arguments may sound like a reasonable idea in this heavily simplified example, but in real life it's almost never what you want (especially if you use inheritance in your document definitions) and it may lead to ugly bugs. We should not rely on the *order* of fields to match a given value to a given name. This also helps us simplify the code e.g. by dropping the confusing (and undocumented) `BaseDocument._auto_id_field` attribute.
This commit is contained in:
@@ -6,6 +6,8 @@ Changelog
|
||||
Development
|
||||
===========
|
||||
- (Fill this out as you fix issues and develop your features).
|
||||
- BREAKING CHANGE: Drop support for positional arguments when instantiating a document. #?
|
||||
- From now on keyword arguments (e.g. `Doc(field_name=value)`) are required.
|
||||
|
||||
Changes in 0.18.1
|
||||
=================
|
||||
|
Reference in New Issue
Block a user