this is ticket #1074. A slightly klunky workaround for now is: col = t1.c.c1.in_([select([t1.c.c1]).as_scalar()])
On Jun 12, 2008, at 10:04 AM, casbon wrote: > > Hi All, > > I am seeing something I didn't expect using in_. > > Here is a simple example, exactly as I expect: > > > In [13]: col = Trade.c.TradeId.in_([1,2]) > > In [14]: sel = select([col]) > > In [15]: print col > "Trade"."TradeId" IN (?, ?) > > In [16]: print sel > SELECT "Trade"."TradeId" IN (?, ?) AS anon_1 > FROM "Trade" > > > But now, if I use a subselect, I see a problem: > > > > In [17]: col = Trade.c.TradeId.in_(select([Trade.c.TradeId])) > > In [18]: sel = select([col]) > > In [19]: print col > "Trade"."TradeId" IN (SELECT "Trade"."TradeId" > FROM "Trade") > > In [20]: print sel > SELECT "Trade"."TradeId" IN (SELECT "Trade"."TradeId" > FROM "Trade") AS anon_1 > FROM "Trade", (SELECT "Trade"."TradeId" AS "TradeId" > FROM "Trade") > > > The column definition (col) is as expected, but the select definition > (sel) is strange. It selects two things and generates n^2 rows. How > can I get the select I expect: > > SELECT "Trade"."TradeId" IN (SELECT "Trade"."TradeId" > FROM "Trade") AS anon_1 > FROM "Trade" > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---