Commit Graph
199 Commits
Author SHA1 Message Date
Stefan Wojcik f45552f8f8 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.
2019-06-24 15:44:35 +02:00
Bastien Gérard 27ea01ee05 refactored datetime to_mongo, separating parsing from str + added test 2019-06-04 23:16:26 +02:00
Bastien Gérard 7ed5829b2c Add test on datetime field - parse datetime as str 2019-06-04 23:16:26 +02:00
Bastien Gérard 7d0687ec73 custom field validator is now expected to raise a ValidationError (drop support for returning True/False) 2019-05-28 09:26:07 +02:00
Bastien Gérard 6e1c132ee8 Improve minor things in the tests 2019-05-26 22:17:58 +02:00
Bastien Gérard bb1089e03d Improve coverage in fields test 2019-05-17 22:16:08 +02:00
Bastien Gérard c82f0c937d more work on coverage 2019-05-17 22:04:28 +02:00
Bastien Gérard 00d2fd685a more test cov 2019-05-17 22:04:28 +02:00
Bastien Gérard f28e1b8c90 improve coverage of lazy ref field 2019-05-17 22:04:28 +02:00
Bastien Gérard f7b7d0f79e Improve tests for querying list(embedded) when using inheritance 2019-05-03 21:59:48 +02:00
Bastien Gérard d98f36ceff Add test for querying on fields of list(EmbeddedDocument) (with inheritance on the EmbededDoc) 2019-05-02 00:08:16 +02:00
Bastien Gérard abfabc30c9 Fix querying on (Generic)EmbeddedDocument subclasses fields 2019-05-01 23:23:19 +02:00
erdenezulandGitHub 50ffa8014e Merge pull request #2008 from bagerard/refactor_deprecated_pymongo_test
refactored deprecated pymongo methods in tests
2019-03-03 08:06:48 +08:00
Bastien Gérard 7ef688b256 Added a test for push in DictField (relates to #1679) 2019-03-02 22:05:23 +01:00
Bastien Gérard b4fe0b35e4 Merge branch 'master' of github.com:MongoEngine/mongoengine into refactor_deprecated_pymongo_test 2019-03-02 21:48:41 +01:00
Bastien Gérard 35b7efe3f4 refactored deprecated pymongo methods in tests
- remove/count/add_user/insert
- added pymongo_support
2019-03-02 00:28:38 +01:00
Bastien Gérard dca837b843 Add suport for Mongo 3.4 (travis, fix tests) 2019-02-26 21:38:23 +01:00
Bastien Gérard c60c2ee8d0 fix minor styling issue in tests 2019-02-25 22:33:36 +01:00
Bastien Gérard 3cdb5b5db2 fix poor assert's in tests 2019-02-25 22:29:44 +01:00
Bastien Gérard b9cc8a4ca9 refactor more field tests into submodules #1983 2019-02-24 10:24:12 +01:00
Bastien Gérard 28606e9985 refactor fields tests (float, int, lazyref, long, url) #1983 2019-02-24 10:24:12 +01:00
Bastien GérardandGitHub 6cfe6652a3 Merge pull request #2001 from bagerard/separate_date_fields_tests_into_submodules
Separate fields tests into separate modules (date/datetime/complexdt)
2019-02-19 20:57:15 +01:00
Bastien Gérard 201f3008b1 Fix for py3 in binary field test 2019-02-17 22:56:56 +01:00
Bastien Gérard e02261be6d add test coverage for #1557 2019-02-17 22:22:29 +01:00
Bastien Gérard 2919e6765c separate test on binary field (#1983) 2019-02-17 21:45:05 +01:00
Bastien Gérard 4a46f5f095 Separate fields tests into separate modules (date/datetime/complexdatetime)
relates to #1983
2019-02-17 21:32:46 +01:00
Hendri KarismaandBastien Gérard a32c893078 in the mid DictField key can accept dollar sign 2018-12-19 20:24:28 +01:00
erdenezulandGitHub d3a592e5bf Merge pull request #1913 from bagerard/1453_mapfield_list_reference_field
Fix complex combinations of DictField(ListField(ReferenceField))
2018-12-13 09:16:19 +08:00
Bastien Gérard c306d42d08 Fix bug #1733 of _delta method (Issue with DynamicDocument and default value) + add test case 2018-11-13 20:57:41 +01:00
Bastien Gérard 23324f0f87 minor fix in ImageField docstring 2018-11-04 22:14:27 +01:00
Bastien Gérard 14d861bcbb Merge branch 'master' of https://github.com/MongoEngine/mongoengine into generic_ref_field_changed 2018-10-30 23:21:19 +01:00
Bastien Gérard f6cd349a16 Fix bug when using GenericReferenceField, modifications to the referenced document are tracked in the parent #1934 2018-10-30 23:00:05 +01:00
Bastien GérardandGitHub 8e1c4dec87 Merge pull request #1846 from bagerard/fix_validator_of_binary_field
fix validator of BinaryField
2018-10-26 22:14:08 +02:00
Bastien Gérard 0fa6610fdb Fix complex combinations of DictField(ListField(ReferenceField)) (#1453) 2018-10-16 21:08:59 +02:00
erdenezulandGitHub 1887f5b7e7 Merge pull request #1877 from bagerard/improve_ComplexField_validation_edge_case
Handles edge case when EmbeddedDocumentListField receives a Document and not a list
2018-09-18 14:49:24 +08:00
Bastien Gérard 57ccfcfc1b Merge branch 'master' of https://github.com/MongoEngine/mongoengine into swat_url_fix 2018-09-16 23:03:16 +02:00
Bastien Gérard 4314fa883f improve 2-3 codebase compatibility 2018-09-09 23:32:10 +02:00
Bastien Gérard 003827e916 rewrote some poorly written assertions like: assertTrue(isinstance(a, b)) assertTrue(a==b) assertTrue(a!=b) assertTrue(a in b) 2018-09-06 21:47:06 +02:00
Bastien Gérard 282b83ac08 Fix default value of ComplexDateTime + fixed descriptor .__get__ for class attribute 2018-09-04 23:48:07 +02:00
Bastien Gérard 193656e71b detect when EmbeddedDocumentListField receives an EmbeddedDocument instance instead of a list. It is a common mistake and the error wasn't meaningful (was fired from _from_son)
(relates to #1464)
2018-09-04 22:26:19 +02:00
Bastien Gérard 5dbee2a270 Ensures EmbeddedDocumentField does not accepts references to Document classes in its constructor 2018-08-30 22:06:36 +02:00
Bastien Gérard 48a85ee6e0 update related tests 2018-08-20 00:10:27 +02:00
Bastien Gérard b71ff6fbb8 fix validator of BinaryField. In fact bson.Binary fails if we give it unicode in input #273 2018-08-18 23:04:46 +02:00
Gram 19a6e324c4 +tests for date field 2018-07-20 17:37:23 +03:00
erdenezulandGitHub 7fb1c9dd35 Merge branch 'master' into master 2018-05-21 16:22:07 +08:00
swathi 8b5df3ca17 fix - allow url with underscore in domain 2018-02-08 12:31:40 -08:00
Erdenezul 101947da8b update fields argument when given #1172 2017-12-23 00:00:57 +08:00
erdenezulandGitHub 18a5fba42b Revert "add tests to increase code coverage" 2017-12-22 20:19:21 +08:00
erdenezulandGitHub b5a3b6f86a Merge pull request #1645 from erdenezul/inc_cov
add tests to increase code coverage
2017-12-22 20:14:31 +08:00
Emmanuel Leblond e74f659015 Improve LazyReferenceField and GenericLazyReferenceField with nested fields 2017-11-22 11:44:49 +01:00