SQLAlchemy 0.8 is generating wrong SQL for my simple self-join --
class ScheduledJob(Base):
Id = Column('Id', Integer, primary_key=True)
DependentJob1 = Column('DependentJob1', Integer)
DJ1 = aliased(ScheduledJob)
query = dbsession.query(ScheduledJob.Id, DJ1.Id).outerjoin(
DJ1, ScheduledJob.DependentJob1==DJ1.Id)
print query
prints the wrong SQL --
SELECT "ScheduledJob"."Id" AS "ScheduledJob_Id"
FROM "ScheduledJob" LEFT OUTER JOIN "ScheduledJob" AS "ScheduledJob_1" ON
"ScheduledJob"."DependentJob1" = "ScheduledJob"."Id"
while it should have been --
SELECT "ScheduledJob"."Id" AS "ScheduledJob_Id",
"ScheduledJob_1"."Id" AS "ScheduledJob_1_Id"
FROM "ScheduledJob" LEFT OUTER JOIN "ScheduledJob" AS "ScheduledJob_1" ON
"ScheduledJob"."DependentJob1" = "ScheduledJob_1"."Id"
What could have gone so wrong? Any pointer will be greatly appreciated.
BTW, I'm mapping multiple databases, could it be related to this problem?
Sorry this is a "repost" of my SO question (which has not seen an answer
for two days)
http://stackoverflow.com/questions/19315202/sqlalchemy-generates-wrong-sql-for-aliased-and-self-join
Many thanks in advance.
Jerry
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.