1. 12 12月, 2016 1 次提交
  2. 10 12月, 2016 3 次提交
  3. 09 12月, 2016 2 次提交
  4. 06 12月, 2016 1 次提交
  5. 01 12月, 2016 2 次提交
    • N
      Fix issue number from becoming markdown header · 634f2238
      nanaya 提交于
      The alternative is escaping it but moving around the text seems a bit simpler.
      634f2238
    • S
      Make the second argument to `attribute` optional · 1bdc395d
      Sean Griffin 提交于
      While working on updating Paper Trail for 5.1 compatibility, I noticed
      that I was required to pass a second argument to `attribute`. I didn't
      intend for this to be the case, as `attribute :foo` is totally
      reasonable shorthand for "I want `attr_accessor :foo`, but also have it
      work with things like `.attributes` and `ActiveRecord::Dirty`"
      1bdc395d
  6. 27 11月, 2016 1 次提交
  7. 26 11月, 2016 1 次提交
  8. 24 11月, 2016 2 次提交
    • D
      Add test for collection *_ids= setter when association primary key set · 93550206
      Dominic Cleal 提交于
      Fixes casting of IDs to the data type of the association primary key,
      rather than then the data type of the model's primary key. (Tests use a
      string primary key on the association, rather than an int.)
      
      Tests issue #20995
      93550206
    • D
      Restore RecordNotFound when *_ids= can't find records by ID · 15e2da65
      Dominic Cleal 提交于
      9c9fb19b changed the behaviour of the _ids= setters for associations to
      raise an AssociationTypeMismatch when unknown IDs are given:
      
          Class: <ActiveRecord::AssociationTypeMismatch>
          Message: <"Developer(#43811860) expected, got NilClass(#16732720)">
      
      This restores the original ActiveRecord::RecordNotFound exception with a
      much clearer error message:
      
          Class: <ActiveRecord::RecordNotFound>
          Message: <"Couldn't find all Developers with 'id': (1, -9999) [WHERE \"contracts\".\"company_id\" = ?] (found 1 results, but was looking for 2)">
      
      Fixes #25719
      15e2da65
  9. 23 11月, 2016 1 次提交
    • Y
      For `PostgreSQL >= 9.4` use `gen_random_uuid()` · b915b11c
      Yaw Boakye 提交于
      Since 9.4, PostgreSQL recommends using `pgcrypto`'s `gen_random_uuid()`
      to generate version 4 UUIDs instead of the functions in the `uuid-ossp`
      extension.
      
      These changes uses the appropriate UUID function depending on the
      underlying PostgreSQL server's version, while maintaining
      `uuid_generate_v4()` in older migrations.
      b915b11c
  10. 22 11月, 2016 1 次提交
    • Y
      Introduce `reload_<association>` reader for singular associations. · 0e995713
      Yves Senn 提交于
      This patch brings back the functionality of passing true to the
      association proxy. The behavior was deprecated with #20888 and scheduled
      for removal in Rails 5.1.
      
      The deprecation mentioned that instead of `Article.category(true)` one
      should use `article#reload.category`. Unfortunately the alternative does
      not expose the same behavior as passing true to the reader
      did. Specifically reloading the parent record throws unsaved changes and
      other caches away. Passing true only affected the association.
      
      This is problematic and there is no easy workaround. I propose to bring
      back the old functionality by introducing this new reader method for
      singular associations.
      0e995713
  11. 21 11月, 2016 1 次提交
  12. 16 11月, 2016 1 次提交
    • J
      Support AC::Parameters for PG HStore · 0a8b212d
      Jon Moss 提交于
      As reported via #26904, there is a regression in how values for
      Postgres' HStore column type are being processed, beginning in Rails 5.
      Currently, the way that Active Record checks whether or not values need
      to be serialized and put into the correct storage format is whether or
      not it is a `Hash` object. Since `ActionController::Parameters` no
      longer inherits from `Hash` in Rails 5, this conditional now returns
      false. To remedy this, we are now checking to see whether the `value`
      parameters being passed in responds to a certain method, and then
      calling the `serialize` method, except this time with a real Hash
      object. Keeping things DRY!
      
      Fixes #26904.
      0a8b212d
  13. 13 11月, 2016 1 次提交
  14. 09 11月, 2016 2 次提交
    • R
      Should except `:distinct` rather than `:order` for `exists?` · 2bf7c300
      Ryuta Kamizono 提交于
      Records fetching order is very important for performance if `limit` is
      presented. Should not except the order in the case.
      
      And `exists?` replaces select list to `1 AS one` therefore `:distinct`
      is useless (`DISTINCT 1 AS one`). And PostgreSQL raises the following
      error if `:distinct` and `:order` are used in the same time.
      
      ```
      ERROR:  for SELECT DISTINCT, ORDER BY expressions must appear in select list
      ```
      2bf7c300
    • P
      Add ActiveRecord::Base.connection_pool.stat · 35b6898f
      Pavel 提交于
      35b6898f
  15. 06 11月, 2016 1 次提交
  16. 02 11月, 2016 1 次提交
  17. 31 10月, 2016 1 次提交
  18. 23 10月, 2016 1 次提交
  19. 22 10月, 2016 3 次提交
  20. 15 10月, 2016 1 次提交
  21. 03 10月, 2016 1 次提交
  22. 24 9月, 2016 1 次提交
  23. 23 9月, 2016 1 次提交
    • P
      Return true if attribute is not changed for update_attribute · 730e99af
      Prathamesh Sonpatki 提交于
      - If the attribute is not changed, then update_attribute does not run
        SQL query, this effectively means that no change was made to the
        attribute.
      - This change was made in https://github.com/rails/rails/commit/0fcd4cf5
        to avoid a SQL call.
      - But the change resulted into `nil` being returned when there was no
        change in the attribute value.
      - This commit corrects the behavior to return true if there is no change
        in attribute value. This is same as previous behavior of Rails 4.2
        plus benefit of no additional SQL call.
      - Fixes #26593.
      730e99af
  24. 20 9月, 2016 1 次提交
    • R
      Always store errors details information with symbols · d406014b
      Rafael Mendonça França 提交于
      When the association is autosaved we were storing the details with
      string keys. This was creating inconsistency with other details that are
      added using the `Errors#add` method. It was also inconsistent with the
      `Errors#messages` storage.
      
      To fix this inconsistency we are always storing with symbols. This will
      cause a small breaking change because in those cases the details could
      be accessed as strings keys but now it can not.
      
      The reason that we chose to do this breaking change is because `#details`
      should be considered a low level object like `#messages` is.
      
      Fix #26499.
      
      [Rafael Mendonça França + Marcus Vieira]
      d406014b
  25. 14 9月, 2016 2 次提交
  26. 01 9月, 2016 1 次提交
    • S
      Attempt to maintain encoding for arrays of strings with PG · 7ba3a48d
      Sean Griffin 提交于
      I still think that this is something that should be handled in the pg
      gem, but it's not going to end up happening there so we'll do it here
      instead. Once we bump to pg 0.19 we can pass the encoding to the
      `encode` method instead.
      
      This issue occurs because C has no concept of encoding (or strings,
      really). The bytes that we pass here when sending the value to the
      database will always be interpreted as whatever encoding the connection
      is currently configured to use. That means that roundtripping to the
      database will lose no information
      
      However, after assigning we round trip through our type system without
      hitting the database. The only way that we can do the "correct" thin
      here would be to actually give a reference to the connection to the
      array type and have it check the current value of the connection's
      encoding -- which I'm strongly opposed to. We could also pass in the
      encoding when it's constructed, but since that can change independently
      of the type I'm not a huge fan of that either.
      
      This feels like a reasonable middle ground, where if we have an array of
      strings we simply use the encoding of the string we're given.
      
      Fixes #26326.
      7ba3a48d
  27. 31 8月, 2016 1 次提交
    • S
      Ensure that inverse associations are set before running callbacks · caa178c1
      Sean Griffin 提交于
      If a parent association was accessed in an `after_find` or
      `after_initialize` callback, it would always end up loading the
      association, and then immediately overwriting the association we just
      loaded. If this occurred in a way that the parent's `current_scope` was
      set to eager load the child, this would result in an infinite loop and
      eventually overflow the stack.
      
      For records that are created with `.new`, we have a mechanism to
      perform an action before the callbacks are run. I've introduced the same
      code path for records created with `instantiate`, and updated all code
      which sets inverse instances on newly loaded associations to use this
      block instead.
      
      Fixes #26320.
      caa178c1
  28. 26 8月, 2016 1 次提交
    • J
      Don't unnecessarily load a belongs_to when saving. · a94fe297
      James Coleman 提交于
      Previously, if the the association was previously loaded and then
      the foreign key changed by itself, a #save call would trigger a
      load of the new associated record during autosave. This is unnecessary
      and the autosave code (in that case) didn't use the loaded record
      anyways.
      a94fe297
  29. 23 8月, 2016 1 次提交
  30. 19 8月, 2016 2 次提交
    • R
      Add chengelog entry to #25976 · 15175fda
      Rafael Mendonça França 提交于
      [Rafael Mendonça França + Robin Dupret]
      15175fda
    • R
      Remove text default treated as an empty string in non-strict mode · 99cb16a2
      Ryuta Kamizono 提交于
      Strict mode controls how MySQL handles invalid or missing values in
      data-change statements such as INSERT or UPDATE. If strict mode is not
      in effect, MySQL inserts adjusted values for invalid or missing values
      and produces warnings.
      
      ```ruby
        def test_mysql_not_null_defaults_non_strict
          using_strict(false) do
            with_mysql_not_null_table do |klass|
              record = klass.new
              assert_nil record.non_null_integer
              assert_nil record.non_null_string
              assert_nil record.non_null_text
              assert_nil record.non_null_blob
      
              record.save!
              record.reload
      
              assert_equal 0,  record.non_null_integer
              assert_equal "", record.non_null_string
              assert_equal "", record.non_null_text
              assert_equal "", record.non_null_blob
            end
          end
        end
      ```
      
      It is inconsistent with other types that only text/blob defaults treated
      as an empty string. This commit fixes the inconsistency.
      99cb16a2