# Add support for sql comments

**URL:** <https://discuss.rubyonrails.org/t/add-support-for-sql-comments/66071>\
**Category:** rubyonrails-core\
**Created:** [January 5, 2013, 1:59am UTC](https://discuss.rubyonrails.org/t/add-support-for-sql-comments/66071 "2013-01-05T01:59:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![grosser](https://avatars.discourse-cdn.com/v4/letter/g/d2c977/32.png) [@grosser](https://discuss.rubyonrails.org/u/grosser)\
**Post date:** [January 5, 2013, 1:59am UTC](https://discuss.rubyonrails.org/t/add-support-for-sql-comments/66071/1 "2013-01-05T01:59:34Z")

</div>

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

```ruby

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 ?

---

<div class="post-metadata">

**Author:** ![Aaron\_Patterson3](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@Aaron\_Patterson3](https://discuss.rubyonrails.org/u/Aaron_Patterson3)\
**Post date:** [January 6, 2013, 1:24am UTC](https://discuss.rubyonrails.org/t/add-support-for-sql-comments/66071/2 "2013-01-06T01:24:44Z")

</div>

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.
