1. 14 12月, 2017 1 次提交
    • O
      Log call site for all queries · 3876defd
      Olivier Lacan 提交于
      This new ActiveRecord configuration option allows you to easily
      pinpoint what line of application code is triggering SQL queries in the
      development log by appending below each SQL statement log the line of
      Ruby code that triggered it.
      
      It’s useful with N+1 issues, and to locate stray queries.
      
      By default this new option ignores Rails and Ruby code in order to
      surface only callers from your application Ruby code or your gems.
      
      It is enabled on newly generated Rails 5.2 applications and can be
      enabled on existing Rails applications:
      
      ```ruby
      Rails.application.configure do
        # ...
        config.active_record.verbose_query_logs = true
      end
      ```
      
      The `rails app:upgrade` task will also add it to
      `config/development.rb`.
      
      This feature purposely avoids coupling with
      ActiveSupport::BacktraceCleaner since ActiveRecord can be used without
      ActiveRecord. This decision can be reverted in the future to allow more
      configurable backtraces (the exclusion of gem callers for example).
      3876defd
  2. 20 7月, 2017 1 次提交
  3. 02 7月, 2017 1 次提交
  4. 01 7月, 2017 1 次提交
  5. 17 5月, 2017 1 次提交
  6. 16 5月, 2017 1 次提交
    • Y
      Address LogSubscriberTest failures to support Rails 2.5.0-dev · d2e5196b
      Yasuo Honda 提交于
      Address #29021
      
      Since Ruby 2.5.0-dev does not return decimal value when it is 0.
      This change has been made at Ruby 2.5.0-dev between `(2017-05-05 trunk 58572)`
      and `(2017-05-07 trunk 58586)`, likely Revision 58586.
      
      This fix has been tested with these Ruby versions:
      
      * ruby 2.5.0dev (2017-05-15 trunk 58733) [x86_64-linux]
      * ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
      * ruby 2.3.4p301 (2017-03-30 revision 58214) [x86_64-linux]
      * ruby 2.2.7p470 (2017-03-28 revision 58194) [x86_64-linux]
      
      [Yasuo Honda & Ryuta Kamizono]
      d2e5196b
  7. 07 5月, 2017 1 次提交
  8. 29 4月, 2017 1 次提交
    • J
      Stop creating duplicate Struct instances · e82d2251
      Jon Moss 提交于
      Just use one `Event` class. Reduces duplication, makes the tests easier
      to read. It might seem like each tests needs a different kind of Struct,
      since we make a new one for each test case.
      e82d2251
  9. 07 8月, 2016 3 次提交
  10. 11 5月, 2016 1 次提交
    • J
      Fix ActiveRecord::LogSubscriber edge case · c6503415
      Jon Moss 提交于
      If an attribute was of the binary type, and also was a Hash, it would
      previously not be logged, and instead raise an error saying that
      `bytesize` was not defined for the `attribute.value` (a `Hash`).
      
      Now, as is done on 4-2-stable, the attribute's database value is
      `bytesize`d, and then logged out to the terminal.
      
      Reproduction script:
      
      ```ruby
      require 'active_record'
      require 'minitest/autorun'
      require 'logger'
      
      ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
      ActiveRecord::Base.logger = Logger.new(STDOUT)
      
      ActiveRecord::Schema.define do
        create_table :posts, force: true do |t|
          t.binary :preferences
        end
      end
      
      class Post < ActiveRecord::Base
        serialize :preferences
      end
      
      class BugTest < Minitest::Test
        def test_24955
          Post.create!(preferences: {a: 1})
      
          assert_equal 1, Post.count
        end
      end
      ```
      c6503415
  11. 05 11月, 2015 1 次提交
  12. 18 7月, 2015 1 次提交
    • P
      Improve sql logging coloration in `ActiveRecord::LogSubscriber`. · bec65fa2
      Peter Boling 提交于
      - Improves coloring for statements like:
      
          # Become WHITE
          SELECT * FROM (
              SELECT * FROM mytable FOR UPDATE
          ) ss WHERE col1 = 5;
          LOCK TABLE table_name IN ACCESS EXCLUSIVE MODE;
      
          # Becomes RED
          ROLLBACK
      
      - Reinstates the coloration of the `payload[:name]`.
        Instead of simple alternating colors, adds meaning:
        - `MAGENTA` for `"SQL"` or `blank?` payload names
        - `CYAN` for Model Load/Exists
      
      - Introduces specs for sql coloration.
      - Introduces specs for payload name coloration.
      
      GH#20885
      bec65fa2
  13. 28 1月, 2015 1 次提交
    • S
      Remove Relation#bind_params · b06f64c3
      Sean Griffin 提交于
      `bound_attributes` is now used universally across the board, removing
      the need for the conversion layer. These changes are mostly mechanical,
      with the exception of the log subscriber. Additional, we had to
      implement `hash` on the attribute objects, so they could be used as a
      key for query caching.
      b06f64c3
  14. 11 1月, 2015 1 次提交
  15. 03 5月, 2014 1 次提交
  16. 08 11月, 2013 1 次提交
  17. 19 6月, 2013 1 次提交
    • N
      log the sql that is actually sent to the database · 6fb5f6f3
      Neeraj Singh 提交于
      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
      6fb5f6f3
  18. 08 1月, 2013 1 次提交
    • C
      Ignore binds payload with nil column in AR log subscriber · 77516a71
      Carlos Antonio da Silva 提交于
      Some tests were raising the following error:
      
          Could not log "sql.active_record" event. NoMethodError: undefined method
          `type' for nil:NilClass`
      
      Due to the way binds were being logged, the column info was considered
      always present, but that is not true for some of the tests listed in the
      issue.
      
      Closes #8806.
      77516a71
  19. 19 12月, 2012 1 次提交
  20. 15 12月, 2012 2 次提交
  21. 03 8月, 2012 1 次提交
    • J
      Remove ActiveRecord::Base.to_a · 55b24888
      Jon Leighton 提交于
      On reflection, it seems like a bit of a weird method to have on
      ActiveRecord::Base, and it shouldn't be needed most of the time anyway.
      55b24888
  22. 27 7月, 2012 1 次提交
    • J
      ActiveRecord::Base.all returns a Relation. · 6a81ccd6
      Jon Leighton 提交于
      Previously it returned an Array.
      
      If you want an array, call e.g. `Post.to_a` rather than `Post.all`. This
      is more explicit.
      
      In most cases this should not break existing code, since
      Relations use method_missing to delegate unknown methods to #to_a
      anyway.
      6a81ccd6
  23. 14 3月, 2012 1 次提交
  24. 20 12月, 2011 1 次提交
  25. 08 12月, 2011 1 次提交
  26. 23 6月, 2011 1 次提交
  27. 07 6月, 2011 1 次提交
  28. 05 6月, 2011 1 次提交
    • J
      Refactor Active Record test connection setup. Please see the... · 253bb6b9
      Jon Leighton 提交于
      Refactor Active Record test connection setup. Please see the RUNNING_UNIT_TESTS file for details, but essentially you can now configure things in test/config.yml. You can also run tests directly via the command line, e.g. ruby path/to/test.rb (no rake needed, uses default db connection from test/config.yml). This will help us fix the CI by enabling us to isolate the different Rails versions to different databases.
      253bb6b9
  29. 02 5月, 2011 1 次提交
  30. 06 4月, 2011 1 次提交
  31. 29 3月, 2011 1 次提交
  32. 27 7月, 2010 1 次提交
  33. 26 7月, 2010 4 次提交
  34. 21 7月, 2010 1 次提交