980 Commits

Author SHA1 Message Date
Filip Kucharczyk
d3d7f0e670 Changelog 2019-12-05 01:18:29 +01:00
Filip Kucharczyk
37ffeafeff Replace 'pip' with 'python -m pip install' in docs 2019-12-05 01:13:05 +01:00
Filip Kucharczyk
abc159b7b9 Update Contributing, changelog 2019-12-05 01:10:54 +01:00
Filip Kucharczyk
17151f67c2 Reformat repo with pre-commit hooks 2019-12-05 00:53:39 +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
37ca79e9c5 fix black formatting 2019-10-31 22:39:53 +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
Bastien Gérard
19f12f3f2f document pymongo in RTD and make it point to github 2019-10-04 21:51:12 +02:00
Bastien Gérard
71e8d9a490 Added a FAQ to doc and Document the fact that we dont support motor 2019-10-04 21:51:12 +02:00
Bastien Gérard
be2c4f2b3c fix formatting and improve doc based on review 2019-09-16 21:15:35 +02:00
Bastien Gérard
7ac74b1c1f Document Model.objects.aggregate entrypoint with an example 2019-09-15 23:27:34 +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
b47669403b
Format the codebase using Black (#2109)
This commit:
1. Formats all of our existing code using `black`.
2. Adds a note about using `black` to `CONTRIBUTING.rst`.
3. Runs `black --check` as part of CI (failing builds that aren't properly formatted).
2019-06-27 13:05:54 +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
Stefan Wójcik
ae0384df29
Improve Document.meta.shard_key docs (#2099)
This closes #2096. Previous documentation of the shard_key meta attribute was
missing the crucial point that it really only matters if your collection is
sharded over a compound index.
2019-06-20 11:25:51 +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
Bastien Gérard
4a8985278d Document inherited members for the Document, EmbeddedDocument, DynamicDocument, and DynamicEmbeddedDocument (#2040) 2019-06-12 11:33:56 +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
0ac59c67ea
Merge pull request #2068 from bagerard/fix_connection_auth_same_host
Fix connection issue when using different authentication in different dbs
2019-06-07 21:08:26 +02:00
Bastien Gérard
70d6e763b0 Document the custom field validation feature 2019-06-05 22:23:54 +02:00
Bastien Gérard
5bf1dd55b1
Update mongomock example
Improved the mongomock example as reported in #2067 
 
Fixes #2067
2019-06-04 22:56:52 +02:00
Bastien Gérard
36aebffcc0 update changelog 2019-06-04 22:39:44 +02:00