[Dbix-class] how to empty a Table? when there is no primary key

demerphq demerphq at gmail.com
Wed Mar 27 13:19:26 GMT 2013


On 26 March 2013 20:12, Peter Rabbitson <rabbit+dbic at rabbit.us> wrote:
> 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.

I would not expect this to change. FK's are a major performance
bottleneck and any high load situation that can get away with it will
not use them.

Yves

-- 
perl -Mre=debug -e "/just|another|perl|hacker/"



More information about the DBIx-Class mailing list