[Dbix-class] Adding comments to generated queries
fREW Schmidt
frioux at gmail.com
Thu May 31 02:09:59 GMT 2012
On Wed, May 30, 2012 at 6:29 PM, Bill Moseley <moseley at hank.org> wrote:
> Aren't those for enhancing the debug object and logging from the app?
>
You're right of course. I don't know of an out of the box solution, but
maybe you could consider a runtime applied role to the sql_maker? Or to be
clear:
package MyApp::TraitFor::SQLMaker::CommentLogs;
use Moo::Role;
around select =3D> sub { ... };
1;
...
use Role::Tiny;
Role::Tiny->apply_roles_to_object($schema->storage->sql_maker,
'MyApp::TraitFor::SQLMaker::CommentLogs');
Of course, you'll need to put the stack trace somewhere to get jammed into
the sql. I have no idea when or where you'll want to do that, but it's
certainly feasible.
Also note: this is getting very much into dangerous territory. If you do
this make sure you write a lot of tests as this is something that is not
quite encouraged and thus only tenuously supported.
-- =
fREW Schmidt
http://blog.afoolishmanifesto.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20120530/d2d=
a99a1/attachment-0001.htm
More information about the DBIx-Class
mailing list