aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation
Commit message (Collapse)AuthorAgeFilesLines
* move the cache to the AR models and populate it on inheritedAaron Patterson2013-08-301-20/+29
|
* no need for the const_get since we lockAaron Patterson2013-08-301-5/+1
|
* require a class for cache computationsAaron Patterson2013-08-301-1/+3
|
* cache misses should return selfAaron Patterson2013-08-301-1/+1
|
* check class hierarchy with is_a? in PredicateBuilder.expandMikhail Dieterle2013-08-271-1/+1
| | | | add changelog entry for #11945
* let AR::FinderMethods#exists? return singletons in all cases [closes #11592]Xavier Noria2013-08-191-7/+7
| | | | | | | | | | | | | | | | | | | | | 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
* Minor optimization and code cleanup in query_methods.Eugene Gilburg2013-07-311-38/+45
| | | | | | | | - Use symbols rather than strings where possible to avoid extra object construction - Use destructive methods where possible to avoid extra object construction - Use array union rather than concat followed by uniq - Use shorthand block syntax where possible - Use consistent multiline block styles, method names, method parenteses style, and spacing
* Merge branch 'revert-order-prepending'Rafael Mendonça França2013-07-301-2/+2
|\ | | | | | | | | Conflicts: activerecord/CHANGELOG.md
| * Revert change on ActiveRecord::Relation#order method that prepends newRafael Mendonça França2013-07-291-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | order on the old ones The previous behavior added a major backward incompatibility since it impossible to have a upgrade path without major changes on the application code. We are taking the most conservative path to be consistent with the idea of having a smoother upgrade on Rails 4. We are reverting the behavior for what was in Rails 3.x and, if needed, we will implement a new API to prepend the order clauses in Rails 4.1.
* | Add ability to specify how a class is converted to Arel predicatesgrif2013-07-283-35/+74
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds the ability for rails apps or gems to have granular control over how a domain object is converted to sql. One simple use case would be to add support for Regexp. Another simple case would be something like the following: class DateRange < Struct.new(:start, :end) def include?(date) (start..end).cover?(date) end end class DateRangePredicate def call(attribute, range) attribute.in(range.start..range.end) end end ActiveRecord::PredicateBuilder.register_handler(DateRange, DateRangePredicate.new) More complex cases might include taking a currency object and converting it from EUR to USD before performing the query. By moving the existing handlers to this format, we were also able to nicely refactor a rather nasty method in PredicateBuilder.
* stop relying on side effects of const_missingAaron Patterson2013-07-231-7/+7
|
* add a specific factory method rather than using newAaron Patterson2013-07-233-6/+4
|
* Improve ActiveRecord::QueryMethods#includes docsHenrik Hodne2013-07-171-0/+8
| | | | | | | | It's not immediately clear whether you can pass in multiple relations or not. After going through the code a bit, I saw that the arguments are just appended to an array. Also, added nested relations example. [ci skip]
* decouple the manager class from building join constraintsAaron Patterson2013-07-161-4/+5
|
* save another array allocationAaron Patterson2013-07-151-1/+1
|
* removing useless assingmentAaron Patterson2013-07-151-1/+1
|
* reorder bind parameters when merging relationsAaron Patterson2013-07-151-2/+18
|
* use arel rather than slapping together SQL stringsAaron Patterson2013-07-151-2/+4
|
* Merge pull request #11439 from ernie/only-scan-strings-for-nodesYves Senn2013-07-141-1/+1
|\ | | | | Blacklist->whitelist for reference scans in order!
| * Blacklist->whitelist for reference scans in order!Ernie Miller2013-07-141-1/+1
| | | | | | | | | | | | Stop special-casing Arel::Nodes as exempt from reference scanning in order. Instead, only scan order values that are strings for a table reference.
* | re-introduce `select_for_count` private method.Yves Senn2013-07-141-5/+10
|/ | | | See https://github.com/rails/rails/commit/da9b5d4a8435b744fcf278fffd6d7f1e36d4a4f2#commitcomment-3630064 for discussion.
* Typo fix [skip ci]Ankit Gupta2013-07-121-1/+1
|
* fix visibility of the relation construction methodsAaron Patterson2013-07-091-5/+7
|
* pass arel to select_all rather than depend on method_missingAaron Patterson2013-07-091-1/+1
|
* Extract common query to a constant.Vipul A M2013-07-061-1/+3
| | | | Perf ref: https://gist.github.com/vipulnsward/8209749201dfdd678c97
* no need to to_sym the column name, leave it as-isAaron Patterson2013-07-021-1/+1
|
* resolve aliases before passing the hash to the predicate builderAaron Patterson2013-07-022-4/+11
|
* avoid intermediate zipped arrayAaron Patterson2013-07-011-3/+2
|
* make the identity type a singleton to save on object creationAaron Patterson2013-07-011-3/+1
|
* only deal with strings internallyAaron Patterson2013-07-011-3/+3
|
* build an AST rather than slapping strings togetherAaron Patterson2013-07-011-11/+7
|
* stop exposing the underlying alias datastructureAaron Patterson2013-07-011-4/+4
|
* we don't need to to_s the columnAaron Patterson2013-07-011-1/+1
|
* the data structure used to store attribute aliases should not be exposedAaron Patterson2013-07-011-2/+2
|
* Remove deprecated `:distinct` option from `Relation#count`.Yves Senn2013-07-011-5/+0
|
* Merge pull request #11161 from dmitry/find_in_batches_works_without_loggerCarlos Antonio da Silva2013-06-281-2/+2
|\ | | | | | | | | ActiveRecord find_in_batches should work without logger When I set logger to nil both methods from Batches module find_in_batches or find_each should work anyway.
| * find_in_batches should work without loggerDmitry Polushkin2013-06-281-2/+2
| |
* | Remove order_values argument now that default_scope is simplifiedCarlos Antonio da Silva2013-06-281-5/+5
| | | | | | | | | | | | | | | | | | | | In 94924dc32baf78f13e289172534c2e71c9c8cade 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.
* | Simplify/fix implementation of default scopesJon Leighton2013-06-285-17/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Merge pull request #10992 from Empact/find-each-enumeratorCarlos Antonio da Silva2013-06-251-2/+13
|\ \ | | | | | | | | | When .find_each is called without a block, return an Enumerator.
| * | When .find_each is called without a block, return an Enumerator.Ben Woosley2013-06-191-2/+13
| |/ | | | | | | This lets us do things like call: .find_each.with_index
* / flatten merged join_values before building the joinsNeeraj Singh2013-06-221-1/+1
|/ | | | | | | | fixes #10669 While joining_values special treatment is given to string values. By flattening the array it ensures that string values are detected as strings and not arrays.
* Merge pull request #10898 from dmitry/find_first_refactor_duplicationRafael Mendonça França2013-06-141-11/+10
|\ | | | | Refactored ActiveRecord `first` method to get rid of duplication.
| * rename method `find_first_records` to `find_first_with_limit`Dmitry Polushkin2013-06-101-3/+3
| |
| * Refactored ActiveRecord `first` method to get rid of duplication.Dmitry Polushkin2013-06-091-11/+10
| |
* | Merge branch 'master' of github.com:lifo/docrailsVijay Dev2013-06-142-22/+85
|\ \ | | | | | | | | | | | | Conflicts: guides/source/upgrading_ruby_on_rails.md
| * | copy edits [ci skip]Vijay Dev2013-06-141-19/+15
| | |
| * | doc: renaming table name to follow the file's standardsThiago Pinto2013-06-081-2/+2
| | |
| * | instructions for variations and alternatives for ActiveRecord#findThiago Pinto2013-06-081-1/+35
| | |
| * | explaining ActiveRecord#first in rails 3 and 4Thiago Pinto2013-06-081-0/+13
| | |