Skip to content

Commit

Permalink
Merge branch 'pull_#1256'
Browse files Browse the repository at this point in the history
Closes #1255
  • Loading branch information
nicolaiarocci committed Apr 5, 2019
2 parents 96deee1 + 68b8d38 commit 1f77fbd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ New

Fixed
~~~~~
- Insertion failure when replacing unknown field with dbref value (`#1255`_)
- ``max_results=1`` should be honored on aggregation endpoints (`#1250`_)
- PATCH incorrectly normalizes default values in subdocuments (`#1234`_)
- Unauthorized Exception not working with Werkzeug >= 15.0 (`#1245`_, `#1251`_)
Expand Down Expand Up @@ -62,6 +63,7 @@ Improved
- Add a "Python 3 is highly preferred" note on the homepage (`#1198`_)
- Drop sphinx-contrib-embedly when building docs.

.. _`#1255`: https://github.com/pyeve/eve/issues/1255
.. _`#1250`: https://github.com/pyeve/eve/issues/1250
.. _`#1234`: https://github.com/pyeve/eve/issues/1234
.. _`#1251`: https://github.com/pyeve/eve/pull/1251
Expand Down
8 changes: 7 additions & 1 deletion eve/io/mongo/mongo.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from werkzeug.exceptions import HTTPException
import decimal
from bson import decimal128
from collections import OrderedDict

from eve.auth import resource_auth
from eve.io.base import DataLayer, ConnectionException, BaseJSONEncoder
Expand All @@ -41,6 +42,9 @@ class MongoJSONEncoder(BaseJSONEncoder):
""" Proprietary JSONEconder subclass used by the json render function.
This is needed to address the encoding of special values.
.. versionchanged:: 0.8.2
Key-value pair order in DBRef are honored when encoding. Closes #1255.
.. versionchanged:: 0.6.2
Do not attempt to serialize callables. Closes #790.
Expand All @@ -57,7 +61,9 @@ def default(self, obj):
# (and we probably don't want it to be exposed anyway). See #790.
return "<callable>"
if isinstance(obj, DBRef):
retval = {"$id": str(obj.id), "$ref": obj.collection}
retval = OrderedDict()
retval["$ref"] = obj.collection
retval["$id"] = str(obj.id)
if obj.database:
retval["$db"] = obj.database
return retval
Expand Down

0 comments on commit 1f77fbd

Please sign in to comment.