Activity log for bug #682989

Date Who What changed Old value New value Message
2010-11-30 06:30:25 Jeroen T. Vermeulen bug added bug
2010-11-30 07:24:57 Thomas Herve storm: importance Undecided High
2010-11-30 07:25:09 Thomas Herve storm: status New Incomplete
2010-11-30 07:25:18 Thomas Herve storm: milestone 0.19
2010-11-30 07:25:18 Thomas Herve storm: assignee Thomas Herve (therve)
2010-11-30 08:13:49 Jeroen T. Vermeulen description We've got an important query in Launchpad doing a more extensive version of: Foo = ClassAlias(Table, "Foo") Bar = ClassAlias(Table, "Bar") bar_ids = [1, 2, 3] selection = Select( Foo.id, tables=[Foo, Bar], where=And( Foo.x == Bar.x, Bar.id.is_in(bar_ids), Foo.y == None, Bar.y == None )) store.find(Foo, Foo.id.is_in(selection)).set(attribute=value) This results in SQL of the form: UPDATE Table SET attribute = value WHERE Table.id IN ( SELECT Foo.id FROM Table AS Foo, Table AS Bar WHERE Foo.x = Bar.x AND Bar.id IN (1, 2, 3) AND Table.y IS NULL AND Table.y IS NULL ); The conditions "Foo.y == None" and "Bar.y == None" are both translated as "Table.y IS NULL"—which refers to the row being updated, not the rows referenced in the subquery! For Foo.y this is not a problem in this case, since id is a key and so the match on "Table.id IN (SELECT Foo.id)" guarantees that Table and Foo are actually the same row. But x is not a key (actually we have a more complex join condition here) and so I can't say the same for Bar.y! We've got an important query in Launchpad doing a more extensive version of: Foo = ClassAlias(Table, "Foo") Bar = ClassAlias(Table, "Bar") bar_ids = [1, 2, 3] selection = Select(     Foo.id,     tables=[Foo, Bar],     where=And(         Foo.x == Bar.x,         Bar.id.is_in(bar_ids),         Foo.y == None,         Bar.y == None     )) store.find(Table, Table.id.is_in(selection)).set(attribute=value) This results in SQL of the form: UPDATE Table SET attribute = value WHERE Table.id IN (     SELECT Foo.id     FROM Table AS Foo, Table AS Bar     WHERE         Foo.x = Bar.x AND         Bar.id IN (1, 2, 3) AND         Table.y IS NULL AND         Table.y IS NULL ); The conditions "Foo.y == None" and "Bar.y == None" are both translated as "Table.y IS NULL"—which refers to the row being updated, not the rows referenced in the subquery! For Foo.y this is not a problem in this case, since id is a key and so the match on "Table.id IN (SELECT Foo.id)" guarantees that Table and Foo are actually the same row. But x is not a key (actually we have a more complex join condition here) and so I can't say the same for Bar.y!
2010-11-30 08:27:25 Thomas Herve storm: status Incomplete New
2010-11-30 08:56:16 Thomas Herve storm: assignee Thomas Herve (therve)
2010-12-15 16:29:41 Edwin Grubbs summary set() ignores ClassAlias, updates wrong rows ClassAlias Reference is compiled to wrong sql
2011-05-02 04:28:39 William Grant bug added subscriber William Grant
2011-09-25 21:30:54 Barry Warsaw storm: milestone 0.19 0.20
2013-06-28 09:53:19 Free Ekanayaka storm: milestone 0.20 0.21
2019-09-20 07:50:30 Colin Watson storm: milestone 0.21 0.22
2019-11-21 11:20:56 Colin Watson storm: milestone 0.22 0.23
2020-03-18 15:42:08 Colin Watson storm: milestone 0.23