summaryrefslogtreecommitdiff
path: root/test/orm/inheritance/test_basic.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2015-06-29 13:47:27 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2015-06-29 13:49:44 -0400
commit4d6f4ed184b94e60d5d39eff7fae678d64e9aeaa (patch)
tree097988c3a6c6f3c3717f741ca963dc678a6f8aa5 /test/orm/inheritance/test_basic.py
parentfcb7c784e9479b9bff7de20c41a05bc1aa550ffb (diff)
downloadsqlalchemy-4d6f4ed184b94e60d5d39eff7fae678d64e9aeaa.tar.gz
- Fixed 1.0 regression where a "deferred" attribute would not populate
correctly if it were loaded within the "optimized inheritance load", which is a special SELECT emitted in the case of joined table inheritance used to populate expired or unloaded attributes against a joined table without loading the base table. This is related to the fact that SQLA 1.0 no longer guesses about loading deferred columns and must be directed explicitly. fixes #3468
Diffstat (limited to 'test/orm/inheritance/test_basic.py')
-rw-r--r--test/orm/inheritance/test_basic.py56
1 files changed, 56 insertions, 0 deletions
diff --git a/test/orm/inheritance/test_basic.py b/test/orm/inheritance/test_basic.py
index d8b2a44af..911d4bc5c 100644
--- a/test/orm/inheritance/test_basic.py
+++ b/test/orm/inheritance/test_basic.py
@@ -1148,6 +1148,62 @@ class FlushTest(fixtures.MappedTest):
sess.flush()
assert user_roles.count().scalar() == 1
+
+class OptimizedGetOnDeferredTest(fixtures.MappedTest):
+ """test that the 'optimized get' path accommodates deferred columns."""
+
+ @classmethod
+ def define_tables(cls, metadata):
+ Table(
+ "a", metadata,
+ Column('id', Integer, primary_key=True,
+ test_needs_autoincrement=True)
+ )
+ Table(
+ "b", metadata,
+ Column('id', Integer, ForeignKey('a.id'), primary_key=True),
+ Column('data', String(10))
+ )
+
+ @classmethod
+ def setup_classes(cls):
+ class A(cls.Basic):
+ pass
+
+ class B(A):
+ pass
+
+ @classmethod
+ def setup_mappers(cls):
+ A, B = cls.classes("A", "B")
+ a, b = cls.tables("a", "b")
+
+ mapper(A, a)
+ mapper(B, b, inherits=A, properties={
+ 'data': deferred(b.c.data),
+ 'expr': column_property(b.c.data + 'q', deferred=True)
+ })
+
+ def test_column_property(self):
+ A, B = self.classes("A", "B")
+ sess = Session()
+ b1 = B(data='x')
+ sess.add(b1)
+ sess.flush()
+
+ eq_(b1.expr, 'xq')
+
+ def test_expired_column(self):
+ A, B = self.classes("A", "B")
+ sess = Session()
+ b1 = B(data='x')
+ sess.add(b1)
+ sess.flush()
+ sess.expire(b1, ['data'])
+
+ eq_(b1.data, 'x')
+
+
class JoinedNoFKSortingTest(fixtures.MappedTest):
@classmethod
def define_tables(cls, metadata):