[Dbix-class] Overloads in ResultSet and Stacktraces
Matt S Trout
dbix-class at trout.me.uk
Sat Sep 27 17:34:39 BST 2008
On Fri, Sep 19, 2008 at 11:46:01AM -0400, Aaron Schrab wrote:
> I'm working on a Catalyst project that uses DBIx::Class (0.08010) as the
> ORM, and the StackTrace plugin. This combination is causing a problem.
>
> In one section of this project I'm using a ResultSet to create a new row
> in a table as part of a transaction. In some cases the new row will
> violate a unique constraint, so I want to catch those errors and notify
> the user. However, the error that I get in $@ isn't due to the
> constraint violation.
>
> Instead the error is due to trying to count the number of items in the
> ResultSet while in a failed transaction. I've traced this to the
> Devel::StackTrace module attempting to stringify the ResultSet. Because
> the string conversion operator isn't implemented but the numeric
> conversion operator is, the latter is used in place of the former. This
> results in trying to do a sql count before the failed transaction is
> rolled back.
>
> I've worked around this problem by overloading string conversion to
> return a static string, but there may be better ways to avoid this
> problem.
Two things really want doing here:
(1) Patching ResultSet to use overload::StrVal, with tests
(2) Patching StackTrace to -not- respect overloading by default, with an
option to turn it back on.
First patch should come here, second one should go to catalyst-dev.
I'll happily pick up both, -provided- they turn up with tests :)
--
Matt S Trout Need help with your Catalyst or DBIx::Class project?
Technical Director http://www.shadowcat.co.uk/catalyst/
Shadowcat Systems Ltd. Want a managed development or deployment platform?
http://chainsawblues.vox.com/ http://www.shadowcat.co.uk/servers/
More information about the DBIx-Class
mailing list