1. 29 6月, 2017 6 次提交
  2. 28 6月, 2017 4 次提交
  3. 26 6月, 2017 1 次提交
  4. 25 6月, 2017 1 次提交
  5. 22 6月, 2017 3 次提交
  6. 21 6月, 2017 5 次提交
    • M
      Keep INNER JOIN when merging relations · 249ddd0c
      Maxime Lapointe 提交于
      Doing `Author.joins(:posts).merge(Post.joins(:comments))` does this
      `SELECT ... INNER JOIN posts ON... LEFT OUTER JOIN comments ON...`
      instead of doing
      `SELECT ... INNER JOIN posts ON... INNER JOIN comments ON...`.
      
      This behavior is unexpected and makes little sense as, basically, doing
      `Post.joins(:comments)` means I want posts that have comments. Turning
      it to a LEFT JOIN means I want posts and join the comments data, if
      any.
      
      We can see this problem directly in the existing tests.
      The test_relation_merging_with_merged_joins_as_symbols only does joins
      from posts to comments to ratings while the ratings fixture isn't
      loaded, but the count is non-zero.
      249ddd0c
    • J
      Clear offset cache on CollectionProxy reset/reload · c7f669af
      John Hawthorn 提交于
      The `@offsets` cache is used by FinderMethods to cache records found by
      find_nth. This cache is cleared in AR::Relation#reset, but not in
      CollectionProxy#reset or CollectionProxy#reload.
      
      Because of this, since #29098, calling #first/#find_nth/etc after
      calling #reload or #reset on an association could return a stale record.
      This is an issue both when the full association target is loaded and
      when the item is loaded in #find_nth.
      
      This commit solves the problem by clearing the `@offsets` cache in
      CollectionProxy#reset and CollectionProxy#reload.
      c7f669af
    • B
      Fix ActiveRecord::Persistence#touch with locking · 4d1264cb
      bogdanvlviv 提交于
      `ActiveRecord::Persistence#touch` does not work well when optimistic
      locking enabled and `locking_column`, without default value, is null in
      the database.
      4d1264cb
    • B
      Fix destroy with locking_column value null · f08bc757
      bogdanvlviv 提交于
      Fix destroying existing object does not work well when optimistic
      locking enabled and `locking column` is null in the database.
      
      Follow 22a822e5, #28914
      f08bc757
    • K
      Use bulk INSERT to insert fixtures · 4ee42379
      Kir Shatrov 提交于
      Improves the performance from O(n) to O(1).
      Previously it would require 50 queries to
      insert 50 fixtures. Now it takes only one query.
      
      Disabled on sqlite which doesn't support multiple inserts.
      4ee42379
  7. 20 6月, 2017 1 次提交
  8. 18 6月, 2017 2 次提交
  9. 17 6月, 2017 1 次提交
    • K
      Remove FK together with column in MySQL · 675a912e
      Kir Shatrov 提交于
      Unlike with other databses, MySQL doesn't let you remove the column
      if there's a FK on this column.
      
      For better developer experience we want to remove the FK together with
      the column.
      675a912e
  10. 16 6月, 2017 1 次提交
  11. 15 6月, 2017 7 次提交
    • E
      Don't map id to primary key in raw_write_attribute · 2e4fe3a4
      Eugene Kenny 提交于
      The `raw_write_attribute` method is used to update a record's attributes
      to reflect the new state of the database in `update_columns`. The hash
      provided to `update_columns` is turned into an UPDATE query directly,
      which means passing an `id` key results in an update to the `id` column,
      even if the model uses a different attribute as its primary key. When
      updating the record, we don't want to apply the `id` column change to
      the primary key attribute, since that's not what happened in the query.
      
      Without the code to handle this case, `write_attribute_with_type_cast`
      no longer contains any logic shared between `raw_write_attribute` and
      `write_attribute`, so we can inline the code into those two methods.
      2e4fe3a4
    • R
      Fix `dump_schema_information` with empty versions · 28b54c6b
      Ryuta Kamizono 提交于
      Fixes #29460.
      28b54c6b
    • D
    • R
    • R
      Fix `Relation#exists?` queries with query cache · 9276ebc7
      Ryuta Kamizono 提交于
      If a connection adapter overrides `select_*` methods, query caching will
      doesn't work. This patch changes `select_value` to `select_one` in
      `Relation#exists?` to ensure query caching.
      
      Fixes #29449.
      9276ebc7
    • R
      Add test cases for #28274 · 249fcbec
      Ryuta Kamizono 提交于
      `object.id` is correctly restored since #29378 has merged.
      
      Closes #28274, Closes #28395.
      
      [Ryuta Kamizono & Eugene Kenny]
      249fcbec
    • E
      Allow `uuid_test.rb` to be loaded on all adapters · b0180c91
      Eugene Kenny 提交于
      Running `bin/test` from the activerecord directory produces this error:
      
          test/cases/adapters/postgresql/uuid_test.rb:43:in `<class:PostgresqlUUIDTest>': undefined method `supports_pgcrypto_uuid?' for #<ActiveRecord::ConnectionAdapters::SQLite3Adapter:0x007fc405e72a68> (NoMethodError)
      
      The test only actually runs on the PostgreSQL adapter; we can avoid
      triggering the error on other adapters with this `respond_to?` guard.
      b0180c91
  12. 14 6月, 2017 1 次提交
  13. 13 6月, 2017 3 次提交
  14. 11 6月, 2017 1 次提交
  15. 09 6月, 2017 1 次提交
  16. 07 6月, 2017 1 次提交
    • R
      Avoid overwriting the methods of `AttributeMethods::PrimaryKey` · 9b8c7796
      Ryuta Kamizono 提交于
      Currently the methods of `AttributeMethods::PrimaryKey` are overwritten
      by `define_attribute_methods`. It will be broken if a table that
      customized primary key has non primary key id column.
      It should not be overwritten if a table has any primary key.
      
      Fixes #29350.
      9b8c7796
  17. 06 6月, 2017 1 次提交
    • Y
      PostgreSQL 10 converts unknown OID 705 to text 25 · eeb83fe9
      Yasuo Honda 提交于
      - Rename test cases from  `unknown` to `unrecognized` since unknown OID
      is one of possible unrecognized types by Rails
      
      - Use "select 'pg_catalog.pg_class'::regclass" whose OID is 2205, which
      will not be converted to recognized type in PostgreSQL 10.
      
      activerecord_unittest=# select oid, typname from pg_type where oid in (2205, 2277);
       oid  | typname
      ------+----------
       2205 | regclass
       2277 | anyarray
      (2 rows)
      
      Addresses #28868
      eeb83fe9