[Dbix-class] Adding comments to generated queries

Bill Moseley moseley at hank.org
Thu May 31 12:50:57 GMT 2012


On Wed, May 30, 2012 at 9:09 PM, fREW Schmidt <frioux at gmail.com> wrote:

>
>    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');
>

Thanks, that's helpful.   And something good to know about in general.



> 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.
>

Well the "problem" that apparently needs to get solved is to simply find
the code that generated a specific query seen in the Postgresql query log.
  I guess there's been a few times when Postgresql gets hammered in
production and it hasn't been easy to find the code generating a specific
query.  (Sounds like a QA/testing problem, though.)   Maybe the URI
requested or Catalyst action name might be enough of a comment to help
track it back to the app.



> 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.
>

That's more supportive of this idea than I would be. :)


Thanks,


-- =

Bill Moseley
moseley at hank.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20120531/0aa=
ddb92/attachment.htm


More information about the DBIx-Class mailing list