Peter Edwards wrote:
On 6 July 2011 15:01, Dave Howorth <[email protected]> wrote:

    I have a DBIC class made up using a UNION, something like this
     __PACKAGE__->result_source_instance->is_virtual(1);
     __PACKAGE__->result_source_instance->view_definition(
      "SELECT
           sp_id AS id,

...
    I've discovered that this doesn't work:

     $node_rs->search({status => 'obsolete' })->delete;

I thought you couldn't Delete through a View in most databases?

You should be able to do any of insert/update/delete through a View where resolving that is logically possible; being able to treat views as ordinary tables in all respects where possible is part of what makes a relational database.

And deletes through a union are a very simple case that should be easily supported; you just do the same delete on all of the tables in the union.

Some DBMSs do natively support writing to views, and for those that don't, DBIC should be able to implement it, especially for simpler cases like deletes on simple union views. If DBIC doesn't do this, its just a matter of tuits.

-- Darren Duncan

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[email protected]

Reply via email to