1. 10 9月, 2020 1 次提交
  2. 09 9月, 2020 3 次提交
  3. 08 9月, 2020 3 次提交
  4. 07 9月, 2020 1 次提交
  5. 04 9月, 2020 4 次提交
    • G
      Raise error when `from` is used with `delete_all`. · 9e477df7
      Guo Xiang Tan 提交于
      This prevents the `from` query method from being ignored silently in the
      resulting SQL query that is generated.
      9e477df7
    • J
      Support reversing of Arel expressions in reverse_order · e32fd534
      Josh Goodall 提交于
      The current behaviour of reverse_order, when presented with an
      existing order that is an Arel expression, is to ignore it.
      This isn't quite in keeping with how it handles Arel attributes
      (which it reverse) or arbitrary strings (which throw an exception).
      
      The easy path would be to throw an exception, but we don't have to.
      Any SQL expression that is a valid default sort expression can be
      reversed with DESC.
      
      It follows that if there's an existing Arel::Nodes::NodeExpression
      that is not already wrapped with an Arel::Nodes::Ordering, then
      it can be reversed with DESC.
      e32fd534
    • G
      Avoid setting `ActiveRecord::Base.configurations` twice in db rake tasks. · 2beeb6fb
      Guo Xiang Tan 提交于
      When ActiveRecord is used with Rails, loading `ActiveRecord` will set
      the configurations so there is no need to do it twice.
      2beeb6fb
    • E
      Default db_config should be primary or first · ee9e308f
      eileencodes 提交于
      The handling for single database applications has always set a schema.rb
      or structure.sql files for loading the database schema. When we first
      implemented multiple database support we intended to keep this for the
      original, default database. Afterall Rails _has_ to connect to something
      on boot. In development only one connection is connected on boot since
      we don't eager load the app.
      
      Originally we had thought that all applications should be required to
      add a `primary` entry in the database configurations file. However,
      this hasn't worked in practice and we have some code now that does not
      assume there's a primary. The schema dumping/loading code however,
      still assumed there was a "primary" in the configurations file.
      
      We want the "default" database in any application to use the original
      files even when converted to a multiple database application as this
      reduces the need to make changes when implementing this functionality on
      an existing application.
      
      The changes here update Rails to ensure that we treat either "primary"
      or the first database configuration for an environment as "default".
      If there is a "primary" that will be used as the default configuration.
      If there is no primary the configuration that is first for an
      environment will be used as the default. For schema dump/load this means
      that the default configuration (primary or first) will use `schema.rb`
      as the filename and other configurations will use
      `[CONFIGURATION_NAME]_schema.rb`.
      
      This should also help us finish the pull request to infer migrations
      paths since now we can say the first configuration is the default. This
      is a natural assumption for application developers.
      
      Followup to #39536
      ee9e308f
  6. 02 9月, 2020 2 次提交
  7. 01 9月, 2020 5 次提交
  8. 27 8月, 2020 1 次提交
  9. 26 8月, 2020 7 次提交
  10. 25 8月, 2020 2 次提交
    • G
      Disconnect connections used for acquiring advisory lock in migration. · ae330afe
      Guo Xiang Tan 提交于
      Not disconnecting the connections in the pool results in a session left idling in the DB.
      
      An idle session will prevent the database being dropped and affect
      commands like `bin/rails db:test:prepare`. While this is an edge case,
      it is still good practice to clean up the connections in the pool.
      ae330afe
    • P
      Add DidYouMean for InverseOfAssociationNotFoundError · c639ef17
      Petrik 提交于
      If an inverse association isn't found we can suggest similar associations:
      
      ```
      class Human < ActiveRecord::Base
        has_one :dirty_face, class_name: "Face", inverse_of: :dirty_human
      end
      
      class Face < ActiveRecord::Base
        belongs_to :human, inverse_of: :face
        belongs_to :horrible_human, class_name: "Human", inverse_of: :horrible_face
      end
      Human.first.dirty_face
      
      Could not find the inverse association for dirty_face (:dirty_human in Face)
      Did you mean?  human
                     horrible_human
                    ....
      ```
      Co-authored-by: NDaniel Colson <danieljamescolson@gmail.com>
      c639ef17
  11. 24 8月, 2020 6 次提交
  12. 23 8月, 2020 1 次提交
    • R
      Support storing demodulized class name for polymorphic type · 62cfbdf3
      Ryuta Kamizono 提交于
      This is an alternative of #29722.
      
      Before Rails 6.1, storing demodulized class name is supported only for
      STI type by `store_full_sti_class` class attribute.
      
      Now `store_full_class_name` class attribute can handle both STI and
      polymorphic types.
      
      Closes #29722.
      
      See also #29601, #32048, #32148.
      62cfbdf3
  13. 19 8月, 2020 1 次提交
  14. 17 8月, 2020 1 次提交
    • R
      Fix eager loading that non-select columns will be loaded · 46393182
      Ryuta Kamizono 提交于
      Related to #35210.
      
      We sometimes use `select` to limit unused columns for performance.
      
      For example, `GET /posts/1` (post detail) usually use (almost) all
      columns, but `GET /posts` (post list) does not always use all columns
      (e.g. use `id` and `title` for the list view, but `body` is not used).
      
      If an association is eager loaded, the limited `select` doesn't works as
      expected, eager loading will load all columns on the model, plus also
      load the `select` columns additionally. It works differently with
      natural load and preload. It means that changing natural load or preload
      to eager load (or vice versa) is unsafe.
      
      This fixes eager loading that always load all columns (plus extra
      `select` columns), to respect the `select` columns like as others.
      
      ```ruby
      post = Post.select("UPPER(title) AS title").first
      post.title # => "WELCOME TO THE WEBLOG"
      post.body  # => ActiveModel::MissingAttributeError
      
      # Rails 6.0 (ignore the `select` values)
      post = Post.select("UPPER(title) AS title").eager_load(:comments).first
      post.title # => "Welcome to the weblog"
      post.body  # => "Such a lovely day"
      
      # Rails 6.1 (respect the `select` values)
      post = Post.select("UPPER(title) AS title").eager_load(:comments).first
      post.title # => "WELCOME TO THE WEBLOG"
      post.body  # => ActiveModel::MissingAttributeError
      ```
      46393182
  15. 16 8月, 2020 1 次提交
    • R
      Fix preloader to associate preloaded records by default · f80179db
      Ryuta Kamizono 提交于
      Someone had relied on the behavior that preloading with a given scope,
      but the behavior has lost in #35496 to fix the minor bug that unloading
      through association.
      
      Basically we don't guarantee the internal behavior, but the bugfix can
      be achieved without any breaking change, so I've restored the lost
      functionality.
      
      Fixes #36638.
      Fixes #37720.
      f80179db
  16. 15 8月, 2020 1 次提交