1. 13 4月, 2014 3 次提交
  2. 14 3月, 2014 2 次提交
  3. 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
  4. 15 2月, 2014 1 次提交
  5. 25 1月, 2014 1 次提交
  6. 22 1月, 2014 1 次提交
    • 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
  7. 21 1月, 2014 1 次提交
    • 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
  8. 10 1月, 2014 1 次提交
  9. 04 12月, 2013 1 次提交
  10. 15 11月, 2013 1 次提交
  11. 21 10月, 2013 1 次提交
  12. 16 10月, 2013 1 次提交
  13. 15 10月, 2013 2 次提交
  14. 14 10月, 2013 5 次提交
  15. 11 10月, 2013 1 次提交
  16. 08 10月, 2013 1 次提交
  17. 19 8月, 2013 1 次提交
    • X
      let AR::FinderMethods#exists? return singletons in all cases [closes #11592] · 565c367d
      Xavier Noria 提交于
      This fixes a regression. The documentation said in its introduction
      paragraph that the method returns truthy/falsy, but then below it
      was said that if there were no arguments you'd get `true` or `false`.
      Also when the argument is exactly `false` a singleton is documented
      to be returned.
      
      The method was not returning the singletons so it didn't conform to
      those special cases.
      
      The best solution here seems to be to just return singletons in all
      cases. This solution is backwards compatible. Also, the contract
      has been revised because it has no sense that the predicate varies
      that way depending on the input. I bet the previous contract was just
      an accident, not something mixed on purpose.
      
      Conflicts:
      	activerecord/lib/active_record/relation/finder_methods.rb
      	activerecord/test/cases/finder_test.rb
      565c367d
  18. 10 7月, 2013 2 次提交
  19. 06 7月, 2013 1 次提交
  20. 28 6月, 2013 2 次提交
    • C
      Remove order_values argument now that default_scope is simplified · 5e6de394
      Carlos Antonio da Silva 提交于
      In 94924dc3 the internal default_scope
      implementation has changed making it simpler to follow, meaning that the
      old usage of with_default_scope has been removed.
      
      With that, order_values was the same argument for both calls to
      find_first_with_limit, so remove it and use the existent attribute
      for the sake of clarity/simplification.
      5e6de394
    • J
      Simplify/fix implementation of default scopes · 94924dc3
      Jon Leighton 提交于
      The previous implementation was necessary in order to support stuff
      like:
      
          class Post < ActiveRecord::Base
            default_scope where(published: true)
            scope :ordered, order("created_at")
          end
      
      If we didn't evaluate the default scope at the last possible moment
      before sending the SQL to the database, it would become impossible to
      do:
      
          Post.unscoped.ordered
      
      This is because the default scope would already be bound up in the
      "ordered" scope, and therefore wouldn't be removed by the
      "Post.unscoped" part.
      
      In 4.0, we have deprecated all "eager" forms of scopes. So now you must
      write:
      
          class Post < ActiveRecord::Base
            default_scope { where(published: true) }
            scope :ordered, -> { order("created_at") }
          end
      
      This prevents the default scope getting bound up inside the "ordered"
      scope, which means we can now have a simpler/better/more natural
      implementation of default scoping.
      
      A knock on effect is that some things that didn't work properly now do.
      For example it was previously impossible to use #except to remove a part
      of the default scope, since the default scope was evaluated after the
      call to #except.
      94924dc3
  21. 14 6月, 2013 1 次提交
  22. 13 6月, 2013 1 次提交
  23. 10 6月, 2013 2 次提交
  24. 09 6月, 2013 3 次提交
  25. 11 5月, 2013 1 次提交
  26. 10 5月, 2013 2 次提交