1. 18 11月, 2017 1 次提交
    • M
      Improve AR connection fork safety · f32cff55
      Matthew Draper 提交于
      Use whatever adapter-provided means we have available to ensure forked
      children don't send quit/shutdown/goodbye messages to the server on
      connections that belonged to their parent.
      f32cff55
  2. 13 11月, 2017 1 次提交
  3. 11 11月, 2017 2 次提交
    • R
      Raise `TransactionTimeout` when lock wait timeout exceeded for PG adapter · 4a65dfcb
      Ryuta Kamizono 提交于
      Follow up of #30360.
      4a65dfcb
    • R
      Add missing autoload `Type` (#31123) · 24b59434
      Ryuta Kamizono 提交于
      Attribute modules (`Attribute`, `Attributes`, `AttributeSet`) uses
      `Type`, but referencing `Type` before the modules still fail.
      
      ```
      % ./bin/test -w test/cases/attribute_test.rb -n test_with_value_from_user_validates_the_value
      Run options: -n test_with_value_from_user_validates_the_value --seed 31876
      
      E
      
      Error:
      ActiveModel::AttributeTest#test_with_value_from_user_validates_the_value:
      NameError: uninitialized constant ActiveModel::AttributeTest::Type
          /Users/kamipo/src/github.com/rails/rails/activemodel/test/cases/attribute_test.rb:233:in `block in <class:AttributeTest>'
      
      bin/test test/cases/attribute_test.rb:232
      
      Finished in 0.002985s, 335.0479 runs/s, 335.0479 assertions/s.
      1 runs, 1 assertions, 0 failures, 1 errors, 0 skips
      ```
      
      Probably we need more autoloading at least `Type`.
      24b59434
  4. 09 11月, 2017 1 次提交
    • B
      Prevent deadlocks with load interlock and DB lock. · 1f9f6f6c
      Brent Wheeldon 提交于
      This fixes an issue where competing threads deadlock each other.
      
      - Thread A holds the load interlock but is blocked on getting the DB lock
      - Thread B holds the DB lock but is blocked on getting the load interlock (for example when there is a `Model.transaction` block that needs to autoload)
      
      This solution allows for dependency loading in other threads while a thread is waiting to acquire the DB lock.
      
      Fixes #31019
      1f9f6f6c
  5. 07 11月, 2017 1 次提交
    • K
      Properly check transaction in persistence · 01c70324
      Keenan Brock 提交于
      ```
      [NoMethodError]: undefined method `state' for nil:NilClass  Method:[rescue in block in refresh]
      ```
      
      In `within_new_transaction`, there is the possibility that
      `begin_transaction` returns a `nil`. (i.e.: so `transaction = nil`)
      So this method is checking `transaction` for nil in 2 spots.
      
      Unfortunately, there is one line that is not checking `transaction` for `nil`
      That line, `commit_transaction`, throws an exception for us in AR 5.0.0.1
      
      The problem with the method is finally realized in the error checking itself.
      it calls `transaction.state` (i.e.: nil.state) and that is the final exception
      raised.
      
      The actual underlying (user) issue is hidden by this line.
      
      Solution is test transaction for nil.
      01c70324
  6. 28 10月, 2017 1 次提交
  7. 25 10月, 2017 4 次提交
  8. 24 10月, 2017 8 次提交
  9. 21 10月, 2017 1 次提交
  10. 15 10月, 2017 2 次提交
    • R
      Fix longer sequence name detection for serial columns (#28339) · 8877492d
      Ryuta Kamizono 提交于
      We already found the longer sequence name, but we could not consider
      whether it was the sequence name created by serial type due to missed a
      max identifier length limitation. I've addressed the sequence name
      consideration to respect the max identifier length.
      
      Fixes #28332.
      8877492d
    • R
      MySQL: Don't lose `auto_increment: true` in the `db/schema.rb` · 9493d455
      Ryuta Kamizono 提交于
      Currently `AUTO_INCREMENT` is implicitly used in the default primary key
      definition. But `AUTO_INCREMENT` is not only used for single column
      primary key, but also for composite primary key. In that case,
      `auto_increment: true` should be dumped explicitly in the
      `db/schema.rb`.
      
      Fixes #30894.
      9493d455
  11. 09 10月, 2017 2 次提交
  12. 05 10月, 2017 1 次提交
  13. 04 10月, 2017 2 次提交
  14. 27 9月, 2017 1 次提交
    • T
      `Postgres::OID::Range` serializes to a `Range`, quote in `Quoting` · 51b6c342
      Thomas Cannon 提交于
      PostgreSQL 9.1+ introduced range types, and Rails added support for
      using this datatype in ActiveRecord. However, the serialization of
      `PostgreSQL::OID::Range` was incomplete, because it did not properly
      quote the bounds that make up the range. A clear example of this is a
      `tsrange`.
      
      Normally, ActiveRecord quotes Date/Time objects to include the
      milliseconds. However, the way `PostgreSQL::OID::Range` serialized its
      bounds, the milliseconds were dropped. This meant that the value was
      incomplete and not equal to the submitted value.
      
      An example of normal timestamps vs. a `tsrange`. Note how the bounds
      for the range do not include their milliseconds (they were present in
      the ruby Range):
      
          UPDATE "iterations" SET "updated_at" = $1, "range" = $2 WHERE
          "iterations"."id" = $3
          [["updated_at", "2017-09-23 17:07:01.304864"],
          ["range", "[2017-09-23 00:00:00 UTC,2017-09-23 23:59:59 UTC]"],
          ["id", 1234]]
      
      `PostgreSQL::OID::Range` serialized the range by interpolating a
      string for the range, which works for most cases, but does not work
      for timestamps:
      
          def serialize(value)
            if value.is_a?(::Range)
              from = type_cast_single_for_database(value.begin)
              to = type_cast_single_for_database(value.end)
              "[#{from},#{to}#{value.exclude_end? ? ')' : ']'}"
            else
              super
            end
          end
      
          (byebug) from = type_cast_single_for_database(value.begin)
          2010-01-01 13:30:00 UTC
      
          (byebug) to = type_cast_single_for_database(value.end)
          2011-02-02 19:30:00 UTC
      
          (byebug) "[#{from},#{to}#{value.exclude_end? ? ')' : ']'}"
          "[2010-01-01 13:30:00 UTC,2011-02-02 19:30:00 UTC)"
      
      @sgrif (the original implementer for Postgres Range support) provided
      some feedback about where the quoting should occur:
      
        Yeah, quoting at all is definitely wrong here. I'm not sure what I
        was thinking in 02579b56, but what this is doing is definitely in the
        wrong place. It should probably just be returning a range of
        subtype.serialize(value.begin) and subtype.serialize(value.end), and
        letting the adapter handle the rest.
      
      `Postgres::OID::Range` now returns a `Range` object, and
      `ActiveRecord::ConnectionAdapters::PostgreSQL::Quoting` can now encode
      and quote a `Range`:
      
          def encode_range(range)
            "[#{type_cast(range.first)},#{type_cast(range.last)}#{range.exclude_end? ? ')' : ']'}"
          end
      
          ...
      
          encode_range(range)
          #=> "['2010-01-01 13:30:00.670277','2011-02-02 19:30:00.745125')"
      
      This commit includes tests to make sure the milliseconds are
      preserved in `tsrange` and `tstzrange` columns
      51b6c342
  15. 25 9月, 2017 2 次提交
  16. 23 9月, 2017 2 次提交
  17. 22 9月, 2017 3 次提交
  18. 19 9月, 2017 1 次提交
  19. 18 9月, 2017 1 次提交
    • R
      Fix collided sequence name detection · a7141177
      Ryuta Kamizono 提交于
      If collided named sequence already exists, newly created serial column
      will generate alternative sequence name. Fix sequence name detection to
      allow the alternative names.
      a7141177
  20. 14 9月, 2017 1 次提交
  21. 08 9月, 2017 1 次提交
  22. 04 9月, 2017 1 次提交