> Also, we've noticed (well, postgres did it), that the most internal > select (for that same B-level) of the polymorphic_union has 2 > "xxx.id AS id" columns:
FYI, the problem is made by polymorphic_union() which does a per-column renaming select over the A.join(B), and because the join has both id's A.id and B.id, it renames both into id: $$ selA = table_A.select( table_A.c.atype == 'A', ) $$ selB0= table_A.join( table_B) $$ print '---',selB0 --- "A" JOIN "B" ON "A".id = "B".id $$ selB = table_A.join( table_B).select( table_A.c.atype == 'B', ) $$ print '---',selB --- SELECT "A".name, "A".id, "A".atype, "B".bdata, "B".id FROM "A" JOIN "B" ON "A".id = "B".id WHERE "A".atype = ? $$ selAB = sql.union_all( selA, selB ) $$ print '---',selAB --- SELECT "A".name, "A".id, "A".atype FROM "A" WHERE "A".atype = ? UNION ALL SELECT "A".name, "A".id, "A".atype, "B".bdata, "B".id FROM "A" JOIN "B" ON "A".id = "B".id WHERE "A".atype = ? $$ aselA = selA.alias('ta') $$ aselB = selB.alias('tb') puAB = polymorphic_union( {'A':aselA, 'B':aselB }, None, 'pu') print '---', str(puAB) --- SELECT CAST(NULL AS TEXT) AS bdata, ta.atype, ta.name, ta.id FROM (SELECT "A".name AS name, "A".id AS id, "A".atype AS atype FROM "A" WHERE "A".atype = ?) AS ta UNION ALL SELECT tb.bdata, tb.atype, tb.name, tb.id FROM (SELECT "A".name AS name, "A".id AS id, "A".atype AS atype, "B".bdata AS bdata, "B".id AS id FROM "A" JOIN "B" ON "A".id = "B".id WHERE "A".atype = ?) AS tb ======== polymunion() sure can be fixed to avoid such duplications - but why the A.join(B) whould have them both .id's anyway? ciao svil --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---