Skip to content

Commit

Permalink
Fix: OperationFailure when changing keys on existing index
Browse files Browse the repository at this point in the history
Closes #1180
  • Loading branch information
nicolaiarocci committed Aug 30, 2018
1 parent de08fec commit c7157ed
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
10 changes: 6 additions & 4 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ New

Fixed
~~~~~
- v0.8: ``OperationFailure`` performing MongoDB full text searches (`#1176`_)
- ``AttributeError`` on Python 2.7 when obsolete ``JSON`` or ``XML`` settings are used (`#1175`_).
- ``TypeError argument of type 'NoneType' is not iterable`` error when using document embedding in conjuction with soft deletes (`#1120`_)
- ``mongo_indexes``: "OperationFailure" when changing the keys of an existing index (`#1180`_)
- v0.8: "OperationFailure" performing MongoDB full text searches (`#1176`_)
- "AttributeError" on Python 2.7 when obsolete ``JSON`` or ``XML`` settings are used (`#1175`_).
- "TypeError argument of type 'NoneType' is not iterable" error when using document embedding in conjuction with soft deletes (`#1120`_)
- ``allow_unknown`` validation rule fails with nested dict fields (`#1163`_)
- Updating a field with a nullable data relation fails when value is null (`#1159`_)
- ``cerberus.schema.SchemaError`` when ``VALIDATE_FILTERS = True``. (`#1154`_)
- "cerberus.schema.SchemaError" when ``VALIDATE_FILTERS = True``. (`#1154`_)
- Serializers fails when array of types is in schema. (`#1112`_)
- Replace the broken ``make audit`` shortcut with ``make check``, add the
command to ``CONTRIBUTING.rst`` it was missing. (`#1144`_)
Expand Down Expand Up @@ -54,6 +55,7 @@ Docs
- Improve changelog format to reduce noise and increase readability. (`#1143`_)

.. _`#1181`: https://github.com/pyeve/eve/issues/1181
.. _`#1180`: https://github.com/pyeve/eve/issues/1180
.. _`#1176`: https://github.com/pyeve/eve/issues/1176
.. _`#1175`: https://github.com/pyeve/eve/issues/1175
.. _`#1173`: https://github.com/pyeve/eve/issues/1173
Expand Down
11 changes: 6 additions & 5 deletions eve/io/mongo/mongo.py
Original file line number Diff line number Diff line change
Expand Up @@ -1027,6 +1027,9 @@ def _create_index(app, resource, name, list_of_keys, index_options):
For example:
{"sparse": True}
.. versionchanged:: 0.8.1
Add support for IndexKeySpecsConflict error. See #1180.
.. versionadded:: 0.6
"""
Expand Down Expand Up @@ -1056,11 +1059,9 @@ def _create_index(app, resource, name, list_of_keys, index_options):
try:
coll.create_index(list_of_keys, **kw)
except pymongo.errors.OperationFailure as e:
if e.code == 85:
# This error is raised when the definition of the index has
# been changed, we didn't find any spec out there but we
# think that this error is not going to change and we can
# trust.
if e.code in (85, 86):
# raised when the definition of the index has been changed.
# (https://github.com/mongodb/mongo/blob/master/src/mongo/base/error_codes.err#L87)

# by default, drop the old index with old configuration and
# create the index again with the new configuration.
Expand Down

0 comments on commit c7157ed

Please sign in to comment.