1. 22 9月, 2020 3 次提交
  2. 21 9月, 2020 2 次提交
  3. 18 9月, 2020 1 次提交
  4. 17 9月, 2020 2 次提交
    • E
      Fix documentation for connected_to · 59ef3c8e
      eileencodes 提交于
      In #40241 I forgot to fix the method's documentation. This commit fixes
      the docs to match the new, unreleased behavior.
      59ef3c8e
    • E
      Make `role` required when using `shard` in `connected_to` · d4df616c
      eileencodes 提交于
      While working on some more indepth changes to Rails internal connection
      management we noticed that it's confusing in some cases that the `role`
      is implcit when using a `shard`. For example, if you passed a `shard`
      and not a `role` in an un-nested block the default `role` would be
      `writing`.
      
      ```
      ActiveRecord::Base.connected_to(shard: :one) do
        # connected to writing
      end
      ```
      
      However in cases where nesting is used it could be confusing to
      application authors that the role is inherited:
      
      ```
      ActiveRecord::Base.connected_to(role: :reading) do
        ActiveRecord::Base.connected_to(shard: :one) do
          # will read from shard one replica, not write to primary
        end
      end
      ```
      
      Since this could be potentially confusing, and extremely hard to track
      in complex applications, the best approach is to require `role` when
      using `shard` which is what this PR does.
      
      Note: the code for this method is...getting unweildy. Once the
      `database` argument is fully deprecated we can remove most of the guards
      and make `role` required by removing `nil` from the keyword argument.
      Until then we need to support required arguments in this round about way.
      d4df616c
  5. 16 9月, 2020 2 次提交
  6. 15 9月, 2020 4 次提交
  7. 14 9月, 2020 2 次提交
  8. 10 9月, 2020 2 次提交
  9. 09 9月, 2020 3 次提交
  10. 08 9月, 2020 3 次提交
  11. 07 9月, 2020 1 次提交
  12. 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
  13. 02 9月, 2020 2 次提交
  14. 01 9月, 2020 5 次提交
  15. 27 8月, 2020 1 次提交
  16. 26 8月, 2020 3 次提交