Add support for sql comments

67 views
Skip to first unread message

grosser

unread,
Jan 4, 2013, 8:59:34 PM1/4/13
to rubyonra...@googlegroups.com

It would be great to be able to annotate sql with comments to tell where a query came from/or user/account runs it -> visible in slow query log and mysql status

User.where(xxx).comment("user.rb:11")
-> SELECT * FROM users WHERE xxx /* user.rb:11 */


User.where(xxx).comment("doing slow stuff in the console: do not kill")

does this sound good -> would a patch be accepted / did anyone already build something similar ?

Aaron Patterson

unread,
Jan 5, 2013, 8:24:44 PM1/5/13
to rubyonra...@googlegroups.com
On Fri, Jan 04, 2013 at 05:59:34PM -0800, grosser wrote:
>
>
> It would be great to be able to annotate sql with comments to tell where a
> query came from/or user/account runs it -> visible in slow query log and
> mysql status
>
> User.where(xxx).comment("user.rb:11")
> -> SELECT * FROM users WHERE xxx /* user.rb:11 */
>
>
> User.where(xxx).comment("doing slow stuff in the console: do not kill")
>
>
> does this sound good -> would a patch be accepted

I would accept support in ARel, but I'm not sure about adding the
`comment` method to AR::Relation. We'll have to discuss it more, but
the first step is to put it in ARel.

--
Aaron Patterson
http://tenderlovemaking.com/
Reply all
Reply to author
Forward
0 new messages