this is fixed in r462bd17d7ea2 however you'll want to use __mapper_args__ and 
not "mapper_args" in your classes, also the issue only exists if you didn't 
specify "inherits" yourself, so since you're already explicitly referencing the 
superclass you can work around easily by saying:

__mapper_args__ = {
'inherits':foo.Foo
}


On Jun 14, 2011, at 9:04 AM, Filip Zyzniewski - Tefnet wrote:

> import sqlalchemy
> import sqlalchemy.ext.declarative
> 
> Base = sqlalchemy.ext.declarative.declarative_base()
> 
> engine = sqlalchemy.create_engine('sqlite:///:memory:', echo = False)
> 
> session = sqlalchemy.orm.scoped_session(
>    sqlalchemy.orm.sessionmaker(
>        bind = engine,
>        autocommit = False
>    )
> )
> 
> Base.metadata.bind = engine
> 
> class SomeObj(Base):
>    __tablename__ = "someobj"
>    Id = sqlalchemy.Column( sqlalchemy.types.Integer, primary_key=True,
> autoincrement=True)
>    objType = sqlalchemy.Column(sqlalchemy.types.String(128), index =
> True, nullable = False)
>    __mapper_args__ = {
>        'polymorphic_identity': __tablename__,
>        'polymorphic_on': objType
>    }
> 
> import bar
> 
> 
> =======================================> foo.py <==
> import sqlalchemy
> import names
> 
> class Foo(names.SomeObj):
>    __tablename__ = 'foo_foo'
> 
>    Id = sqlalchemy.Column(
>        sqlalchemy.types.Integer(),
>        sqlalchemy.schema.ForeignKey(names.SomeObj.Id),
>        primary_key = True
>    )
> 
>    mapper_args = {
>        'inherit_condition': Id == names.SomeObj.Id,
>        'polymorphic_identity': __tablename__,
>    }
> 
> 
> =======================================> bar.py <==
> import sqlalchemy
> import foo
> 
> class Foo(foo.Foo):
>    __tablename__ = 'bar_foo'
> 
>    Id = sqlalchemy.Column(
>        sqlalchemy.types.Integer(),
>        sqlalchemy.schema.ForeignKey(foo.Foo.Id),
>        primary_key = True
>    )
> 
>    mapper_args = {
>        'inherit_condition': Id == foo.Foo.Id,
>        'polymorphic_identity': __tablename__,
>    }
> 
> =====================================

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to