summaryrefslogtreecommitdiff
path: root/test/orm/inheritance/test_basic.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2010-11-20 13:44:03 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2010-11-20 13:44:03 -0500
commit007344a40a9ec8f1abed3af1ff7c1473031f7b50 (patch)
tree0b8e0e1bffbc7a0d49a336474e14e3b895001228 /test/orm/inheritance/test_basic.py
parent4af7bc6cfc8790bf6ef267c059a47952de7c64fa (diff)
downloadsqlalchemy-007344a40a9ec8f1abed3af1ff7c1473031f7b50.tar.gz
- the ordering of columns in a multi-column property now is in
reverse order of which they were added to the property. A typical effect of this is that the ".id" attribute on a joined-inheritance subclass, where both parent/child tables name the PK column ".id", will reference the ".id" column of the child table, not the parent, thus allowing join conditions and such to be constructed more intuitively. This is a behavior change for some joined-table inheritance queries. [ticket:1892] - it's now an error condition to map to a join where multiple same-named columns from each table combine themselves implicitly. An explicit mention in the "properties" dictionary should be specified, using a list of columns, or column_property(*cols) with declarative. [ticket:1892]
Diffstat (limited to 'test/orm/inheritance/test_basic.py')
-rw-r--r--test/orm/inheritance/test_basic.py37
1 files changed, 12 insertions, 25 deletions
diff --git a/test/orm/inheritance/test_basic.py b/test/orm/inheritance/test_basic.py
index c6dec16b7..b9956f286 100644
--- a/test/orm/inheritance/test_basic.py
+++ b/test/orm/inheritance/test_basic.py
@@ -128,7 +128,6 @@ class PolymorphicOnNotLocalTest(_base.MappedTest):
)
-
class FalseDiscriminatorTest(_base.MappedTest):
@classmethod
def define_tables(cls, metadata):
@@ -781,8 +780,8 @@ class DistinctPKTest(_base.MappedTest):
primary_key=[person_table.c.id, employee_table.c.id])
assert_raises_message(sa_exc.SAWarning,
r"On mapper Mapper\|Employee\|employees, "
- "primary key column 'employees.id' is being "
- "combined with distinct primary key column 'persons.id' "
+ "primary key column 'persons.id' is being "
+ "combined with distinct primary key column 'employees.id' "
"in attribute 'id'. Use explicit properties to give "
"each column its own mapped attribute name.",
self._do_test, True
@@ -910,7 +909,7 @@ class OverrideColKeyTest(_base.MappedTest):
# column of both tables.
eq_(
class_mapper(Sub).get_property('base_id').columns,
- [base.c.base_id, subtable.c.base_id]
+ [subtable.c.base_id, base.c.base_id]
)
def test_override_explicit(self):
@@ -982,11 +981,9 @@ class OverrideColKeyTest(_base.MappedTest):
# PK col
assert s2.id == s2.base_id != 15
- @testing.emits_warning(r'Implicit')
def test_override_implicit(self):
- # this is how the pattern looks intuitively when
- # using declarative.
- # fixed as part of [ticket:1111]
+ # this is originally [ticket:1111].
+ # the pattern here is now disallowed by [ticket:1892]
class Base(object):
pass
@@ -996,26 +993,16 @@ class OverrideColKeyTest(_base.MappedTest):
mapper(Base, base, properties={
'id':base.c.base_id
})
- mapper(Sub, subtable, inherits=Base, properties={
- 'id':subtable.c.base_id
- })
+ def go():
+ mapper(Sub, subtable, inherits=Base, properties={
+ 'id':subtable.c.base_id
+ })
# Sub mapper compilation needs to detect that "base.c.base_id"
# is renamed in the inherited mapper as "id", even though
- # it has its own "id" property. Sub's "id" property
- # gets joined normally with the extra column.
-
- eq_(
- set(class_mapper(Sub).get_property('id').columns),
- set([base.c.base_id, subtable.c.base_id])
- )
-
- s1 = Sub()
- s1.id = 10
- sess = create_session()
- sess.add(s1)
- sess.flush()
- assert sess.query(Sub).get(10) is s1
+ # it has its own "id" property. It then generates
+ # an exception in 0.7 due to the implicit conflict.
+ assert_raises(sa_exc.InvalidRequestError, go)
def test_plain_descriptor(self):
"""test that descriptors prevent inheritance from propigating properties to subclasses."""