2008/10/28 Gaetan de Menten <[EMAIL PROTECTED]>:
>
> On Mon, Oct 27, 2008 at 6:52 PM, Alex Marandon <[EMAIL PROTECTED]> wrote:
>
>> Just a quick word to mention that I've just posted a (ridiculously
>> simple) patch at http://elixir.ematia.de/trac/ticket/34
>
> Thanks. But this introduces an extra query for all DB, which I'd
> prefer to avoid. Could you test if it works with "as_scalar" instead?

Using as_scalar leads to generating this type of subquery that MySQL
doesn't support. I've tested it and unfortunately it doesn't work.

The problem with MySQL is documented at
http://dev.mysql.com/doc/refman/5.0/en/subquery-errors.html  "You can
use a subquery for assignment within an UPDATE statement because
subqueries are legal in UPDATE and DELETE statements as well as in
SELECT statements. However, you cannot use the same table (in this
case, table t1) for both the subquery's FROM clause and the update
target."

The error message returned by MySQL is:
OperationalError: (OperationalError) (1093, "You can't specify target
table 'todos' for update in FROM clause") u'UPDATE todos SET
position=(SELECT max(todos.position) + %s AS anon_1 \nFROM todos
\nWHERE todos.owner_id = %s) WHERE todos.id = %s' [1, 1L, 3L]

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"SQLElixir" 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/sqlelixir?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to