aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation/query_methods.rb
Commit message (Collapse)AuthorAgeFilesLines
* 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
|
* AR::Relation#order: make new order prepend old oneBogdan Gusiev2012-07-311-2/+2
| | | | | | | User.order("name asc").order("created_at desc") # SELECT * FROM users ORDER BY created_at desc, name asc This also affects order defined in `default_scope` or any kind of associations.
* Revert "Removing composed_of from ActiveRecord."Rafael Mendonça França2012-07-271-1/+2
| | | | | | | | | | | This reverts commit 14fc8b34521f8354a17e50cd11fa3f809e423592. Reason: we need to discuss a better path from this removal. Conflicts: activerecord/lib/active_record/reflection.rb activerecord/test/cases/base_test.rb activerecord/test/models/developer.rb
* Changelog and doc updates for the previous changes.Jon Leighton2012-07-271-6/+6
|
* Deprecate ActiveRecord::Base.scoped.Jon Leighton2012-07-271-1/+1
| | | | | | | It doesn't serve much purpose now that ActiveRecord::Base.all returns a Relation. The code is moved to active_record_deprecated_finders.
* improve NullRelation docs [ci skip]Vijay Dev2012-07-211-4/+4
|
* minor copy edits [ci skip]Vijay Dev2012-07-211-1/+1
|
* TypoOscar Del Ben2012-07-161-1/+0
|
* Add documentation for query_methods bang methodsOscar Del Ben2012-07-161-1/+20
|
* Add nodoc to create_with_valueOscar Del Ben2012-07-161-1/+1
| | | | | Reason: all *_value methods are defined dynamically and so don't appear in the documentation.
* Add documentation for arel and build_arelOscar Del Ben2012-07-161-0/+2
|
* Add documentation for create_withOscar Del Ben2012-07-161-1/+19
|
* Merge branch 'master' of github.com:lifo/docrailsVijay Dev2012-07-151-2/+39
|\
| * Add docs for having, lock and readonlyOscar Del Ben2012-07-071-0/+12
| |
| * Add doc for joins and improve includes docOscar Del Ben2012-07-071-2/+17
| |
| * Add docs for eager_laod and preloadOscar Del Ben2012-07-071-0/+10
| |
* | fix association :extend optionJon Leighton2012-07-131-1/+1
| |
* | support relations created with a table aliasJon Leighton2012-07-131-1/+1
|/
* minor text change [ci skip]Vijay Dev2012-07-071-1/+1
|
* Revert "Add nodoc to relation methods"Vijay Dev2012-07-071-22/+24
| | | | | | This reverts commit c47a698d5d497340d4e349257522212173865838. Reason: Let's revert pending further discussions
* Add nodoc to relation methodsOscar Del Ben2012-07-061-24/+22
|
* Add order docsOscar Del Ben2012-07-051-0/+10
|
* Add group documentationOscar Del Ben2012-07-051-0/+12
|
* Add documentation for includesOscar Del Ben2012-07-051-0/+11
|
* fixing typo in from documentationSubba Rao Pasupuleti2012-06-281-2/+2
|
* Use args.flatten! in query methods when applicableCarlos Antonio da Silva2012-06-251-7/+12
| | | | | Try to use more destructive methods on *args when applicable, to avoid creating new objects.
* Merge branch 'master' of github.com:lifo/docrailsVijay Dev2012-06-221-3/+15
|\