673 Commits

Author SHA1 Message Date
Filip Kucharczyk
abc159b7b9 Update Contributing, changelog 2019-12-05 01:10:54 +01:00
Bastien Gérard
78b240b740 updated changelog + improved query_counter test 2019-12-04 21:51:07 +01:00
Filip Kucharczyk
f7f0e10d4d Update changelog 2019-12-03 00:54:53 +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
6040b4b494 update changelog 2019-10-31 21:33:19 +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
c60ed32f3a Documented how pymongo.monitoring can be used with MongoEngine 2019-10-16 21:25:17 +02:00
Erdenezul Batmunkh
1dbe7a3163 Add log in changelog 2019-09-03 16:17:09 +02:00
Stefan Wojcik
d09af430e8 Fix formatting of the changelog – part 2
RTD didn't render it properly previously.

Refs #2105
2019-07-15 09:57:48 +02:00
Stefan Wojcik
79454b5eed Fix formatting of the changelog
RTD didn't render it properly previously.

Refs #2105
2019-07-15 09:54:18 +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
1338839b52
Update changelog.rst 2019-07-03 11:18:56 +02:00
Stefan Wojcik
058203a0ec More changelog tweaks [ci skip]
The main change is that we're now using double backticks (``), which are the
correct way to format code in an RST file.
2019-07-03 11:12:25 +02:00
Stefan Wojcik
8fdf664968 Changelog tweaks [ci skip] 2019-07-03 11:08:51 +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
Stefan Wojcik
bbed312bdd Final changelog tweaks [ci skip] 2019-07-02 18:42:50 +02:00
Stefan Wojcik
b593764ded One more changelog tweak [ci skip] 2019-07-02 18:35:29 +02:00
Stefan Wojcik
483c840fc8 One more changelog tweak [ci skip] 2019-07-02 18:29:28 +02:00
Stefan Wojcik
de80f0ccff Clean up the changelog [ci skip]
Mostly making sure that code is formatted using backticks and that wording and
punctuation are consistent.
2019-07-02 18:28:04 +02:00
Stefan Wójcik
d0b87f7f82
Drop the deprecated "format" param from BaseQuerySet.explain (#2113)
That option was pretty useless. You can very easily do:
```
import pprint
(...)

plan = SomeDoc.objects(...).explain()
pprint.pformat(plan)
```
2019-07-01 10:18:47 +02:00
Stefan Wójcik
9170eea784
Rename MongoEngineConnectionError to ConnectionFailure (#2111)
I originally changed the exception name from `ConnectionError` to
`MongoEngineConnectionError` in
b02904ee75,
inspired by landscape.io's package health report, which argued that
`ConnectionError` is already a built-in exception in Python 3 (which it is:
https://docs.python.org/3/library/exceptions.html#ConnectionError).

I do agree that we shouldn't override built-in exceptions. [0] That said, it’s
silly to add a "MongoEngine" prefix to any class within the `mongoengine`
module (and *especially* to *just one* exception class out of many). I've
decided to do what PyMongo does (
8855a510a8/pymongo/errors.py (L59))
and call this exception `ConnectionFailure`.

Note that this is a breaking change and people will need to rename
`MongoEngineConnectionError`s in their code to `ConnectionFailure`. Moreover,
if they use PyMongo's `ConnectionFailure` for anything, they'll need to take
    extra care to avoid conflicts, e.g. by using:
```
from mongoengine import ConnectionFailure as MongoEngineConnectionFailure
```

[0] Note that some popular packages still overwrite `ConnectionError`, e.g.
4983a9bde3/requests/exceptions.py (L32)
or
0be4d29206/redis/exceptions.py (L8)
2019-06-30 09:23:32 +02:00
Stefan Wojcik
2769967e1e Update the changelog [ci skip] 2019-06-27 17:41:29 +02:00
Stefan Wójcik
ffedd33101
Drop support for positional arguments when instantiating a document (#2103)
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-26 11:31:11 +02:00
Stefan Wojcik
1ead7f9b2b Add changelog entries for v0.18.2 2019-06-25 16:51:56 +02:00
Stefan Wojcik
8e69008699 Fill in the PR # in the changelog [ci skip] 2019-06-24 16:00:21 +02:00
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
ca230d28b4 fix typo in changelog 2019-06-18 22:18:10 +02:00
Bastien Gérard
63c9135184 Bump version number and update changelog for 0.18.1 2019-06-17 22:36:54 +02:00
Bastien Gérard
5f00b4f923 refactor travis - mongo install and added python3.7 2019-06-13 22:50:19 +02:00
Stefan Wojcik
a6c04f4f9a Finalize the v0.18.0 changelog [ci skip] 2019-06-12 11:38:58 +02:00
erdenezul
1f02d5fbbd
Merge pull request #1570 from erdenezul/remove_save_embedded
EmbeddedDocument should not have save method #1552
2019-06-11 16:15:53 +02:00
Erdenezul Batmunkh
c58b9f00f0 Add changelog 2019-06-11 15:53:50 +02:00
Stefan Wojcik
118a998138 Classify the QuerySet.aggregate change as a bugfix [ci skip] 2019-06-11 15:09:16 +02:00
Bastien Gérard
1fc5b954f2 fix typo in changelog 2019-06-10 22:38:37 +02:00
Stefan Wojcik
31d99c0bd2 Cleaner wording in the dev changelog 2019-06-10 11:26:47 +02:00
Bastien Gérard
36aebffcc0 update changelog 2019-06-04 22:39:44 +02:00
Bastien Gérard
5fb0f46e3f fix changelog (py37 not yet in travis) 2019-06-01 11:16:29 +02:00
Bastien Gérard
daca0ebc14 update changelog 2019-06-01 11:13:28 +02:00
Bastien Gérard
9ae8fe7c2d Improve perf of Doc.save by preventing a full to_mongo() call just to get the created variable 2019-06-01 11:13:28 +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
2e01eb87db Add support for MongoDB 3.6 and Python3.7 in travis 2019-05-18 14:29:42 +02:00
erdenezul
ee85af34d8
Merge pull request #2043 from bagerard/fix_write_concern_in_save
Fix default write concern on save call that was overwriting connection WC
2019-05-15 15:26:50 +02:00
Bastien Gérard
9cdc3ebee6 Fix default write concern on save call that was overwriting connection wc 2019-05-05 23:37:12 +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
Bastien Gérard
e44f71eeb1 updated changelog 2019-04-25 22:31:05 +02:00
Bastien Gérard
cb578c84e2 Merge branch 'master' of github.com:MongoEngine/mongoengine into disconnect 2019-04-25 22:15:48 +02:00
Bastien Gérard
565e1dc0ed minor improvements 2019-04-25 22:11:43 +02:00
Bastien Gérard
b1e28d02f7 Improve connect/disconnect
- document disconnect + sample of usage
- add more test cases to prevent github issues regressions
2019-04-24 22:44:07 +02:00