1548 Commits

Author SHA1 Message Date
Bastien Gérard
b5485b16e6 Merge branch 'allow-periods-in-dict' of https://github.com/mcsimps2/mongoengine into mcsimps2-allow-periods-in-dict 2019-12-26 20:47:46 +01:00
Bastien Gérard
c85b59d3b5 Merge branch 'master' of github.com:MongoEngine/mongoengine into negative_indexes_in_list 2019-12-20 23:27:51 +01:00
Bastien Gérard
332bd767d4 minor fixes in tests 2019-12-20 23:20:15 +01:00
Eric Timmons
68dc2925fb Add LazyReferenceField with dbref=True to embedded_document equality test 2019-12-15 20:21:22 -05:00
Eric Timmons
dc7b96a569 Make python value for LazyReferenceFields be a DBRef
Previously, when reading a LazyReferenceField from the DB, it was stored
internally in the parent document's _data field as an ObjectId. However, this
meant that equality tests using an enclosing EmbeddedDocument would not return
True when the EmbeddedDocument being compared to contained a DBRef or Document
in _data. Enclosing Documents were largely unaffected because they look at the
primary key for equality (which EmbeddedDocuments lack).

This makes the internal Python representation of a LazyReferenceField (before
the LazyReference itself has been constructed) a DBRef, using code identical to
ReferenceField.
2019-12-15 20:20:59 -05:00
Eric Timmons
50882e5bb0 Add failing test
Test that __eq__ for EmbeddedDocuments with LazyReferenceFields works as
expected.
2019-12-15 20:20:59 -05:00
Bastien Gérard
9166ba91d7 fix minor styling issue 2019-12-14 16:11:59 +01:00
Bastien Gérard
6bc4e602bb additional fix 2019-12-14 00:05:48 +01:00
Bastien Gérard
64c0cace85 fix from code review regarding py2py3 compat 2019-12-13 23:57:18 +01:00
Bastien Gérard
2ca905b6e5 Finalize python2/3 codebase compatibility and get rid of 2to3 2019-12-13 23:43:04 +01:00
Matt Simpson
b205314424 Add ability for dict keys to have . or $ in MongoDB >= 3.6
Starting in MongoDB >= 3.6, it is valid for dictionary keys to have $ or . in them as long as they don't start with $.  Additional tests added.
2019-12-10 11:09:29 -05:00
Filip Kucharczyk
cb77bb6b69 Implement __bool__ on Q and QCombination 2019-12-05 00:27:41 +01:00
Bastien Gérard
78b240b740 updated changelog + improved query_counter test 2019-12-04 21:51:07 +01:00
Bastien Gérard
7e30f00178
Merge pull request #2195 from EloiZalczer/master
Added alias parameter in query_counter
2019-12-04 21:50:41 +01:00
Filip Kucharczyk
af82c07acc Reformat with black 2019-12-03 09:19:02 +01:00
Filip Kucharczyk
3f75f30f26 Run black 2019-12-03 09:03:49 +01:00
Filip Kucharczyk
0458ef869e Add __eq__ to Q and Q operations 2019-12-03 00:44:13 +01:00
Eloi Zalczer
0bf08db7b9 Added test case for query_counter alias 2019-12-02 10:07:33 +01:00
Bastien Gérard
138e759161
Merge pull request #2187 from bagerard/improve_error_message_InvalidDocumentError
Improve error message from InvalidDocumentError
2019-11-08 21:27:17 +01:00
Bastien Gérard
81647d67a0 fix recent tests update with unittest2pytest 2019-10-31 23:06:40 +01:00
Bastien Gérard
d8924ed892 remove inheritance from unittest.TestCase on basic test classes 2019-10-31 23:02:28 +01:00
Bastien Gérard
799cdafae6 remove references to nose 2019-10-31 23:02:28 +01:00
Bastien Gérard
bc0c55e49a improve tests health (flake8 warnings) 2019-10-31 23:01:27 +01:00
Bastien Gérard
c61c6a8525 fix == None assertions 2019-10-31 22:59:49 +01:00
Bastien Gérard
3e764d068c fix remaining assertRaises 2019-10-31 22:59:49 +01:00
Bastien Gérard
ac25f4b98b ran unittest2pytest 2019-10-31 22:59:49 +01:00
Bastien Gérard
37ca79e9c5 fix black formatting 2019-10-31 22:39:53 +01:00
Bastien Gérard
bbfa978861 switch test runner from nose to pytest 2019-10-31 20:39:49 +01:00
Bastien Gérard
54ca7bf09f fix associated test to avoid discrepencies btw py2 and py3 2019-10-28 23:33:37 +01:00
Bastien Gérard
8bf5370b6c Improve error message from InvalidDocumentError whenever an embedded document has a bad shape (e.g due to migration) 2019-10-28 22:05:13 +01:00
Bastien Gérard
ecefa05e03
Merge pull request #2174 from bagerard/upgrade_latest_pymongo_travis
add latest pymongo 3.9 as part of the CI
2019-10-28 21:22:00 +01:00
Bastien Gérard
5bcc679194 fix 2 pymongo deprecation warnings 2019-10-10 22:55:44 +02:00
Bastien Gérard
e3cd553f82 add latest pymongo 3.9 as part of the CI 2019-10-04 21:46:47 +02:00
Bastien Gérard
933cb1d5c7
Merge pull request #2144 from 0a69911a/master
Implement collation for queryset
2019-09-11 23:27:25 +02:00
Bastien Gérard
7d94af0e31 add test coverage for no_cursor_timeout to support recent fix 2019-09-11 21:53:30 +02:00
Bastien Gérard
693195f70b fix test_pickable that was brought back to life recently 2019-08-31 22:28:31 +03:00
Bastien Gérard
2267b7e7d7 rename remaining files for pytest migration 2019-08-30 16:27:56 +03:00
otrofimov
47c67ecc99 Merge branch 'master' of https://github.com/MongoEngine/mongoengine 2019-08-29 11:48:07 +03:00
Bastien Gérard
ddececbfea rename all test files so that they are prefixed by test_{orginal_filename}.py 2019-08-28 16:01:44 +03:00
otrofimov
71a6f3d1a4 test_collation:
Added test with `pymongo.collation.Collation` object
Readable list of BlogPost names for test
2019-08-21 18:26:10 +03:00
otrofimov
fbb3bf869c compatibility with black 2019-08-08 15:56:20 +03:00
otrofimov
b887ea9623 Implement collation for queryset 2019-08-08 11:55:45 +03:00
Bastien Gérard
c68e3e1238 Add test case for list update by negative index 2019-07-24 21:37:16 +02:00
Bastien Gérard
0d01365751
Merge pull request #2131 from NMFR/master
Set default database when using mongomock.
2019-07-22 11:56:56 +02:00
Nuno Rodrigues
05a22d5a54 Extract test to its own method 2019-07-22 08:42:17 +00:00
Nuno Rodrigues
2424ece0c5 Fix a linting error 2019-07-16 13:40:46 +00:00
Nuno Rodrigues
2d02551d0a Add test 2019-07-15 17:54:46 +01:00
Stefan Wójcik
ac416aeeb3
Improve BaseDocument.from_json tests and documentation (#2127) 2019-07-15 12:15:55 +02:00
Stefan Wójcik
aa76ccdd25
Fix Document._object_key (#2125)
Previous implementation of `Document._object_key` was *pretending* to work on
MongoEngine-level fields (e.g. using "pk" instead of "_id" and separating
nested field parts by "__" instead of "."), but then it was also attempting to
transform field names from the `shard_key` into DB-level fields.

This, expectedly, didn't really work well. Most of the test cases added in this
commit were failing prior to the code fixes.
2019-07-09 12:08:26 +02:00
Stefan Wójcik
50555ec73e
Better management of the automatic "_cls" field (#2112)
* Rename BaseQuerySet._initial_query to BaseQuerySet._cls_query

This new name more accurately reflects the purpose of the dict. It is either
empty for documents that don't use inheritance or it contains a `{"_cls": ...}`
shape query. There was nothing "initial" about it per se.

* Drop read_preference as a kwarg on BaseQuerySet.__call__/filter

It was a poor design choice to offer two different ways to do the same thing:
1. `SomeDoc.objects(foo=bar, bar=baz).read_preference(...)`
2. `SomeDoc.objects(foo=bar, bar=baz, read_preference=...)`

Option 1 is good because it's immediately obvious which part defines the query
to be used and which part defines the read preference.

Option 2 is bad because you don't immediately know whether `read_preference`
is a query kwarg or a reserved keyword with some special behavior. If you
wanted to be particularly cruel, you could even write
`SomeDoc.objects(foo=bar, read_preference=..., bar=baz)`.

THIS IS A BREAKING CHANGE. From now on you have to use the
`BaseQuerySet.read_preference(...)` method.

* Add a BaseQuerySet.clear_cls_query method + get rid of the class_check kwarg

This is similar to what the previous commit did to read preference except that
in this case we were still missing a `BaseQuerySet` method for clearing the
`_cls` query.

Now, instead of the undocumented, untested, and confusing interface:
    `ParentDoc.objects(foo=bar, bar=baz, class_check=False)`
We do:
    `ParentDoc.objects(foo=bar, bar=baz).clear_cls_query()`
2019-07-03 11:07:55 +02:00