Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
99637151b5 | ||
|
a8e787c120 | ||
|
53339c7c72 | ||
|
3534bf7d70 |
@@ -2,6 +2,14 @@
|
|||||||
Changelog
|
Changelog
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
Changes in 0.7.2
|
||||||
|
================
|
||||||
|
- Update index spec generation so its not destructive (MongoEngine/mongoengine#113)
|
||||||
|
|
||||||
|
Changes in 0.7.1
|
||||||
|
=================
|
||||||
|
- Fixed index spec inheritance (MongoEngine/mongoengine#111)
|
||||||
|
|
||||||
Changes in 0.7.0
|
Changes in 0.7.0
|
||||||
=================
|
=================
|
||||||
- Updated queryset.delete so you can use with skip / limit (MongoEngine/mongoengine#107)
|
- Updated queryset.delete so you can use with skip / limit (MongoEngine/mongoengine#107)
|
||||||
|
@@ -12,7 +12,7 @@ from signals import *
|
|||||||
__all__ = (document.__all__ + fields.__all__ + connection.__all__ +
|
__all__ = (document.__all__ + fields.__all__ + connection.__all__ +
|
||||||
queryset.__all__ + signals.__all__)
|
queryset.__all__ + signals.__all__)
|
||||||
|
|
||||||
VERSION = (0, 7, 0)
|
VERSION = (0, 7, 2)
|
||||||
|
|
||||||
|
|
||||||
def get_version():
|
def get_version():
|
||||||
|
@@ -398,6 +398,7 @@ class QuerySet(object):
|
|||||||
or a **-** to determine the index ordering
|
or a **-** to determine the index ordering
|
||||||
"""
|
"""
|
||||||
index_spec = QuerySet._build_index_spec(self._document, key_or_list)
|
index_spec = QuerySet._build_index_spec(self._document, key_or_list)
|
||||||
|
index_spec = index_spec.copy()
|
||||||
fields = index_spec.pop('fields')
|
fields = index_spec.pop('fields')
|
||||||
index_spec['drop_dups'] = drop_dups
|
index_spec['drop_dups'] = drop_dups
|
||||||
index_spec['background'] = background
|
index_spec['background'] = background
|
||||||
@@ -472,7 +473,9 @@ class QuerySet(object):
|
|||||||
|
|
||||||
# Ensure document-defined indexes are created
|
# Ensure document-defined indexes are created
|
||||||
if self._document._meta['index_specs']:
|
if self._document._meta['index_specs']:
|
||||||
for spec in self._document._meta['index_specs']:
|
index_spec = self._document._meta['index_specs']
|
||||||
|
for spec in index_spec:
|
||||||
|
spec = spec.copy()
|
||||||
fields = spec.pop('fields')
|
fields = spec.pop('fields')
|
||||||
types_indexed = types_indexed or includes_types(fields)
|
types_indexed = types_indexed or includes_types(fields)
|
||||||
opts = index_opts.copy()
|
opts = index_opts.copy()
|
||||||
@@ -510,6 +513,10 @@ class QuerySet(object):
|
|||||||
use_types = allow_inheritance and not spec.get('sparse', False)
|
use_types = allow_inheritance and not spec.get('sparse', False)
|
||||||
|
|
||||||
for key in spec['fields']:
|
for key in spec['fields']:
|
||||||
|
# If inherited spec continue
|
||||||
|
if isinstance(key, (list, tuple)):
|
||||||
|
continue
|
||||||
|
|
||||||
# Get ASCENDING direction from +, DESCENDING from -, and GEO2D from *
|
# Get ASCENDING direction from +, DESCENDING from -, and GEO2D from *
|
||||||
direction = pymongo.ASCENDING
|
direction = pymongo.ASCENDING
|
||||||
if key.startswith("-"):
|
if key.startswith("-"):
|
||||||
|
@@ -5,7 +5,7 @@
|
|||||||
%define srcname mongoengine
|
%define srcname mongoengine
|
||||||
|
|
||||||
Name: python-%{srcname}
|
Name: python-%{srcname}
|
||||||
Version: 0.7.0
|
Version: 0.7.2
|
||||||
Release: 1%{?dist}
|
Release: 1%{?dist}
|
||||||
Summary: A Python Document-Object Mapper for working with MongoDB
|
Summary: A Python Document-Object Mapper for working with MongoDB
|
||||||
|
|
||||||
|
@@ -669,6 +669,44 @@ class DocumentTest(unittest.TestCase):
|
|||||||
|
|
||||||
BlogPost.drop_collection()
|
BlogPost.drop_collection()
|
||||||
|
|
||||||
|
def test_inherited_index(self):
|
||||||
|
"""Ensure index specs are inhertited correctly"""
|
||||||
|
|
||||||
|
class A(Document):
|
||||||
|
title = StringField()
|
||||||
|
meta = {
|
||||||
|
'indexes': [
|
||||||
|
{
|
||||||
|
'fields': ('title',),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
'allow_inheritance': True,
|
||||||
|
}
|
||||||
|
|
||||||
|
class B(A):
|
||||||
|
description = StringField()
|
||||||
|
|
||||||
|
self.assertEqual(A._meta['index_specs'], B._meta['index_specs'])
|
||||||
|
|
||||||
|
def test_build_index_spec_is_not_destructive(self):
|
||||||
|
|
||||||
|
class MyDoc(Document):
|
||||||
|
keywords = StringField()
|
||||||
|
|
||||||
|
meta = {
|
||||||
|
'indexes': ['keywords'],
|
||||||
|
'allow_inheritance': False
|
||||||
|
}
|
||||||
|
|
||||||
|
self.assertEqual(MyDoc._meta['index_specs'],
|
||||||
|
[{'fields': [('keywords', 1)]}])
|
||||||
|
|
||||||
|
# Force index creation
|
||||||
|
MyDoc.objects._ensure_indexes()
|
||||||
|
|
||||||
|
self.assertEqual(MyDoc._meta['index_specs'],
|
||||||
|
[{'fields': [('keywords', 1)]}])
|
||||||
|
|
||||||
def test_db_field_load(self):
|
def test_db_field_load(self):
|
||||||
"""Ensure we load data correctly
|
"""Ensure we load data correctly
|
||||||
"""
|
"""
|
||||||
|
Reference in New Issue
Block a user