Skip to content

Commit

Permalink
Hello 0.1.4 version!
Browse files Browse the repository at this point in the history
  • Loading branch information
uralbash committed Jun 19, 2015
1 parent 3c9a43c commit adb1841
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 3 deletions.
10 changes: 10 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
0.1.4 (2015-06-19)
==================

- delete method ``get_pk_with_class_name``

Bug Fixes
---------

- fix ``_get_tree_table`` function for inheritance models

0.1.3 (2015-06-17)
==================

Expand Down
2 changes: 1 addition & 1 deletion sqlalchemy_mptt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from .mixins import BaseNestedSets
from .events import TreesManager

__version__ = "0.1.4.dev1"
__version__ = "0.1.4"
__mixins__ = [BaseNestedSets]
__all__ = ['BaseNestedSets', 'mptt_sessionmaker']

Expand Down
2 changes: 1 addition & 1 deletion sqlalchemy_mptt/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def _insert_subtree(table, connection, node_size,

def _get_tree_table(mapper):
for table in mapper.tables:
if all(key in table.c for key in ['level', ]):
if all(key in table.c for key in ['level', 'lft', 'rgt', 'parent_id']):
return table


Expand Down
1 change: 1 addition & 0 deletions sqlalchemy_mptt/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def add(self, model, fixtures):
if hasattr(model, 'sqlalchemy_mptt_pk_name'):
fixture[model.sqlalchemy_mptt_pk_name] = fixture.pop('id')
self.session.add(model(**fixture))
self.session.flush()


class TreeTestingMixin(
Expand Down
52 changes: 51 additions & 1 deletion sqlalchemy_mptt/tests/test_inheritance.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,61 @@ def test_rebuild(self):
# hierarchies:
# http://docs.sqlalchemy.org/en/rel_0_9/orm/query.html?highlight=update#sqlalchemy.orm.query.Query.update
#
# tl;dr: This test will always fail on specialized classes.
# This test will always fail on specialized classes.
try:
super(TestSpecializedTree, self).test_rebuild()
except Exception:
import nose
raise nose.SkipTest()
else:
raise AssertionError('Failure expected') # pragma: no cover


Base2 = declarative_base()


class BaseInheritance(Base2):
__tablename__ = "base_inheritance"

ppk = sa.Column('idd', sa.Integer, primary_key=True)
type = sa.Column(sa.Integer, default=0)
visible = sa.Column(sa.Boolean)

__mapper_args__ = {
'polymorphic_identity': 0,
'polymorphic_on': type,
}

def __repr__(self):
return "<Node (%s)>" % self.ppk


class InheritanceTree(BaseInheritance, BaseNestedSets):
__tablename__ = "inheriance_tree"

ppk = sa.Column('idd', sa.Integer, sa.ForeignKey(BaseInheritance.ppk),
primary_key=True)
sqlalchemy_mptt_pk_name = 'ppk'

__mapper_args__ = {
'polymorphic_identity': 1,
}


class TestInheritanceTree(TreeTestingMixin, unittest.TestCase):
base = Base2
model = InheritanceTree

def test_rebuild(self):
# See the following URL for caveats when using update on mapped
# hierarchies:
# http://docs.sqlalchemy.org/en/rel_0_9/orm/query.html?highlight=update#sqlalchemy.orm.query.Query.update
#
# This test will always fail on specialized classes.
try:
super(TestInheritanceTree, self).test_rebuild()
except Exception:
import nose
raise nose.SkipTest()
else:
raise AssertionError('Failure expected') # pragma: no cover

0 comments on commit adb1841

Please sign in to comment.