Hi,
I'm curious why mapped Selectables are named the way they are.
Consider the following code:
from sqlalchemy import *
metadata = BoundMetaData("...")
class Data(object):
pass
table1 = Table("table1", metadata,
Column("id", Integer, nullable=False,
primary_key=True),
)
table2 = Table("table2", metadata,
Column("id", Integer, nullable=False,
primary_key=True),
Column("fk", Integer, ForeignKey("table1.id")),
)
table = join(table1, table2, table1.c.id == table2.c.fk)
mapper(Data, table)
print table.c.keys()
# This prints ['table1_id', 'table2_id', 'table2_fk'] as expected.
# Now let us delete the mapper and then add a select to the join:
table = join(table1, table2.select(table2.c.id == 42).alias("s"),
table1.c.id == table2.c.fk)
mapper(Data, table)
print table.c.keys()
# This prints ['table1_id', 's_id', 's_fk'], also as expected.
# Now let us add the select in a different position. (Assume that
mappers are deleted again.)
table = join(table1, table2, table1.c.id ==
table2.c.fk).select(table2.c.id == 42).alias("s")
mapper(Data, table)
print table.c.keys()
# This prints ['id', 'fk']. Shouldn't there be three columns? And
where is the prefix "s"?
Best regards
Klaus
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---