aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorNeeraj Singh <neerajdotname@gmail.com>2013-06-18 14:16:33 +0530
committerNeeraj Singh <neerajdotname@gmail.com>2013-06-19 17:37:27 +0530
commit6fb5f6f3d69662cc55a086f84f9caaca3eec1515 (patch)
tree456acb189b768bfd8f176439f471fc642ec5e5c5 /activerecord/test
parent615ad884579f416a7cfcd685a9aa9d124ab72a7a (diff)
downloadrails-6fb5f6f3d69662cc55a086f84f9caaca3eec1515.tar.gz
rails-6fb5f6f3d69662cc55a086f84f9caaca3eec1515.tar.bz2
rails-6fb5f6f3d69662cc55a086f84f9caaca3eec1515.zip
log the sql that is actually sent to the database
If I have a query that produces sql `WHERE "users"."name" = 'a b'` then in the log all the whitespace is being squeezed. So the sql that is printed in the log is `WHERE "users"."name" = 'a b'`. This can be confusing. This commit fixes it by ensuring that whitespace is not squeezed. fixes #10982
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/log_subscriber_test.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/activerecord/test/cases/log_subscriber_test.rb b/activerecord/test/cases/log_subscriber_test.rb
index 57eac0c175..3bdc5a1302 100644
--- a/activerecord/test/cases/log_subscriber_test.rb
+++ b/activerecord/test/cases/log_subscriber_test.rb
@@ -56,6 +56,13 @@ class LogSubscriberTest < ActiveRecord::TestCase
assert_equal 2, logger.debugs.length
end
+ def test_sql_statements_are_not_squeezed
+ event = Struct.new(:duration, :payload)
+ logger = TestDebugLogSubscriber.new
+ logger.sql(event.new(0, sql: 'ruby rails'))
+ assert_match(/ruby rails/, logger.debugs.first)
+ end
+
def test_ignore_binds_payload_with_nil_column
event = Struct.new(:duration, :payload)