diff --git a/.travis.yml b/.travis.yml index 0c93e6e6..1b9f5b7b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,21 +2,17 @@ language: python services: mongodb python: - - "2.5" - "2.6" - "2.7" - "3.2" - "3.3" env: - PYMONGO=dev - - PYMONGO=2.4.1 - - PYMONGO=2.3 + - PYMONGO=2.5 + - PYMONGO=2.4.2 install: - - if [[ $TRAVIS_PYTHON_VERSION == '2.'* ]]; then sudo apt-get install zlib1g zlib1g-dev; fi - - if [[ $TRAVIS_PYTHON_VERSION == '2.'* ]]; then sudo ln -s /usr/lib/i386-linux-gnu/libz.so /usr/lib/; fi - - if [[ $TRAVIS_PYTHON_VERSION == '2.'* ]]; then pip install PIL --use-mirrors ; true; fi - - if [[ $TRAVIS_PYTHON_VERSION == '2.'* ]]; then pip install PIL --use-mirrors ; true; fi - - if [[ $TRAVIS_PYTHON_VERSION == '2.5' ]]; then pip install simplejson --use-mirrors ; true; fi + - if [[ $TRAVIS_PYTHON_VERSION == '2.'* ]]; then cp /usr/lib/*/libz.so $VIRTUAL_ENV/lib/; fi + - if [[ $TRAVIS_PYTHON_VERSION == '2.'* ]]; then pip install pil --use-mirrors ; true; fi - if [[ $PYMONGO == 'dev' ]]; then pip install https://github.com/mongodb/mongo-python-driver/tarball/master; true; fi - if [[ $PYMONGO != 'dev' ]]; then pip install pymongo==$PYMONGO --use-mirrors; true; fi - python setup.py install diff --git a/AUTHORS b/AUTHORS index c64aaece..9371cd76 100644 --- a/AUTHORS +++ b/AUTHORS @@ -145,3 +145,4 @@ that much better: * Jared Forsyth * Kenneth Falck * Lukasz Balcerzak + * Aleksandr Sorokoumov diff --git a/LICENSE b/LICENSE index cef91cca..45f233c3 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2009-2012 See AUTHORS +Copyright (c) 2009 See AUTHORS Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/docs/changelog.rst b/docs/changelog.rst index e9783cd0..ecfe941d 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -49,6 +49,12 @@ Changes in 0.8.X - Updated Save so it calls $set and $unset in a single operation (#211) - Fixed inner queryset looping (#204) +Changes in 0.7.10 +================= +- Fixed cloning querysets in PY3 +- Int fields no longer unset in save when changed to 0 (#272) +- Fixed ReferenceField query chaining bug fixed (#254) + Changes in 0.7.9 ================ - Better fix handling for old style _types diff --git a/mongoengine/base/document.py b/mongoengine/base/document.py index 60b4d975..2d3b090b 100644 --- a/mongoengine/base/document.py +++ b/mongoengine/base/document.py @@ -1,5 +1,6 @@ import copy import operator +import numbers from functools import partial import pymongo @@ -431,13 +432,13 @@ class BaseDocument(object): # Determine if any changed items were actually unset. for path, value in set_data.items(): - if value or isinstance(value, bool): + if value or isinstance(value, (numbers.Number, bool)): continue # If we've set a value that ain't the default value dont unset it. default = None - if (self._dynamic and len(parts) and - parts[0] in self._dynamic_fields): + if (self._dynamic and len(parts) and parts[0] in + self._dynamic_fields): del(set_data[path]) unset_data[path] = 1 continue diff --git a/setup.py b/setup.py index 4b42e71c..ba538fab 100644 --- a/setup.py +++ b/setup.py @@ -58,7 +58,7 @@ if sys.version_info[0] == 3: extra_opts['packages'].append("tests") extra_opts['package_data'] = {"tests": ["fields/mongoengine.png"]} else: - extra_opts['tests_require'] = ['nose', 'coverage', 'blinker', 'django>=1.3', 'PIL'] + extra_opts['tests_require'] = ['nose', 'coverage', 'blinker', 'django==1.4.2', 'PIL'] extra_opts['packages'] = find_packages(exclude=('tests',)) setup(name='mongoengine', diff --git a/tests/all_warnings/__init__.py b/tests/all_warnings/__init__.py index 8cbe22df..74533de2 100644 --- a/tests/all_warnings/__init__.py +++ b/tests/all_warnings/__init__.py @@ -69,7 +69,7 @@ class AllWarnings(unittest.TestCase): p2.parent.name = "Poppa Wilson" p2.save() - self.assertEqual(len(self.warning_list), 1) + self.assertTrue(len(self.warning_list) > 0) if len(self.warning_list) > 1: print self.warning_list warning = self.warning_list[0] @@ -91,4 +91,4 @@ class AllWarnings(unittest.TestCase): InheritedDocumentFailTest._get_collection_name()) import sys -sys.path[0:0] = [""] \ No newline at end of file +sys.path[0:0] = [""] diff --git a/tests/queryset/queryset.py b/tests/queryset/queryset.py index d5e80be5..3e53c456 100644 --- a/tests/queryset/queryset.py +++ b/tests/queryset/queryset.py @@ -241,7 +241,7 @@ class QuerySetTest(unittest.TestCase): def test_none(self): class A(Document): - pass + s = StringField() A.drop_collection() A().save() @@ -249,6 +249,31 @@ class QuerySetTest(unittest.TestCase): self.assertEqual(list(A.objects.none()), []) self.assertEqual(list(A.objects.none().all()), []) + class B(Document): + ref = ReferenceField(A) + boolfield = BooleanField(default=False) + + A.drop_collection() + B.drop_collection() + + a1 = A(s="test1").save() + a2 = A(s="test2").save() + + B(ref=a1, boolfield=True).save() + + # Works + q1 = B.objects.filter(ref__in=[a1, a2], ref=a1)._query + + # Doesn't work + q2 = B.objects.filter(ref__in=[a1, a2]) + q2 = q2.filter(ref=a1)._query + self.assertEqual(q1, q2) + + a_objects = A.objects(s='test1') + query = B.objects(ref__in=a_objects) + query = query.filter(boolfield=True) + self.assertEquals(query.count(), 1) + def test_update_write_options(self): """Test that passing write_options works"""