[Dbix-class] how to empty a Table? when there is no primary key
David Cantrell
david at cantrell.org.uk
Mon Mar 25 15:57:45 GMT 2013
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.
--
David Cantrell | Cake Smuggler Extraordinaire
comparative and superlative explained:
<Huhn> worse, worser, worsest, worsted, wasted
More information about the DBIx-Class
mailing list