aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation/query_methods.rb
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #10767 from jmondo/masterCarlos Antonio da Silva2013-05-291-1/+1
|\ | | | | Use grep instead of select with === in QueryMethods
| * use grep over select for consistency and efficiencyJohn Gesimondo2013-05-281-1/+1
| | | | | | | | pass block directly to grep
* | `implicit_readonly` is being removed in favor of calling `readonly` explicitlyYves Senn2013-05-271-5/+0
|/
* added to rdoc for unscope that default_scope winsNeeraj Singh2013-05-031-0/+3
|
* When empty options passed to having clause having_values was [nil] but ↵Fyodor2013-04-231-1/+0
| | | | should be empty.
* Merge branch 'master' of github.com:lifo/docrailsVijay Dev2013-04-111-2/+1
|\ | | | | | | | | Conflicts: guides/source/action_mailer_basics.md
| * mark relation mutator as :nodoc: [ci skip]Francesco Rodriguez2013-04-021-2/+1
| |
* | converge three lines into oneNeeraj Singh2013-04-101-3/+1
|/
* Fix some typos in AR- CHANGELOG, tests, method doc. fixedVipul A M2013-03-201-1/+1
|
* rename `Relation#uniq` to `Relation#distinct`. `#uniq` still works.Yves Senn2013-03-151-9/+11
| | | | | | | | The similarity of `Relation#uniq` to `Array#uniq` is confusing. Since our Relation API is close to SQL terms I renamed `#uniq` to `#distinct`. There is no deprecation. `#uniq` and `#uniq!` are aliases and will continue to work. I also updated the documentation to promote the use of `#distinct`.
* Merge branch 'master' of github.com:lifo/docrailsVijay Dev2013-03-051-1/+1
|\
| * Fix WhereChain docs to mention only notErnie Miller2013-03-041-1/+1
| |
* | Remove .all usage from unscope doc examples [ci skip]Carlos Antonio da Silva2013-03-041-4/+4
| |
* | Use 1.9 hash style in changelog and doc examples [ci skip]Carlos Antonio da Silva2013-03-041-3/+3
| |
* | Created an unscope method for removing relations from a chain ofwangjohn2013-03-031-0/+94
|/ | | | | relations. Specific where values can be unscoped, and the unscope method still works when relations are merged or combined.
* Expand order(:symbol) to "table".symbol to prevent broken queries on PG.Yves Senn2013-02-251-0/+5
| | | | | | | | | | Fixes #9275. When `#order` is called with a Symbol this patch will prepend the quoted_table_name. Before the postgresql adapter failed to build queries containg a join and an order with a symbol. This expansion happens for all adapters.
* Make explicit the method will raise an exceptionRafael Mendonça França2013-02-241-10/+10
| | | | Taking the wise advice of @carlosantoniodasilva
* Merge pull request #9345 from ↵Rafael Mendonça França2013-02-201-10/+10
|\ | | | | | | | | wangjohn/change_name_of_query_method_argument_checker_for_clarity Renaming the check_empty_arguments method to something more descriptive.
| * Renaming the check_empty_arguments method to something more descriptive.wangjohn2013-02-201-10/+10
| | | | | | | | | | The function is now called has_arguments? so that it's easier to tell that it's just checking to see if the args are blank or not.
* | removes some remaining relation bang methods documentation [ci skip]Xavier Noria2013-02-201-3/+0
| |
* | adds an example in the docs of #not with multiple conditions [ci skip]Xavier Noria2013-02-201-4/+8
|/
* Added comments about the check_empty_arguments method which is calledwangjohn2013-02-201-11/+27
| | | | | for query methods in a where_clause. Also, modified the CHANGELOG entry because it had false information and added tests.
* Raise an error when query methods have blank arguments, and when blank ↵John J Wang2013-02-191-9/+23
| | | | arguments are meaningless.
* Add example for ActiveRecord::Base.joins using a string as argumentMaurizio De Santis2013-02-071-0/+5
|
* Add example for ActiveRecord::Base.group using a string as argumentMaurizio De Santis2013-02-071-0/+3
|
* Add documentation for ActiveRecord.select when use strings as argumentsMaurizio De Santis2013-02-071-0/+10
|
* reduce the number of queries on IN clauses, fix relation queries in `where`Aaron Patterson2013-01-241-0/+5
|
* Improve where.not docs [ci skip]Carlos Antonio da Silva2012-12-081-14/+8
| | | | | | | * Fix example queries * Remove doc entries of where.like/not_like. * Remove :chain from where.not related docs. To me that's an implementation detail and we don't expect people to use where(:chain).not.
* Rollback where.like and where.not_likeCarlos Antonio da Silva2012-12-071-26/+0
| | | | | | | | | | | | | | | | | | | The real win with these chain methods is where.not, that takes care of different scenarios in a graceful way, for instance when the given value is nil. where("author.id != ?", author_to_ignore.id) where.not("author.id", author_to_ignore.id) Both where.like and where.not_like compared to the SQL versions doesn't seem to give us that much: Post.where("title LIKE 'ruby on%'") Post.where.like(title: 'ruby on%'") Post.where("title NOT LIKE 'ruby on%'") Post.where.not_like(title: 'ruby on%'") Thus Rails is adding where.not, but not where.like/not_like and others.
* Document the types of arguments accepted by AR#notclaudiob2012-12-071-2/+11
| | | | | | | | This commit stems from https://github.com/rails/rails/pull/8332#issuecomment-11127957 Since the formats in which conditions can be passed to `not` differ from the formats in which conditions can be passed to `like` and `not_like`, then I think it's worth adding rdoc and tests to show this behavior
* Fix where.not with in clauseCarlos Antonio da Silva2012-12-071-3/+3
| | | | | | Arel::Nodes::In inherits from Arel::Nodes::Equality, so the case statement was always using the Equality operator for both scenarios, resulting in a not equal query instead.
* Update #where rdoc to match 6ba0f97 [ci skip]claudiob2012-12-071-4/+4
| | | | | | | | This commit updates the rdoc of AR#where to match the changes applied in https://github.com/rails/rails/commit/6ba0f97 that is: * `where(nil)` has the same effect of `where('')`: a no op * `where` (no args) has the same effect of `where(:chain)`: to create a WhereChain
* Ensure there won't be any regression with where(nil) callsCarlos Antonio da Silva2012-12-071-4/+4
| | | | | | | | | | | | | | | | | | | Consider this scenario: if params[:foo] conditions = { foo: true } end foos = Foo.where(conditions).order(:id) When params[:foo] is nil, this would call: foos = Foo.where(nil).order(:id) In this scenario, we want Foo.where(conditions) to be the same as calling Foo.all, otherwise we'd get a "NoMethodError order for WhereChain". Related to #8332.
* Merge pull request #8332 from amatsuda/ar_where_chainCarlos Antonio da Silva2012-12-071-7/+98
|\ | | | | | | | | | | | | | | Relation.where with no args can be chained with not, like, and not_like Conflicts: activerecord/CHANGELOG.md activerecord/lib/active_record/relation/query_methods.rb
| * Relation.where with no args can be chained with not, like, and not_likeAkira Matsuda2012-11-301-7/+96
| | | | | | | | | | | | | | | | | | | | | | | | | | | | examples: Model.where.not field: nil #=> "SELECT * FROM models WHERE field IS NOT NULL Model.where.like name: 'Jeremy%' #=> "SELECT * FROM models WHERE name LIKE 'Jeremy%' this feature was originally suggested by Jeremy Kemper https://github.com/rails/rails/pull/5950#issuecomment-5591330 Closes #5950
* | Mark Relation mutators as :nodoc:Jon Leighton2012-11-301-46/+22
|/ | | | | These are for internal use only and cannot be relied on as part of the public API. See discussion on 8c2c60511beaad05a218e73c4918ab89fb1804f0.
* Merge branch 'master' of github.com:lifo/docrailsVijay Dev2012-11-171-9/+9
|\ | | | | | | | | Conflicts: actionpack/lib/action_dispatch/routing/redirection.rb
| * 1.9 Syntax related changesAvnerCohen2012-11-101-9/+9
| |
* | Use flat_map when building AR orderCarlos Antonio da Silva2012-11-041-6/+4
|/
* ActiveRecord::Relation#none! method.Juanjo Bazán2012-10-281-0/+5
|
* buckets hash isn't public, so use symbol keys to avoid stringAaron Patterson2012-10-151-8/+8
| | | | allocations
* performance improvements to joins!Aaron Patterson2012-10-121-3/+1
| | | | | | | | | | | | | | | | | | Before: Calculating ------------------------------------- ar 87 i/100ms ------------------------------------------------- ar 823.4 (±11.8%) i/s - 4089 in 5.070234s After: Calculating ------------------------------------- ar 88 i/100ms ------------------------------------------------- ar 894.1 (±3.9%) i/s - 4488 in 5.028161s Same test as 3a6dfca7f5f5bd45cea2f6ac348178e72423e1d5
* trailling whitespace cleanup in query_methods.rbYves Senn2012-10-121-12/+12
|
* learn ActiveRecord::QueryMethods#order work with hash argumentsTima Maslyuchenko2012-10-121-4/+47
|
* Revert "Use flat_map { } instead of map {}.flatten"Santiago Pastorino2012-10-051-2/+2
| | | | | | | | | | | This reverts commit abf8de85519141496a6773310964ec03f6106f3f. We should take a deeper look to those cases flat_map doesn't do deep flattening. irb(main):002:0> [[[1,3], [1,2]]].map{|i| i}.flatten => [1, 3, 1, 2] irb(main):003:0> [[[1,3], [1,2]]].flat_map{|i| i} => [[1, 3], [1, 2]]
* Use flat_map { } instead of map {}.flattenSantiago Pastorino2012-10-051-2/+2
|
* Pass in the model class rather than engineJon Leighton2012-09-131-1/+1
| | | | | | | | | In some circumstances engine was Arel::Table.engine which for separate reasons was an ActiveRecord::Model::DeprecationProxy, which caused a deprecation warning. In any case, we want the actual model class here, since we want to use it to infer information about associations.
* Accept belongs_to assoc. keys in ActiveRecord queriesbeerlington2012-09-111-0/+18
| | | | | | | | | | | | | Allows you to specify the model association key in a belongs_to relationship instead of the foreign key. The following queries are now equivalent: Post.where(:author_id => Author.first) Post.where(:author => Author.first) PriceEstimate.where(:estimate_of_type => 'Treasure', :estimate_of_id => treasure) PriceEstimate.where(:estimate_of => treasure)
* Model.select takes a variable list of arguments.Isaac Sanders2012-08-231-11/+12
| | | | | | This is a cleaner version of #6916. Closes #3165.
* load active_support/core_ext/object/blank in active_support/railsXavier Noria2012-08-021-1/+0
|