1. 08 4月, 2014 1 次提交
    • L
      Build the reverse_order on its proper method. · 6c311e0b
      Lauro Caetano 提交于
      The reverse_order method was using a flag to control if the order should
      be reversed or not. Instead of using this variable just build the reverse order
      inside its proper method.
      
      This implementation was leading to an unexpected behavior when using
      reverse_order and then applying reorder(nil).
      
      Example:
        Before
          Post.order(:name).reverse_order.reorder(nil)
          # => SELECT "posts".* FROM "posts"   ORDER BY "posts"."id" DESC
      
        After
          Post.order(:name).reverse_order.reorder(nil)
         # => SELECT "posts".* FROM "posts"
      6c311e0b
  2. 07 4月, 2014 1 次提交
  3. 18 3月, 2014 1 次提交
  4. 17 3月, 2014 1 次提交
  5. 15 3月, 2014 1 次提交
  6. 14 3月, 2014 2 次提交
  7. 05 3月, 2014 3 次提交
  8. 04 3月, 2014 1 次提交
    • M
      Make exists? use bound values. · f317cc8b
      Martin Schürrer 提交于
      When we build a query with an inline value that is a numeric (e.g.
      because it's out of range for an int4) PostgreSQL doesn't use an index
      on the column, since it's now comparing numerics and not int4s.
      
      This leads to a _very_ slow query.
      
      When we use bound parameters instead of inline values PostgreSQL
      raises numeric_value_out_of_range since no automatic coercion happens.
      f317cc8b
  9. 01 3月, 2014 1 次提交
  10. 17 2月, 2014 2 次提交
  11. 15 2月, 2014 1 次提交
  12. 06 2月, 2014 2 次提交
  13. 02 2月, 2014 1 次提交
    • R
      Make arel methods private API · cd93d717
      Rafael Mendonça França 提交于
      Since its conception arel was made to be private API of Active Record.
      If users want to use arel features directly we should provide a way
      using the Active Record API without exposing the arel implementation.
      cd93d717
  14. 31 1月, 2014 1 次提交
  15. 30 1月, 2014 3 次提交
  16. 29 1月, 2014 1 次提交
  17. 27 1月, 2014 1 次提交
    • W
      Display value when raising due to unscope() issues · 8b14b114
      Washington Luiz 提交于
      Hopefully make it easier to debug errors. e.g
      
      Before:
      
          RuntimeError:
             unscope(where: "deleted_at") failed: unscoping String is unimplemented.
      
      After:
      
          RuntimeError:
             unscope(where: "deleted_at") failed: unscoping String "'t'='t'" is unimplemented.
      8b14b114
  18. 25 1月, 2014 1 次提交
  19. 22 1月, 2014 2 次提交
    • J
      Ensure AR #second, #third, etc. finders work through associations · 03855e79
      Jason Meller 提交于
      This commit fixes two regressions introduced in cafe31a0 where
      newly created finder methods #second, #third, #forth, and #fifth
      caused a NoMethodError error on reload associations and where we
      were pulling the wrong element out of cached associations.
      
      Examples:
      
        some_book.authors.reload.second
      
        # Before
        # => NoMethodError: undefined method 'first' for nil:NilClass
      
        # After
        # => #<Author id: 2, name: "Sally Second", ...>
      
        some_book.first.authors.first
        some_book.first.authors.second
      
        # Before
        # => #<Author id: 1, name: "Freddy First", ...>
        # => #<Author id: 1, name: "Freddy First", ...>
      
        # After
        # => #<Author id: 1, name: "Freddy First", ...>
        # => #<Author id: 2, name: "Sally Second", ...>
      
      Fixes #13783.
      03855e79
    • Y
      prepend table name for `Relation#select` columns. · e011258c
      Yves Senn 提交于
      This fixes a bug where `select(:id)` combined with `joins()` raised:
      
      ```
      ActiveRecord::StatementInvalid: SQLite3::SQLException: ambiguous column name: id:
      SELECT  id, authors.author_address_id
      FROM "posts"
      INNER JOIN "authors"
      ON "authors"."id" = "posts"."author_id"
      ORDER BY posts.id LIMIT 3
      ```
      
      The `select_values` are still String and Symbols because other parts (mainly calculations.rb)
      rely on that fact.
      
      /cc @tenderlove
      e011258c
  20. 21 1月, 2014 2 次提交
    • A
      Fail early with "Primary key not included in the custom select clause" in find_in_batches · 691709dd
      Alexander Balashov 提交于
      Before this patch find_in_batches raises this error only on second iteration. So you will know about the problem only when you get the batch size threshold.
      691709dd
    • J
      Ensure #second acts like #first AR finder · cafe31a0
      Jason Meller 提交于
      This commit bring the famous ordinal Array instance methods defined
      in ActiveSupport into ActiveRecord as fully-fledged finders.
      
      These finders ensure a default ascending order of the table's primary
      key, and utilize the OFFSET SQL verb to locate the user's desired
      record. If an offset is defined in the query, calling #second adds
      to the offset to get the actual desired record.
      
      Fixes #13743.
      cafe31a0
  21. 14 1月, 2014 4 次提交
  22. 10 1月, 2014 1 次提交
  23. 30 12月, 2013 1 次提交
  24. 20 12月, 2013 1 次提交
  25. 18 12月, 2013 1 次提交
  26. 17 12月, 2013 2 次提交
    • L
      Create a blacklist to disallow mutator methods to be delegated to `Array`. · d4ee09cd
      Lauro Caetano 提交于
      This change was necessary because the whitelist wouldn't work.
      It would be painful for users trying to update their applications.
      
      This blacklist intent to prevent odd bugs and confusion in code that call mutator
      methods directely on the `Relation`.
      d4ee09cd
    • M
      Better support for `where()` conditions that use an association name. · 8062a307
      Martin Emde 提交于
      Using the name of an association in `where` previously worked only
      if the value was a single `ActiveRecrd::Base` object. e.g.
      
          Post.where(author: Author.first)
      
      Any other values, including `nil`, would cause invalid SQL to be
      generated. This change supports arguments in the `where` query
      conditions where the key is a `belongs_to` association name and the
      value is `nil`, an `Array` of `ActiveRecord::Base` objects, or an
      `ActiveRecord::Relation` object.
      
          # Given the Post model
          class Post < ActiveRecord::Base
            belongs_to :author
          end
      
          # nil value finds records where the association is not set
          Post.where(author: nil)
          # SELECT "posts".* FROM "posts" WHERE "posts"."author_id" IS NULL
      
          # Array values find records where the association foreign key
          # matches the ids of the passed ActiveRecord models, resulting
          # in the same query as Post.where(author_id: [1,2])
          authors_array = [Author.find(1), Author.find(2)]
          Post.where(author: authors_array)
      
          # ActiveRecord::Relation values find records using the same
          # query as Post.where(author_id: Author.where(last_name: "Emde"))
          Post.where(author: Author.where(last_name: "Emde"))
      
      Polymorphic `belongs_to` associations will continue to be handled
      appropriately, with the polymorphic `association_type` field added
      to the query to match the base class of the value. This feature
      previously only worked when the value was a single `ActveRecord::Base`.
      
          class Post < ActiveRecord::Base
            belongs_to :author, polymorphic: true
          end
      
          Post.where(author: Author.where(last_name: "Emde"))
          # Generates a query similar to:
          Post.where(author_id: Author.where(last_name: "Emde"), author_type: "Author")
      8062a307
  27. 16 12月, 2013 1 次提交