1. 14 2月, 2019 1 次提交
    • E
      Improve errors and handling of hashes for database configurations · 06f94343
      eileencodes 提交于
      In chat Sam Saffron asked how to use the setter now that configurations
      is no longer a hash and you need to do AR::Base.configurations["test"]=.
      
      Technically you can do `ActiveRecord::Base.configurations = { the hash
      }` but I realized the old way throws an error and is unintuitive.
      
      To aid in the transition from hashes to objects this PR makes a few
      changes:
      
      1) Re-adds a deprecated hash setter `[]=` that will add a new hash
      to the configurations list OR replace an existing hash if that
      environment is already present. This won't be supported in future Rails
      versions but a good error is important.
      
      2) Changed to throw deprecation warnings on the methods we decided to support
      for hash conversion and raise on the methods we don't support.
      
      3) Refactored the setter/getter hash deprecation warnings messages and
      rewrote them.
      
      Getters message:
      
      ```
      DEPRECATION WARNING: `ActiveRecord::Base.configurations` no longer
      returns a hash. Methods that act on the hash like `values` are
      deprecated and will be removed in Rails 6.1. Use the `configs_for`
      method to collect and iterate over the database configurations.
      ```
      
      Setter message:
      
      ```
      DEPRECATION WARNING: Setting `ActiveRecord::Base.configurations` with
      `[]=` is deprecated. Use `ActiveRecord::Base.configurations=` directly
      to set the configurations instead.
      ```
      
      4) Rewrote the legacy configurations test file to test all the public
      methods in the DatabaseConfigurations class.
      06f94343
  2. 11 2月, 2019 13 次提交
  3. 10 2月, 2019 6 次提交
  4. 09 2月, 2019 12 次提交
  5. 08 2月, 2019 8 次提交