Merge fixes
This commit is contained in:
		| @@ -30,7 +30,7 @@ class BaseDocument(object): | |||||||
|     _dynamic_lock = True |     _dynamic_lock = True | ||||||
|     _initialised = False |     _initialised = False | ||||||
|  |  | ||||||
|     def __init__(self, __auto_convert=True, *args, **values): |     def __init__(self, *args, **values): | ||||||
|         """ |         """ | ||||||
|         Initialise a document or embedded document |         Initialise a document or embedded document | ||||||
|  |  | ||||||
| @@ -46,7 +46,7 @@ class BaseDocument(object): | |||||||
|                 if name in values: |                 if name in values: | ||||||
|                     raise TypeError("Multiple values for keyword argument '" + name + "'") |                     raise TypeError("Multiple values for keyword argument '" + name + "'") | ||||||
|                 values[name] = value |                 values[name] = value | ||||||
|  |         __auto_convert = values.pop("__auto_convert", True) | ||||||
|         signals.pre_init.send(self.__class__, document=self, values=values) |         signals.pre_init.send(self.__class__, document=self, values=values) | ||||||
|  |  | ||||||
|         self._data = {} |         self._data = {} | ||||||
|   | |||||||
| @@ -1138,8 +1138,13 @@ class QuerySet(object): | |||||||
|  |  | ||||||
|             if self._hint != -1: |             if self._hint != -1: | ||||||
|                 self._cursor_obj.hint(self._hint) |                 self._cursor_obj.hint(self._hint) | ||||||
|  |  | ||||||
|         return self._cursor_obj |         return self._cursor_obj | ||||||
|  |  | ||||||
|  |     def __deepcopy__(self, memo): | ||||||
|  |         """Essential for chained queries with ReferenceFields involved""" | ||||||
|  |         return self.clone() | ||||||
|  |  | ||||||
|     @property |     @property | ||||||
|     def _query(self): |     def _query(self): | ||||||
|         if self._mongo_query is None: |         if self._mongo_query is None: | ||||||
| @@ -1302,6 +1307,9 @@ class QuerySet(object): | |||||||
|             except: |             except: | ||||||
|                 pass |                 pass | ||||||
|             key_list.append((key, direction)) |             key_list.append((key, direction)) | ||||||
|  |  | ||||||
|  |         if self._cursor_obj: | ||||||
|  |             self._cursor_obj.sort(key_list) | ||||||
|         return key_list |         return key_list | ||||||
|  |  | ||||||
|     def _get_scalar(self, doc): |     def _get_scalar(self, doc): | ||||||
|   | |||||||
| @@ -249,6 +249,10 @@ class QuerySetTest(unittest.TestCase): | |||||||
|         self.assertEqual(list(A.objects.none()), []) |         self.assertEqual(list(A.objects.none()), []) | ||||||
|         self.assertEqual(list(A.objects.none().all()), []) |         self.assertEqual(list(A.objects.none().all()), []) | ||||||
|  |  | ||||||
|  |     def test_chaining(self): | ||||||
|  |         class A(Document): | ||||||
|  |             s = StringField() | ||||||
|  |  | ||||||
|         class B(Document): |         class B(Document): | ||||||
|             ref = ReferenceField(A) |             ref = ReferenceField(A) | ||||||
|             boolfield = BooleanField(default=False) |             boolfield = BooleanField(default=False) | ||||||
| @@ -1475,7 +1479,6 @@ class QuerySetTest(unittest.TestCase): | |||||||
|  |  | ||||||
|         BlogPost.drop_collection() |         BlogPost.drop_collection() | ||||||
|  |  | ||||||
|  |  | ||||||
|     def test_set_list_embedded_documents(self): |     def test_set_list_embedded_documents(self): | ||||||
|  |  | ||||||
|         class Author(EmbeddedDocument): |         class Author(EmbeddedDocument): | ||||||
| @@ -1533,11 +1536,11 @@ class QuerySetTest(unittest.TestCase): | |||||||
|         BlogPost.drop_collection() |         BlogPost.drop_collection() | ||||||
|  |  | ||||||
|         blog_post_3 = BlogPost(title="Blog Post #3", |         blog_post_3 = BlogPost(title="Blog Post #3", | ||||||
|                                published_date=datetime(2010, 1, 6, 0, 0 ,0)) |                                published_date=datetime(2010, 1, 6, 0, 0, 0)) | ||||||
|         blog_post_2 = BlogPost(title="Blog Post #2", |         blog_post_2 = BlogPost(title="Blog Post #2", | ||||||
|                                published_date=datetime(2010, 1, 5, 0, 0 ,0)) |                                published_date=datetime(2010, 1, 5, 0, 0, 0)) | ||||||
|         blog_post_4 = BlogPost(title="Blog Post #4", |         blog_post_4 = BlogPost(title="Blog Post #4", | ||||||
|                                published_date=datetime(2010, 1, 7, 0, 0 ,0)) |                                published_date=datetime(2010, 1, 7, 0, 0, 0)) | ||||||
|         blog_post_1 = BlogPost(title="Blog Post #1", published_date=None) |         blog_post_1 = BlogPost(title="Blog Post #1", published_date=None) | ||||||
|  |  | ||||||
|         blog_post_3.save() |         blog_post_3.save() | ||||||
| @@ -1563,11 +1566,11 @@ class QuerySetTest(unittest.TestCase): | |||||||
|         BlogPost.drop_collection() |         BlogPost.drop_collection() | ||||||
|  |  | ||||||
|         blog_post_1 = BlogPost(title="A", |         blog_post_1 = BlogPost(title="A", | ||||||
|                                published_date=datetime(2010, 1, 6, 0, 0 ,0)) |                                published_date=datetime(2010, 1, 6, 0, 0, 0)) | ||||||
|         blog_post_2 = BlogPost(title="B", |         blog_post_2 = BlogPost(title="B", | ||||||
|                                published_date=datetime(2010, 1, 6, 0, 0 ,0)) |                                published_date=datetime(2010, 1, 6, 0, 0, 0)) | ||||||
|         blog_post_3 = BlogPost(title="C", |         blog_post_3 = BlogPost(title="C", | ||||||
|                                published_date=datetime(2010, 1, 7, 0, 0 ,0)) |                                published_date=datetime(2010, 1, 7, 0, 0, 0)) | ||||||
|  |  | ||||||
|         blog_post_2.save() |         blog_post_2.save() | ||||||
|         blog_post_3.save() |         blog_post_3.save() | ||||||
| @@ -1604,6 +1607,7 @@ class QuerySetTest(unittest.TestCase): | |||||||
|  |  | ||||||
|         qs = self.Person.objects.all().limit(10) |         qs = self.Person.objects.all().limit(10) | ||||||
|         qs = qs.order_by('-age') |         qs = qs.order_by('-age') | ||||||
|  |  | ||||||
|         ages = [p.age for p in qs] |         ages = [p.age for p in qs] | ||||||
|         self.assertEqual(ages, [40, 30, 20]) |         self.assertEqual(ages, [40, 30, 20]) | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user