1. 04 3月, 2020 5 次提交
    • R
      Merge pull request #38576 from Edouard-chin/ec-activejob-deprecation · 40b7d93c
      Rafael França 提交于
      Fix AJ wrong deprecation message on `after_callbacks_if_terminated`:
      40b7d93c
    • E
      Fix AJ wrong deprecation message on `after_callbacks_if_terminated`: · 0cdeee42
      Edouard CHIN 提交于
      - ### Problem
      
        In some cirumstances, the deprecation message to warn that AJ won't
        run `after_(enqueue/perform)` callbacks when the chain is halted
        by a `throw(:abort)` will be thrown even though no `throw(:abort)`
        was thrown.
      
        ```ruby
          run_callback(:foo) do
            ...
          end
        ```
      
        There is two possible way for the callback body to not be executed:
      
        1) `before` callback throw a `abort`
        2) `before` callback raises an error which is rescued by an
           around callback (See associated test in this commit for
           an example)
      
        When 2) happen we don't want to output a deprecation message,
        because what the message says isn't true and doesn't apply.
      
        ### Solution
      
        In order to differentiate between 1) and 2), I have added
        a `halted_callback_hook` which is called by ActiveSupport callback
        whenever the callback chain is halted.
      0cdeee42
    • E
      `ActiveSupport::Calbacks#halted_callback_hook` receive callback name: · 06dd162f
      Edouard CHIN 提交于
      - The `halted_callback_hook` method is called whenever the
        `terminator` halt the callback execution.
        Usually, this translate to when a `before` callback throw
        an `:abort`.
      
        <details>
          <summary> Example </summary>
      
          ```ruby
            class Foo
              include ActiveSupport::Callbacks
      
      	define_callbacks :save
      	set_callback(:save, :before) { throw(:abort) }
      
      	def run
      	  run_callbacks(:save) do
      	    'hello'
      	  end
      	end
      
      	def halted_callback_hook(filter)
      	  # filter is the proc passed to `set_callback` above
      	end
            end
          ```
        </details>
      
        ### Problem
      
        When a class has multiple callbacks, (i.e. `save`, `validate` ...),
        it's impossible to tell in the halted_callback_hook which type of
        callback halted the execution.
        This is useful to take different action based on the callback.
      
        <details>
          <summary> Use Case </summary>
      
          ```ruby
            class Foo
              include ActiveSupport::Callbacks
      
      	define_callbacks :save
      	define_callbacks :validate
      
      	set_callback(:save, :before) { throw(:abort) }
      	set_callback(:validate, :before) { throw(:abort) }
      
      	def run
      	  run_callbacks(:validate) do
      	    ...
      	  end
      
      	  run_callbacks(:save) do
      	    ...
      	  end
      	end
      
      	def halted_callback_hook(filter)
      	  Rails.logger.warn("Couldn't save the record, the ??? callback halted the execution")
      	end
            end
          ```
        </details>
      
        ### Solution
      
        Allow `halted_callback_hook` to receive a second argument which is
        the name of the callback being run.
      06dd162f
    • R
      Merge pull request #38628 from vinistock/simplify_route_score · 9d66da2f
      Rafael França 提交于
      Simplify route score
      9d66da2f
    • R
      Merge pull request #38620 from bogdanvlviv/add-activerecord-db-folder-to-gitignore · 2d2fa64f
      Rafael França 提交于
      Add activerecord/db/ to gitignore
      2d2fa64f
  2. 03 3月, 2020 2 次提交
  3. 02 3月, 2020 3 次提交
    • B
      Add activerecord/db/ to gitignore · 22877a9d
      bogdanvlviv 提交于
      After running `bundle exec rake test:sqlite3` and `bundle exec rake test:sqlite3_mem`
      on my VM I noticed that it had created untracked files:
      
      ```bash
      vagrant@ubuntu-bionic:/rails/activerecord$ git status
      Untracked files:
        (use "git add <file>..." to include in what will be committed)
              db/
              file::memory:
      ```
      
      To prevent them from being accidentally committed I put 'file::memory:' to
      `activerecord/db/` folder and added the folder to .gitignore
      Also, we could consider fixing this by removing `db/` folder in each test that
      creates the folder.
      
      It would be great if someone confirms that it happens not only on my VM.
      22877a9d
    • A
      Merge pull request #38616 from abhaynikam/fix-typo-in-rails-engine-guides · 6d0895a4
      Arun Agrawal 提交于
      Fixed typo classsic -> classic [ci skip]
      6d0895a4
    • A
      Fixed typo classsic -> classic [ci skip] · de4c941e
      Abhay Nikam 提交于
      de4c941e
  4. 29 2月, 2020 4 次提交
    • E
      Merge pull request #38609 from eileencodes/fix-error-in-deprecation · c63cfc87
      Eileen M. Uchitelle 提交于
      Fix error in deprecation
      c63cfc87
    • R
      Merge pull request #38610 from hachi8833/fix_security_guide · d877729e
      Ryuta Kamizono 提交于
      [ci skip] Security guide: change raw HTML elements and signs to backquoted ones
      d877729e
    • H
      Change raw HTML elements and signs to backquoted ones · 54256d52
      hachi8833 提交于
      54256d52
    • E
      Fix error in deprecation · 13e28f5f
      eileencodes 提交于
      When I implemented the deprecation for #38536 I left in the setter in
      the initalizer. This meant that objects returned had both `@name` and
      `@spec_name` set and objects looked like this:
      
      ```
      <ActiveRecord::DatabaseConfigurations::HashConfig:0x00007fe0f7100c68
        @env_name="development",
        @name="primary",
        @spec_name="primary",
        @config={
          :adapter=>"mysql2",
          :database=>"recipes_app_development"
        }
      >
      ```
      
      Since we don't use the kwarg to create the hash config and we have the
      reader for reading off the object or selecting from the configurations
      objects list we can remove this so the object looks like:
      
      ```
      <ActiveRecord::DatabaseConfigurations::HashConfig:0x00007fe0f7100c68
        @env_name="development",
        @name="primary",
        @config={
          :adapter=>"mysql2",
          :database=>"recipes_app_development"
        }
      >
      ```
      13e28f5f
  5. 28 2月, 2020 14 次提交
  6. 27 2月, 2020 5 次提交
    • E
      Merge pull request #38581 from eileencodes/remove-unused-argument · 3269e4e7
      Eileen M. Uchitelle 提交于
      Remove unused argument
      3269e4e7
    • R
      Fix `unscope` when an `eq` node which has no arel attribute · 9698c1bf
      Ryuta Kamizono 提交于
      Current code expect an `eq` node has one arel attribute at least, but an
      `eq` node may have no arel attribute (e.g. `Arel.sql("...").eq(...)`).
      
      In that case `unscope` will raise `NoMethodError`:
      
      ```
      % bundle exec ruby -w -Itest test/cases/relations_test.rb -n test_unscope_with_arel_sql
      Using sqlite3
      Run options: -n test_unscope_with_arel_sql --seed 4477
      
      # Running:
      
      E
      
      Error:
      RelationTest#test_unscope_with_arel_sql:
      NoMethodError: undefined method `name' for #<Arel::Nodes::Quoted:0x00007f9938e55960>
          /Users/kamipo/src/github.com/rails/rails/activerecord/lib/active_record/relation/where_clause.rb:157:in `block (2 levels) in except_predicates'
          /Users/kamipo/src/github.com/rails/rails/activerecord/lib/arel.rb:57:in `fetch_attribute'
          /Users/kamipo/src/github.com/rails/rails/activerecord/lib/active_record/relation/where_clause.rb:157:in `block in except_predicates'
          /Users/kamipo/src/github.com/rails/rails/activerecord/lib/active_record/relation/where_clause.rb:156:in `reject'
          /Users/kamipo/src/github.com/rails/rails/activerecord/lib/active_record/relation/where_clause.rb:156:in `except_predicates'
          /Users/kamipo/src/github.com/rails/rails/activerecord/lib/active_record/relation/where_clause.rb:31:in `except'
          /Users/kamipo/src/github.com/rails/rails/activerecord/lib/active_record/relation/query_methods.rb:487:in `block (2 levels) in unscope!'
          /Users/kamipo/src/github.com/rails/rails/activerecord/lib/active_record/relation/query_methods.rb:481:in `each'
          /Users/kamipo/src/github.com/rails/rails/activerecord/lib/active_record/relation/query_methods.rb:481:in `block in unscope!'
          /Users/kamipo/src/github.com/rails/rails/activerecord/lib/active_record/relation/query_methods.rb:471:in `each'
          /Users/kamipo/src/github.com/rails/rails/activerecord/lib/active_record/relation/query_methods.rb:471:in `unscope!'
          /Users/kamipo/src/github.com/rails/rails/activerecord/lib/active_record/relation/query_methods.rb:464:in `unscope'
          test/cases/relations_test.rb:2062:in `test_unscope_with_arel_sql'
      ```
      
      We should check for both `value.left` and `value.right` those are arel
      attribute or not.
      9698c1bf
    • E
      Remove unused argument · cadd9661
      eileencodes 提交于
      This was leftover in debugging we did to support `shard` in
      `connected_to`. We don't need this because `with_shard` already has
      access to `connection_specification_name` because they are in the same
      class.
      cadd9661
    • R
      Merge pull request #38580 from seejohnrun/disallow-calling-connected_to-on-subclasses-of-ar-base · 03d32ca2
      Rafael França 提交于
      Disallow calling `connected_to` on subclasses of `ActiveRecord::Base`
      03d32ca2
    • E
      Disallow calling `connected_to` on subclasses of `ActiveRecord::Base` · b7b26fab
      eileencodes 提交于
      Behavior has not changed here but the previous API could be
      misleading to people who thought it would switch connections for only
      that class. `connected_to` switches the context from which we are
      getting connections, not the connections themselves.
      Co-authored-by: NJohn Crepezzi <john.crepezzi@gmail.com>
      b7b26fab
  7. 26 2月, 2020 3 次提交
  8. 25 2月, 2020 4 次提交
    • R
      More less and lazy allocation for `assign_attributes` and `_assign_attributes` · 79ba0694
      Ryuta Kamizono 提交于
      https://gist.github.com/kamipo/296b9dd97f690d7960fdfe8de3ca08c7
      
      Before:
      
      ```
      ================================= All symbols ==================================
      
      Warming up --------------------------------------
         assign_attributes     4.425k i/100ms
      Calculating -------------------------------------
         assign_attributes     44.983k (± 2.8%) i/s -    225.675k in   5.020906s
      
      ==================================== Mixed =====================================
      
      Warming up --------------------------------------
         assign_attributes     4.546k i/100ms
      Calculating -------------------------------------
         assign_attributes     46.103k (± 5.2%) i/s -    231.846k in   5.046489s
      
      ================================= All strings ==================================
      
      Warming up --------------------------------------
         assign_attributes     4.511k i/100ms
      Calculating -------------------------------------
         assign_attributes     47.931k (± 7.4%) i/s -    239.083k in   5.023971s
      ```
      
      After:
      
      ```
      ================================= All symbols ==================================
      
      Warming up --------------------------------------
         assign_attributes     4.831k i/100ms
      Calculating -------------------------------------
         assign_attributes     48.206k (± 8.5%) i/s -    241.550k in   5.058372s
      
      ==================================== Mixed =====================================
      
      Warming up --------------------------------------
         assign_attributes     4.960k i/100ms
      Calculating -------------------------------------
         assign_attributes     50.628k (± 3.5%) i/s -    252.960k in   5.002779s
      
      ================================= All strings ==================================
      
      Warming up --------------------------------------
         assign_attributes     5.006k i/100ms
      Calculating -------------------------------------
         assign_attributes     52.242k (± 5.5%) i/s -    260.312k in   5.001695s
      ```
      79ba0694
    • R
      Tweak contributing_to_ruby_on_rails.md [ci skip] · 9028ba0e
      Ryuta Kamizono 提交于
      9028ba0e
    • R
    • R
      Remove duplicate part from deprecation warning · 63316b7b
      Ryuta Kamizono 提交于
      Before:
      
      ```
      DEPRECATION WARNING: spec_name is deprecated and will be removed from Rails 6.2 (spec_name accessors are deprecated and will be removed in Rails 6.2, please use name instead.)
      ```
      
      After:
      
      ```
      DEPRECATION WARNING: spec_name is deprecated and will be removed from Rails 6.2 (please use name instead)
      ```
      
      Follow up of #38536.
      63316b7b