Comment 3 for bug 181905

Revision history for this message
James Henstridge (jamesh) wrote :

For databases like PostgreSQL (at least), we should be able to generate working queries.

For foo.bars.find().set(title=u"hoho"), the following is valid in PG:

    UPDATE bar SET title='hoho' FROM link
      WHERE link.foo_id = 20 AND bar.id = link.bar_id;

Similarly, for foo.bars.find().remove(), the following works:

    DELETE FROM bar USING link
      WHERE link.foo_id = 20 AND bar.id = link.bar_id;

It looks like MySQL supports "DELETE ... USING", but has a different syntax for the UPDATE:

    UPDATE bar, link SET bar.title='hoho' FROM link
      WHERE link.foo_id = 20 AND bar.id = link.bar_id;

It doesn't look like SQLite supports this type of feature for either UPDATE or DELETE. So it will probably be necessary to do per-backend statement compilation to solve this bug.