Added :meth:`.baked.Result.scalar` and :meth:`.baked.Result.count`
to the "baked" query system.
+ .. change:: 3895
+ :tags: bug, orm, declarative
+ :tickets: 3895
+
+ Fixed bug where the "automatic exclude" feature of declarative that
+ ensures a column local to a single table inheritance subclass does
+ not appear as an attribute on other derivations of the base would
+ not take effect for multiple levels of subclassing from the base.
+
.. change:: 3893
:tags: bug, orm
:tickets: 3893
if 'exclude_properties' not in mapper_args:
mapper_args['exclude_properties'] = exclude_properties = \
- set([c.key for c in inherited_table.c
- if c not in inherited_mapper._columntoproperty])
+ set(
+ [c.key for c in inherited_table.c
+ if c not in inherited_mapper._columntoproperty]
+ ).union(
+ inherited_mapper.exclude_properties or ()
+ )
exclude_properties.difference_update(
[c.key for c in self.declared_columns])
from sqlalchemy.testing import eq_, assert_raises, \
- assert_raises_message, is_, is_true
+ assert_raises_message, is_, is_true, is_false
from sqlalchemy.ext import declarative as decl
import sqlalchemy as sa
from sqlalchemy import testing
).one(),
Engineer(name='vlad', primary_language='cobol'))
+ def test_single_cols_on_sub_base_of_joined(self):
+ """test [ticket:3895]"""
+
+ class Person(Base):
+ __tablename__ = "person"
+
+ id = Column(Integer, primary_key=True)
+ type = Column(String)
+
+ __mapper_args__ = {
+ "polymorphic_on": type,
+ }
+
+ class Contractor(Person):
+ contractor_field = Column(String)
+
+ __mapper_args__ = {
+ "polymorphic_identity": "contractor",
+ }
+
+ class Employee(Person):
+ __tablename__ = "employee"
+
+ id = Column(Integer, ForeignKey(Person.id), primary_key=True)
+
+ class Engineer(Employee):
+ __mapper_args__ = {
+ "polymorphic_identity": "engineer",
+ }
+
+ configure_mappers()
+
+ is_false(hasattr(Person, 'contractor_field'))
+ is_true(hasattr(Contractor, 'contractor_field'))
+ is_false(hasattr(Employee, 'contractor_field'))
+ is_false(hasattr(Engineer, 'contractor_field'))
+
def test_single_cols_on_sub_to_joined(self):
"""test [ticket:3797]"""