summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2014-02-10 17:43:37 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2014-02-10 17:43:37 -0500
commit7d56f6c8077a3d9aeae3aed2cc548ca4e350161b (patch)
tree446fb6f0f94f68e6ea22a94e3ad8abdfa44293bd
parent093ce65c5fc741340e68c39b298787f36f6e98a6 (diff)
downloadsqlalchemy-7d56f6c8077a3d9aeae3aed2cc548ca4e350161b.tar.gz
this example doesn't work, we don't really have a solution for this as far as automating this pattern
-rw-r--r--lib/sqlalchemy/ext/declarative/__init__.py31
1 files changed, 0 insertions, 31 deletions
diff --git a/lib/sqlalchemy/ext/declarative/__init__.py b/lib/sqlalchemy/ext/declarative/__init__.py
index 0ee4e33fd..e878e362d 100644
--- a/lib/sqlalchemy/ext/declarative/__init__.py
+++ b/lib/sqlalchemy/ext/declarative/__init__.py
@@ -1122,37 +1122,6 @@ inheritance::
primary_language = Column(String(50))
__mapper_args__ = {'polymorphic_identity': 'engineer'}
-If you want to use a similar pattern with a mix of single and joined
-table inheritance, you would need a slightly different mixin and use
-it on any joined table child classes in addition to their parent
-classes::
-
- from sqlalchemy.ext.declarative import declared_attr
- from sqlalchemy.ext.declarative import has_inherited_table
-
- class Tablename(object):
- @declared_attr
- def __tablename__(cls):
- if (has_inherited_table(cls) and
- Tablename not in cls.__bases__):
- return None
- return cls.__name__.lower()
-
- class Person(Tablename, Base):
- id = Column(Integer, primary_key=True)
- discriminator = Column('type', String(50))
- __mapper_args__ = {'polymorphic_on': discriminator}
-
- # This is single table inheritance
- class Engineer(Person):
- primary_language = Column(String(50))
- __mapper_args__ = {'polymorphic_identity': 'engineer'}
-
- # This is joined table inheritance
- class Manager(Tablename, Person):
- id = Column(Integer, ForeignKey('person.id'), primary_key=True)
- preferred_recreation = Column(String(50))
- __mapper_args__ = {'polymorphic_identity': 'engineer'}
Combining Table/Mapper Arguments from Multiple Mixins
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~