Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turn off Active Record's verbose_query_logs when using the console #31688

Closed
dhh opened this issue Jan 12, 2018 · 1 comment · Fixed by #31690
Closed

Turn off Active Record's verbose_query_logs when using the console #31688

dhh opened this issue Jan 12, 2018 · 1 comment · Fixed by #31690

Comments

@dhh
Copy link
Member

dhh commented Jan 12, 2018

When interacting with Active Record in the console, the verbose_query_log setting adds a lot of noise:

irb(main):009:0> Topic.first.messages
  Topic Load (0.1ms)  SELECT  "topics".* FROM "topics" ORDER BY "topics"."id" ASC LIMIT $1  [["LIMIT", 1]]
  ↳ (irb):9
  Message Load (0.3ms)  SELECT  "messages".* FROM "messages" WHERE "messages"."topic_id" = $1 LIMIT $2  [["topic_id", 1], ["LIMIT", 11]]
  ↳ /Users/david/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor/command.rb:27
=> #<ActiveRecord::Associations::CollectionProxy []>

This feature should be turned off when using the console.

cc @olivierlacan

@dhh dhh added this to the 5.2.0 milestone Jan 12, 2018
@olivierlacan
Copy link
Contributor

olivierlacan commented Jan 12, 2018 via email

@dhh dhh removed this from the 5.2.0 milestone Jan 18, 2018
olivierlacan added a commit to olivierlacan/rails that referenced this issue Jan 23, 2018
Should fix rails#31688 unless someone can point me to a better way to achieve
this goal. Essentially David's point was that verbose query logging when
enabled in Rails console tends to make things very noisy.

That's especially true if we display absolute paths to callsites which
sadly is still the case when we detect a caller that isn't part of the
Rails application — think gems.

Discussed this with both @matthewd and @rafaelfranca and went back and
forth between enabling if defined?(Rails::Server) or this implementation
and this one makes more sense for now.

Long term I think it'll make sense to let people override this default
disabling in Rails Console because they might want to use the feature
but for now it feels like the correct default behavior.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants