On Mon, Mar 25, 2013 at 03:57:45PM +0000, David Cantrell wrote:
> On Mon, Mar 25, 2013 at 11:58:31AM +1300, Paul Findlay wrote:
> > > I tried to use delete_all, but there is no primary key in the table so it 
> > > failed. what else can i do?
> > 
> > There is a discussion in the manual about this:
> > https://metacpan.org/module/DBIx::Class::Manual::Intro#The-Significance-and-Importance-of-Primary-Keys
> > 
> > But you could alternatively use
> > $schema->resultset('Mytable')->delete;
> > 
> > But this won't execute any on-delete triggers or cascade to MyTable's 
> > relationships.
> 
> I've always thought that this is something that should be handled by the
> database, not by DBIx::Class - or at least that it should be something
> that you have to explicitly turn on in DBIx::Class to support data
> sources which don't really do relationships.
> 

When DBIC was first worked on (2005) most available data sources either 
did not handle FK constraints or (much more often the case, even today) 
did not have them declared. As such the default of cascade_delete [1] is 
true for has_many's, as it is generally harmless (though wasteful) if 
FK-Cs are present, but is life-saving when they are not.

There is a plan on how to take folks "off the needle" but it requires a 
bit more work in the ResultSource area and eeryone capable of doing it 
has been busy lately.

So really just a heads up as "should be getting fixed sooner rather than 
later"

Cheers

[1] https://metacpan.org/module/DBIx::Class::Relationship::Base#cascade_delete

_______________________________________________
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/dbix-class@lists.scsys.co.uk

Reply via email to