1. 04 1月, 2019 1 次提交
  2. 03 1月, 2019 1 次提交
  3. 02 1月, 2019 4 次提交
  4. 28 12月, 2018 2 次提交
  5. 23 12月, 2018 1 次提交
  6. 22 12月, 2018 1 次提交
    • E
      Raise helpful error when role doesn't exist · 22a12658
      Eileen Uchitelle 提交于
      If you try to call `connected_to` with a role that doesn't have an
      established connection you used to get an error that said:
      
      ```
      >> ActiveRecord::Base.connected_to(role: :i_dont_exist) { Home.first }
      
      ActiveRecord::ConnectionNotEstablished Exception: No connection pool
      with 'primary' found.
      ```
      
      This is confusing because the connection could be established but we
      spelled the role wrong.
      
      I've changed this to raise if the `role` used in `connected_to` doesn't
      have an associated handler. Users who encounter this should either check
      that the role is spelled correctly (writin -> writing), establish a
      connection to that role in the model with connects_to, or use the
      `database` keyword for the `role`.
      
      I think this will provide a less confusing error message for those
      starting out with multiple databases.
      22a12658
  7. 21 12月, 2018 3 次提交
  8. 19 12月, 2018 1 次提交
    • R
      MySQL: `ROW_FORMAT=DYNAMIC` create table option by default · a1652c19
      Ryuta Kamizono 提交于
      Since MySQL 5.7.9, the `innodb_default_row_format` option defines the
      default row format for InnoDB tables. The default setting is `DYNAMIC`.
      
      The row format is required for indexing on `varchar(255)` with `utf8mb4`
      columns.
      
      As long as using MySQL 5.6, CI won't be passed even if MySQL server
      setting is properly configured the same as MySQL 5.7
      (`innodb_file_per_table = 1`, `innodb_file_format = 'Barracuda'`, and
      `innodb_large_prefix = 1`) since InnoDB table is created as the row
      format `COMPACT` by default on MySQL 5.6, therefore indexing on string
      with `utf8mb4` columns aren't succeeded.
      
      Making `ROW_FORMAT=DYNAMIC` create table option by default for legacy
      MySQL version would mitigate the indexing issue on the user side, and it
      makes CI would be passed on MySQL 5.6 which is configured properly.
      a1652c19
  9. 18 12月, 2018 1 次提交
  10. 13 12月, 2018 1 次提交
  11. 12 12月, 2018 2 次提交
  12. 11 12月, 2018 5 次提交
  13. 08 12月, 2018 1 次提交
  14. 07 12月, 2018 1 次提交
    • E
      Rename error that occurs when writing on a read · db54afba
      Eileen Uchitelle 提交于
      I originally named this `StatementInvalid` because that's what we do in
      GitHub, but `@tenderlove` pointed out that this means apps can't test
      for or explitly rescue this error. `StatementInvalid` is pretty broad so
      I've renamed this to `ReadOnlyError`.
      db54afba
  15. 06 12月, 2018 1 次提交
  16. 05 12月, 2018 1 次提交
    • Y
      Fix unstable `test_serialized_attribute_works_under_concurrent_initial_access` test · 65c4b1b5
      yuuji.yaginuma 提交于
      Since bd623893, isolate test of `test_serialized_attribute_works_under_concurrent_initial_access` fails.
      
      ```
      $ ./bin/test -w test/cases/serialized_attribute_test.rb -n test_serialized_attribute_works_under_concurrent_initial_access
      Using sqlite3
      Run options: -n test_serialized_attribute_works_under_concurrent_initial_access --seed 32129
      
      # Running:
      
      E
      
      Error:
      SerializedAttributeTest#test_serialized_attribute_works_under_concurrent_initial_access:
      ActiveRecord::StatementInvalid: SQLite3::SQLException: no such table:
      ```
      
      If duplicate an unloaded model, it seems that method invocation for that class
      is not guaranteed. Use the original class to avoid it.
      65c4b1b5
  17. 04 12月, 2018 3 次提交
  18. 03 12月, 2018 2 次提交
  19. 30 11月, 2018 3 次提交
    • E
      Add ability to prevent writes to a database · f39d72d5
      Eileen Uchitelle 提交于
      This PR adds the ability to prevent writes to a database even if the
      database user is able to write (ie the database is a primary and not a
      replica).
      
      This is useful for a few reasons: 1) when converting your database from
      a single db to a primary/replica setup - you can fix all the writes on
      reads early on, 2) when we implement automatic database switching or
      when an app is manually switching connections this feature can be used
      to ensure reads are reading and writes are writing. We want to make sure
      we raise if we ever try to write in read mode, regardless of database
      type and 3) for local development if you don't want to set up multiple
      databases but do want to support rw/ro queries.
      
      This should be used in conjunction with `connected_to` in write mode.
      For example:
      
      ```
      ActiveRecord::Base.connected_to(role: :writing) do
        Dog.connection.while_preventing_writes do
          Dog.create! # will raise because we're preventing writes
        end
      end
      
      ActiveRecord::Base.connected_to(role: :reading) do
        Dog.connection.while_preventing_writes do
          Dog.first # will not raise because we're not writing
        end
      end
      ```
      f39d72d5
    • R
      Fix the scoping with query methods in the scope block · 3090b358
      Ryuta Kamizono 提交于
      Follow up #33394.
      
      #33394 only fixes the case of scoping with klass methods in the scope
      block which invokes `klass.all`.
      Query methods in the scope block also need to invoke `klass.all` to be
      affected by the scoping.
      3090b358
    • G
      Allow aliased attributes in update · 72e63c71
      Gannon McGibbon 提交于
      Allow aliased attributes to be used in `#update_columns` and `#update`.
      72e63c71
  20. 29 11月, 2018 2 次提交
  21. 28 11月, 2018 2 次提交
  22. 27 11月, 2018 1 次提交