Hi there,
I have these two tables (with very long column names and most of them
with the same names in both tables) I want to join. Since I will be
processing the results afterwards, I would like to have shorten names
to type less and clearly differentiated names to avoid conflicts.
So I pass the use_labels param to the select statement and apply
labels to both tables.
E.g.:
select([service.alias('a'), history.alias('b')], use_labels=True)
which generates the following sql:
select a.id as a_id, a.valid_flag as a_valid_flag, a.code as
a_code, ...more columns with 'a' alias, b.id as b_id, ... more column
with 'b' alias from service as a, history as b...
The problem is when I add a where clause (or I think it's the
problem):
select([service.alias('a'), history.alias('b')],
and_(service.c.id==history.c.id, service.c.valid_flag==True),
use_labels=True)
turns out it generates the following sql:
select a.id as a_id, a.valid_flag as a_valid_flag, a.code as
a_code, ...more columns with 'a' alias, b.id as b_id, ... more column
with 'b' alias from service as a, history as b, service, history where
service.id=history.id and service.valid_flag='f'
As you can see it ignores the existence of the aliased tables and use
a new copy of them to make the join, generating a cartesian join.
How can I fix this situation?
TIA,
Mariano
--
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.