[Catalyst] Duplicate entries with C::P::Session::Store::DBIC and MySQL

Tobias Kremer list at funkreich.de
Tue Jul 29 11:24:33 BST 2008


Quoting Matt S Trout <dbix-class at trout.me.uk>:
> On Mon, Jul 28, 2008 at 01:03:52PM +0200, Tobias Kremer wrote:
> > Is there anything speaking against wrapping line 52 of the DBIC backend
> > class with an eval to trap this duplicate error and ignore it silently
> > (or just warn about it) except the fact that it's trying to fix something
> > that probably should be the database's task?
> Don't see why not.

Cool :)

> The interesting question i how we make a test for it.
> Mm ... ah. How about a debugcb sub that checks for the SELECT and does the
> insert in the background so the row's there when the DBIC-driven INSERT
> happens?

I have a working test case now which involves a custom debugobj with a query_end
method that injects an INSERT after the SELECT for the flash happened. debugcb()
didn't work for me. I suppose it's called _before_ the SELECT is executed.

However, I'm unsure how to detect if the error really was a duplicate entry
error or something else.

  die $@ if $@ && $@ !~ /duplicate/i;

This doesn't work because different DBs throw different errors.

Any thoughts?

--Tobias



More information about the Catalyst mailing list