Hi, I created a class "Resource", and its subclass "BasePrAc" as
below:
class Resource(BaseClass.BaseClass):
__tablename__ = "resources"
id = Column("id", Integer, primary_key=True, key="id")
class BasePrAc(Resource.Resource):
__tablename__ = "base_products_accessories"
id = Column("id", Integer, ForeignKey("resources.id"),
primary_key=True)
And when I try to "query.join" BasePrAc or its subquery, it always
gives me the OperationalError(1060, "Duplicate column name 'id'"). I
checked the generated SQL statement, and found the subquery part shown
as below:
"..... INNER JOIN (SELECT resources.id AS id,
base_products_accessories.id AS id,
base_products_accessories.polymorphic_identity AS
polymorphic_identity, ...."
As you see, there are two "AS id" in the statement and causing the
error. I was wondering why it asks "resource.id" which I didn't
specify, and it would know that BasePrAc.id is equal to Resource.id
since BasePrAc class is the subclass of Resource class. Some suggested
to use "alias" for joining, and I tried but it didn't work. Besides, I
am hoping not to use alias everytime, so joining things could be more
generic.
I will appreciate if you have any advise for this situation.
Thank you very much, and have a nice day.
W
--
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.