Fix for inheritance bug and db_alias
This commit is contained in:
parent
83c11a9834
commit
3070e0bf5d
@ -2,9 +2,14 @@
|
|||||||
Changelog
|
Changelog
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
|
||||||
|
Changes in 0.6.16
|
||||||
|
=================
|
||||||
|
- Fixed issue where db_alias wasn't inherited
|
||||||
|
|
||||||
Changes in 0.6.15
|
Changes in 0.6.15
|
||||||
=================
|
=================
|
||||||
- Updated validation error message
|
- Updated validation error messages
|
||||||
- Added support for null / zero / false values in item_frequencies
|
- Added support for null / zero / false values in item_frequencies
|
||||||
- Fixed cascade save edge case
|
- Fixed cascade save edge case
|
||||||
- Fixed geo index creation through reference fields
|
- Fixed geo index creation through reference fields
|
||||||
|
@ -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, 6, 15)
|
VERSION = (0, 6, 16)
|
||||||
|
|
||||||
|
|
||||||
def get_version():
|
def get_version():
|
||||||
|
@ -649,8 +649,13 @@ class TopLevelDocumentMetaclass(DocumentMetaclass):
|
|||||||
del(attrs['meta']['collection'])
|
del(attrs['meta']['collection'])
|
||||||
if base._get_collection_name():
|
if base._get_collection_name():
|
||||||
collection = base._get_collection_name()
|
collection = base._get_collection_name()
|
||||||
# Propagate index options.
|
|
||||||
for key in ('index_background', 'index_drop_dups', 'index_opts'):
|
# Propagate inherited values
|
||||||
|
keys_to_propogate = (
|
||||||
|
'index_background', 'index_drop_dups', 'index_opts',
|
||||||
|
'allow_inheritance', 'queryset_class', 'db_alias',
|
||||||
|
)
|
||||||
|
for key in keys_to_propogate:
|
||||||
if key in base._meta:
|
if key in base._meta:
|
||||||
base_meta[key] = base._meta[key]
|
base_meta[key] = base._meta[key]
|
||||||
|
|
||||||
@ -659,11 +664,6 @@ class TopLevelDocumentMetaclass(DocumentMetaclass):
|
|||||||
abstract_base_indexes += base._meta.get('indexes', [])
|
abstract_base_indexes += base._meta.get('indexes', [])
|
||||||
else:
|
else:
|
||||||
base_indexes += base._meta.get('indexes', [])
|
base_indexes += base._meta.get('indexes', [])
|
||||||
# Propagate 'allow_inheritance'
|
|
||||||
if 'allow_inheritance' in base._meta:
|
|
||||||
base_meta['allow_inheritance'] = base._meta['allow_inheritance']
|
|
||||||
if 'queryset_class' in base._meta:
|
|
||||||
base_meta['queryset_class'] = base._meta['queryset_class']
|
|
||||||
try:
|
try:
|
||||||
base_meta['objects'] = base.__getattribute__(base, 'objects')
|
base_meta['objects'] = base.__getattribute__(base, 'objects')
|
||||||
except TypeError:
|
except TypeError:
|
||||||
@ -671,6 +671,7 @@ class TopLevelDocumentMetaclass(DocumentMetaclass):
|
|||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
# defaults
|
||||||
meta = {
|
meta = {
|
||||||
'abstract': False,
|
'abstract': False,
|
||||||
'collection': collection,
|
'collection': collection,
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
%define srcname mongoengine
|
%define srcname mongoengine
|
||||||
|
|
||||||
Name: python-%{srcname}
|
Name: python-%{srcname}
|
||||||
Version: 0.6.15
|
Version: 0.6.16
|
||||||
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
|
||||||
|
|
||||||
|
@ -2999,7 +2999,7 @@ class DocumentTest(unittest.TestCase):
|
|||||||
self.assertEqual(User.objects.first(), bob)
|
self.assertEqual(User.objects.first(), bob)
|
||||||
self.assertEqual(Book.objects.first(), hp)
|
self.assertEqual(Book.objects.first(), hp)
|
||||||
|
|
||||||
# DeRefecence
|
# DeReference
|
||||||
class AuthorBooks(Document):
|
class AuthorBooks(Document):
|
||||||
author = ReferenceField(User)
|
author = ReferenceField(User)
|
||||||
book = ReferenceField(Book)
|
book = ReferenceField(Book)
|
||||||
@ -3027,6 +3027,18 @@ class DocumentTest(unittest.TestCase):
|
|||||||
self.assertEqual(Book._get_collection(), get_db("testdb-2")[Book._get_collection_name()])
|
self.assertEqual(Book._get_collection(), get_db("testdb-2")[Book._get_collection_name()])
|
||||||
self.assertEqual(AuthorBooks._get_collection(), get_db("testdb-3")[AuthorBooks._get_collection_name()])
|
self.assertEqual(AuthorBooks._get_collection(), get_db("testdb-3")[AuthorBooks._get_collection_name()])
|
||||||
|
|
||||||
|
def test_db_alias_propagates(self):
|
||||||
|
"""db_alias propagates?
|
||||||
|
"""
|
||||||
|
class A(Document):
|
||||||
|
name = StringField()
|
||||||
|
meta = {"db_alias": "testdb-1", "allow_inheritance": True}
|
||||||
|
|
||||||
|
class B(A):
|
||||||
|
pass
|
||||||
|
|
||||||
|
self.assertEquals('testdb-1', B._meta.get('db_alias'))
|
||||||
|
|
||||||
def test_db_ref_usage(self):
|
def test_db_ref_usage(self):
|
||||||
""" DB Ref usage in __raw__ queries """
|
""" DB Ref usage in __raw__ queries """
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user