Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
6802967863
13
.travis.yml
13
.travis.yml
@ -7,6 +7,7 @@ python:
|
|||||||
- "3.3"
|
- "3.3"
|
||||||
- "3.4"
|
- "3.4"
|
||||||
- "pypy"
|
- "pypy"
|
||||||
|
- "pypy3"
|
||||||
env:
|
env:
|
||||||
- PYMONGO=dev DJANGO=dev
|
- PYMONGO=dev DJANGO=dev
|
||||||
- PYMONGO=dev DJANGO=1.6.5
|
- PYMONGO=dev DJANGO=1.6.5
|
||||||
@ -14,6 +15,9 @@ env:
|
|||||||
- PYMONGO=2.7.1 DJANGO=dev
|
- PYMONGO=2.7.1 DJANGO=dev
|
||||||
- PYMONGO=2.7.1 DJANGO=1.6.5
|
- PYMONGO=2.7.1 DJANGO=1.6.5
|
||||||
- PYMONGO=2.7.1 DJANGO=1.5.8
|
- PYMONGO=2.7.1 DJANGO=1.5.8
|
||||||
|
- PYMONGO=2.7.2 DJANGO=dev
|
||||||
|
- PYMONGO=2.7.2 DJANGO=1.6.5
|
||||||
|
- PYMONGO=2.7.2 DJANGO=1.5.8
|
||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
exclude:
|
exclude:
|
||||||
@ -21,6 +25,10 @@ matrix:
|
|||||||
env: PYMONGO=dev DJANGO=dev
|
env: PYMONGO=dev DJANGO=dev
|
||||||
- python: "2.6"
|
- python: "2.6"
|
||||||
env: PYMONGO=2.7.1 DJANGO=dev
|
env: PYMONGO=2.7.1 DJANGO=dev
|
||||||
|
- python: "2.6"
|
||||||
|
env: PYMONGO=2.7.2 DJANGO=dev
|
||||||
|
allow_failures:
|
||||||
|
- python: "pypy3"
|
||||||
fast_finish: true
|
fast_finish: true
|
||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
@ -36,12 +44,17 @@ install:
|
|||||||
- if [[ $DJANGO == 'dev' ]]; then travis_retry pip install https://www.djangoproject.com/download/1.7c2/tarball/; fi
|
- if [[ $DJANGO == 'dev' ]]; then travis_retry pip install https://www.djangoproject.com/download/1.7c2/tarball/; fi
|
||||||
- if [[ $DJANGO != 'dev' ]]; then travis_retry pip install Django==$DJANGO; fi
|
- if [[ $DJANGO != 'dev' ]]; then travis_retry pip install Django==$DJANGO; fi
|
||||||
- travis_retry pip install https://pypi.python.org/packages/source/p/python-dateutil/python-dateutil-2.1.tar.gz#md5=1534bb15cf311f07afaa3aacba1c028b
|
- travis_retry pip install https://pypi.python.org/packages/source/p/python-dateutil/python-dateutil-2.1.tar.gz#md5=1534bb15cf311f07afaa3aacba1c028b
|
||||||
|
- travis_retry pip install coveralls
|
||||||
- travis_retry python setup.py install
|
- travis_retry python setup.py install
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- travis_retry python setup.py test
|
- travis_retry python setup.py test
|
||||||
- if [[ $TRAVIS_PYTHON_VERSION == '3.'* ]]; then 2to3 . -w; fi;
|
- if [[ $TRAVIS_PYTHON_VERSION == '3.'* ]]; then 2to3 . -w; fi;
|
||||||
|
- coverage run --source=mongoengine setup.py test
|
||||||
|
- coverage report -m
|
||||||
- python benchmark.py
|
- python benchmark.py
|
||||||
|
after_script:
|
||||||
|
coveralls --verbose
|
||||||
notifications:
|
notifications:
|
||||||
irc: "irc.freenode.org#mongoengine"
|
irc: "irc.freenode.org#mongoengine"
|
||||||
branches:
|
branches:
|
||||||
|
@ -12,6 +12,10 @@ MongoEngine
|
|||||||
.. image:: https://coveralls.io/repos/MongoEngine/mongoengine/badge.png?branch=master
|
.. image:: https://coveralls.io/repos/MongoEngine/mongoengine/badge.png?branch=master
|
||||||
:target: https://coveralls.io/r/MongoEngine/mongoengine?branch=master
|
:target: https://coveralls.io/r/MongoEngine/mongoengine?branch=master
|
||||||
|
|
||||||
|
.. image:: https://landscape.io/github/MongoEngine/mongoengine/master/landscape.png
|
||||||
|
:target: https://landscape.io/github/MongoEngine/mongoengine/master
|
||||||
|
:alt: Code Health
|
||||||
|
|
||||||
About
|
About
|
||||||
=====
|
=====
|
||||||
MongoEngine is a Python Object-Document Mapper for working with MongoDB.
|
MongoEngine is a Python Object-Document Mapper for working with MongoDB.
|
||||||
|
@ -46,6 +46,7 @@ Changes in 0.9.X - DEV
|
|||||||
- Workaround a dateutil bug #608
|
- Workaround a dateutil bug #608
|
||||||
- Conditional save for atomic-style operations #511
|
- Conditional save for atomic-style operations #511
|
||||||
- Allow dynamic dictionary-style field access #559
|
- Allow dynamic dictionary-style field access #559
|
||||||
|
- index_cls is ignored when deciding to set _cls as index prefix #733
|
||||||
|
|
||||||
Changes in 0.8.7
|
Changes in 0.8.7
|
||||||
================
|
================
|
||||||
|
@ -718,6 +718,9 @@ class BaseDocument(object):
|
|||||||
ALLOW_INHERITANCE)
|
ALLOW_INHERITANCE)
|
||||||
include_cls = (allow_inheritance and not spec.get('sparse', False) and
|
include_cls = (allow_inheritance and not spec.get('sparse', False) and
|
||||||
spec.get('cls', True))
|
spec.get('cls', True))
|
||||||
|
|
||||||
|
# 733: don't include cls if index_cls is False unless there is an explicit cls with the index
|
||||||
|
include_cls = include_cls and (spec.get('cls', False) or cls._meta.get('index_cls', True))
|
||||||
if "cls" in spec:
|
if "cls" in spec:
|
||||||
spec.pop('cls')
|
spec.pop('cls')
|
||||||
for key in spec['fields']:
|
for key in spec['fields']:
|
||||||
|
@ -405,6 +405,7 @@ class BaseQuerySet(object):
|
|||||||
will force an fsync on the primary server.
|
will force an fsync on the primary server.
|
||||||
:param _from_doc_delete: True when called from document delete therefore
|
:param _from_doc_delete: True when called from document delete therefore
|
||||||
signals will have been triggered so don't loop.
|
signals will have been triggered so don't loop.
|
||||||
|
:returns number of deleted documents
|
||||||
"""
|
"""
|
||||||
queryset = self.clone()
|
queryset = self.clone()
|
||||||
doc = queryset._document
|
doc = queryset._document
|
||||||
@ -422,9 +423,11 @@ class BaseQuerySet(object):
|
|||||||
has_delete_signal) and not _from_doc_delete
|
has_delete_signal) and not _from_doc_delete
|
||||||
|
|
||||||
if call_document_delete:
|
if call_document_delete:
|
||||||
|
cnt = 0
|
||||||
for doc in queryset:
|
for doc in queryset:
|
||||||
doc.delete(write_concern=write_concern)
|
doc.delete(write_concern=write_concern)
|
||||||
return
|
cnt += 1
|
||||||
|
return cnt
|
||||||
|
|
||||||
delete_rules = doc._meta.get('delete_rules') or {}
|
delete_rules = doc._meta.get('delete_rules') or {}
|
||||||
# Check for DENY rules before actually deleting/nullifying any other
|
# Check for DENY rules before actually deleting/nullifying any other
|
||||||
@ -455,8 +458,8 @@ class BaseQuerySet(object):
|
|||||||
write_concern=write_concern,
|
write_concern=write_concern,
|
||||||
**{'pull_all__%s' % field_name: self})
|
**{'pull_all__%s' % field_name: self})
|
||||||
|
|
||||||
queryset._collection.remove(
|
result = queryset._collection.remove(queryset._query, write_concern=write_concern)
|
||||||
queryset._query, write_concern=write_concern)
|
return result["n"]
|
||||||
|
|
||||||
def update(self, upsert=False, multi=True, write_concern=None,
|
def update(self, upsert=False, multi=True, write_concern=None,
|
||||||
full_result=False, **update):
|
full_result=False, **update):
|
||||||
|
@ -175,6 +175,16 @@ class IndexesTest(unittest.TestCase):
|
|||||||
info = A._get_collection().index_information()
|
info = A._get_collection().index_information()
|
||||||
self.assertEqual(len(info.keys()), 2)
|
self.assertEqual(len(info.keys()), 2)
|
||||||
|
|
||||||
|
class B(A):
|
||||||
|
c = StringField()
|
||||||
|
d = StringField()
|
||||||
|
meta = {
|
||||||
|
'indexes': [{'fields': ['c']}, {'fields': ['d'], 'cls': True}],
|
||||||
|
'allow_inheritance': True
|
||||||
|
}
|
||||||
|
self.assertEqual([('c', 1)], B._meta['index_specs'][1]['fields'])
|
||||||
|
self.assertEqual([('_cls', 1), ('d', 1)], B._meta['index_specs'][2]['fields'])
|
||||||
|
|
||||||
def test_build_index_spec_is_not_destructive(self):
|
def test_build_index_spec_is_not_destructive(self):
|
||||||
|
|
||||||
class MyDoc(Document):
|
class MyDoc(Document):
|
||||||
|
@ -4390,6 +4390,17 @@ class QuerySetTest(unittest.TestCase):
|
|||||||
{'_id': None, 'avg': 29, 'total': 2}
|
{'_id': None, 'avg': 29, 'total': 2}
|
||||||
])
|
])
|
||||||
|
|
||||||
|
def test_delete_count(self):
|
||||||
|
[self.Person(name="User {0}".format(i), age=i * 10).save() for i in xrange(1, 4)]
|
||||||
|
self.assertEqual(self.Person.objects().delete(), 3) # test ordinary QuerySey delete count
|
||||||
|
|
||||||
|
[self.Person(name="User {0}".format(i), age=i * 10).save() for i in xrange(1, 4)]
|
||||||
|
|
||||||
|
self.assertEqual(self.Person.objects().skip(1).delete(), 2) # test Document delete with existing documents
|
||||||
|
|
||||||
|
self.Person.objects().delete()
|
||||||
|
self.assertEqual(self.Person.objects().skip(1).delete(), 0) # test Document delete without existing documents
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user