1. 11 1月, 2018 2 次提交
  2. 10 1月, 2018 3 次提交
  3. 07 1月, 2018 6 次提交
  4. 05 1月, 2018 1 次提交
  5. 04 1月, 2018 4 次提交
  6. 01 1月, 2018 2 次提交
  7. 31 12月, 2017 1 次提交
  8. 30 12月, 2017 1 次提交
    • R
      Fix `cache_key` with a relation having distinct and order · 7fae88f7
      Ryuta Kamizono 提交于
      We can't replace existing SELECT list as long as having DISTINCT, it
      will cause incorrect result.
      
      And also, PostgreSQL has a limitation that ORDER BY expressions must
      appear in select list for SELECT DISTINCT.
      
      Therefore, we should not replace existing SELECT list when using
      DISTINCT.
      
      Fixes #29779.
      7fae88f7
  9. 29 12月, 2017 1 次提交
  10. 27 12月, 2017 1 次提交
  11. 26 12月, 2017 2 次提交
  12. 22 12月, 2017 1 次提交
  13. 20 12月, 2017 5 次提交
  14. 19 12月, 2017 3 次提交
  15. 18 12月, 2017 1 次提交
  16. 17 12月, 2017 1 次提交
  17. 15 12月, 2017 1 次提交
  18. 14 12月, 2017 2 次提交
    • 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
    • Y
      Suppress `warning: BigDecimal.new is deprecated` in activerecord · 6c6c3fa1
      Yasuo Honda 提交于
      `BigDecimal.new` has been deprecated in BigDecimal 1.3.3
       which will be a default for Ruby 2.5.
      
      Refer https://github.com/ruby/bigdecimal/commit/533737338db915b00dc7168c3602e4b462b23503
      
      ```
      $ cd rails/activerecord/
      $ git grep -l BigDecimal.new | grep \.rb | xargs sed -i -e "s/BigDecimal.new/BigDecimal/g"
      ```
      
      - Changes made only to Active Record. Will apply the same change to
      other module once this commit is merged.
      
      - The following deprecation has not been addressed because it has been
      reported at `ActiveRecord::Result.new`. `ActiveRecord::Result.ancestors`
      did not show `BigDecimal`.
      
      * Not addressed
      
      ```ruby
      /path/to/rails/activerecord/lib/active_record/connection_adapters/mysql/database_statements.rb:34:
      warning: BigDecimal.new is deprecated
      ```
      
      * database_statements.rb:34
      
      ```ruby
      ActiveRecord::Result.new(result.fields, result.to_a) if result
      ```
      
      * ActiveRecord::Result.ancestors
      
      ```ruby
      [ActiveRecord::Result,
       Enumerable,
       ActiveSupport::ToJsonWithActiveSupportEncoder,
       Object,
       Metaclass::ObjectMethods,
       Mocha::ObjectMethods,
       PP::ObjectMixin,
       ActiveSupport::Dependencies::Loadable,
       ActiveSupport::Tryable,
       JSON::Ext::Generator::GeneratorMethods::Object,
       Kernel,
       BasicObject]
      ```
      
      This commit has been tested with these Ruby and BigDecimal versions
      
      - ruby 2.5 and bigdecimal 1.3.3
      
      ```
      $ ruby -v
      ruby 2.5.0dev (2017-12-14 trunk 61217) [x86_64-linux]
      $ gem list |grep bigdecimal
      bigdecimal (default: 1.3.3, default: 1.3.2)
      ```
      
      - ruby 2.4 and bigdecimal 1.3.0
      
      ```
      $ ruby -v
      ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-linux-gnu]
      $ gem list |grep bigdecimal
      bigdecimal (default: 1.3.0)
      ```
      
      - ruby 2.3 and bigdecimal 1.2.8
      
      ```
      $ ruby -v
      ruby 2.3.5p376 (2017-09-14 revision 59905) [x86_64-linux]
      $ gem list |grep -i bigdecimal
      bigdecimal (1.2.8)
      ```
      
      - ruby 2.2 and bigdecimal 1.2.6
      ```
      $ ruby -v
      ruby 2.2.8p477 (2017-09-14 revision 59906) [x86_64-linux]
      $ gem list |grep bigdecimal
      bigdecimal (1.2.6)
      ```
      6c6c3fa1
  19. 13 12月, 2017 2 次提交
    • R
      Fix inheritance object creation from relation · d4007d5a
      Ryuta Kamizono 提交于
      We need to pass scope attributes to `klass.new` to detect subclass.
      Otherwise `subclass_from_attributes` can't detect subclass which is had
      in scope attributes.
      
      Fixes #18062.
      Closes #18227.
      Closes #30720.
      d4007d5a
    • H
      Optimizing information_schema query for `foreign_keys` · 3499d320
      Hiroyuki Morita 提交于
      Use CONSTRAINT_SCHEMA key for information_schema.referential_constraints.
      See https://dev.mysql.com/doc/refman/5.7/en/information-schema-optimization.html.
      
      ```
      > EXPLAIN SELECT fk.referenced_table_name AS 'to_table', fk.referenced_column_name AS 'primary_key', fk.column_name AS 'column', fk.constraint_name AS 'name', rc.update_rule AS 'on_update', rc.delete_rule AS 'on_delete' FROM information_schema.referential_constraints rc JOIN information_schema.key_column_usage fk USING (constraint_schema, constraint_name) WHERE fk.referenced_column_name IS NOT NULL AND fk.table_schema = 'activerecord_unittest' AND fk.table_name = 'fk_test_has_pk' AND rc.constraint_schema = 'activerecord_unittest' AND rc.table_name = 'fk_test_has_pk'\G
      *************************** 1. row ***************************
                 id: 1
        select_type: SIMPLE
              table: rc
         partitions: NULL
               type: ALL
      possible_keys: NULL
                key: CONSTRAINT_SCHEMA,TABLE_NAME
            key_len: NULL
                ref: NULL
               rows: NULL
           filtered: NULL
              Extra: Using where; Open_full_table; Scanned 0 databases
      *************************** 2. row ***************************
                 id: 1
        select_type: SIMPLE
              table: fk
         partitions: NULL
               type: ALL
      possible_keys: NULL
                key: TABLE_SCHEMA,TABLE_NAME
            key_len: NULL
                ref: NULL
               rows: NULL
           filtered: NULL
              Extra: Using where; Open_full_table; Scanned 0 databases; Using join buffer (Block Nested Loop)
      2 rows in set, 1 warning (0.00 sec)
      ```
      3499d320