Hi all,
I'm running SQLAlchemy 0.7.0, against MySQL 5.1. I'm having issues
with a field that I'd like shared between the classes in single table
inheritance that I would like to have referred to differently in the
subclasses:
class Post(Base):
__tablename__ = 'posts'
id = Column(Integer, primary_key = True)
type = Column(String(40))
data = Column(String(255))
__mapper_args__ = {'polymorphic_on': type}
class Link(Post):
__mapper_args__ = {'polymorphic_identity': 'link'}
url = Column('data', String(255))
When I run this, I get the following error:
sqlalchemy.exc.ArgumentError: Column 'data' on class <class
'api.models.posts.Link'> conflicts with existing column 'posts.data'
I searched for answers, and came across the following post:
http://www.mail-archive.com/[email protected]/msg20077.html
When I tried its solution, however, I get the error " TypeError:
getattr(): attribute name must be string" when the code actually gets
called.
The offending line of code is "return getattr(obj, self.name)" from
"Module sqlalchemy.orm.descriptor_props:53 in fget". In this case,
self.name is an sqlalchemy.orm.attributes.InstrumentedAttribute
object. If I cast it to a string, getattr returns the data that I
wanted.
Is there a better way to do what I'm trying to do, or is this a bug in
the code?
Thanks,
Dan
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.