It looks like only one aliased table gets aliased correctly when joining to
multiple aliased tables.
Test case:
from __future__ import print_function
from sqlalchemy import Integer, String, select, Date, and_
from sqlalchemy import Column
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm.util import aliased
Base = declarative_base()
class Users(Base):
__tablename__ = "users"
id = Column(Integer, primary_key=True)
name = Column(String)
date = Column(Date)
a = aliased(Users, name="aaa")
b = aliased(Users, name="bbb")
c = aliased(Users, name="ccc")
sel = select([a.name, b.name]).select_from(
c.__table__.join(
a.__table__,
a.name == c.name,
).join(
b.__table__,
b.date == c.date,
)
)
print(sel)
Output:
SELECT aaa.name, bbb.name
FROM users AS bbb, users JOIN users ON aaa.name = ccc.name JOIN users ON
bbb.date = ccc.date
I expect there to be three "AS" clauses in this sql, but there is only one,
e.g.
SELECT aaa.name, bbb.name
FROM users AS ccc JOIN users AS aaa ON aaa.name = ccc.name JOIN users AS
bbb ON bbb.date = ccc.date
Using sqlalchemy 1.0.9, python 3.4.3
--
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/d/optout.