aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/relation
Commit message (Collapse)AuthorAgeFilesLines
* Handle aliased attributes in ActiveRecord::Relation.Godfrey Chan2013-05-011-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | When using symbol keys, ActiveRecord will now translate aliased attribute names to the actual column name used in the database: With the model class Topic alias_attribute :heading, :title end The call Topic.where(heading: 'The First Topic') should yield the same result as Topic.where(title: 'The First Topic') This also applies to ActiveRecord::Relation::Calculations calls such as `Model.sum(:aliased)` and `Model.pluck(:aliased)`. This will not work with SQL fragment strings like `Model.sum('DISTINCT aliased')`. Github #7839 *Godfrey Chan*
* stop calling to_sym when building arel nodes [CVE-2013-1854]Aaron Patterson2013-03-151-10/+15
|
* Revert "Merge pull request #9207 from dylanahsmith/mysql-quote-numeric"Steve Klabnik2013-02-271-25/+0
| | | | | This reverts commit 408227d9c5ed7de26310d72a1a99c1ee02311c63, reversing changes made to dca0b57d03deffc933763482e615c3cf0b9a1d97.
* Reverting e170014113 (Change behaviour with empty hash in where clause)Guillermo Iguaran2013-02-081-6/+2
|
* Reverting 16f6f25 (Change behaviour with empty array in where clause)Guillermo Iguaran2013-02-081-3/+1
|
* Change behaviour with empty array in where clauserobertomiranda2013-02-081-1/+3
|
* Change behaviour with empty hash in where clauserobertomiranda2013-02-081-2/+6
|
* active_record: Quote numeric values compared to string columns.Dylan Smith2013-02-071-0/+25
|
* reduce the number of queries on IN clauses, fix relation queries in `where`Aaron Patterson2013-01-241-1/+14
|
* Fix syntax error and remove duplicated testCarlos Antonio da Silva2013-01-081-6/+4
|
* * Strip nils from collections on JSON and XML posts. [CVE-2013-0155] * ↵Aaron Patterson2013-01-081-0/+6
| | | | | | | | | | | | dealing with empty hashes. Thanks Damien Mathieu Conflicts: actionpack/CHANGELOG.md actionpack/lib/action_dispatch/http/request.rb actionpack/lib/action_dispatch/middleware/params_parser.rb activerecord/CHANGELOG.md activerecord/lib/active_record/relation/predicate_builder.rb activerecord/test/cases/relation/where_test.rb
* Revert "Merge branch 'master-sec'"Jeremy Kemper2013-01-081-6/+0
| | | | | This reverts commit 88cc1688d0cb828c17706b41a8bd27870f2a2beb, reversing changes made to f049016cd348627bf8db0d72382d7580bf802a79.
* * Strip nils from collections on JSON and XML posts. [CVE-2013-0155] * ↵Aaron Patterson2013-01-071-0/+6
| | | | | | | | | | | | dealing with empty hashes. Thanks Damien Mathieu Conflicts: actionpack/CHANGELOG.md actionpack/lib/action_dispatch/http/request.rb actionpack/lib/action_dispatch/middleware/params_parser.rb activerecord/CHANGELOG.md activerecord/lib/active_record/relation/predicate_builder.rb activerecord/test/cases/relation/where_test.rb
* Rollback where.like and where.not_likeCarlos Antonio da Silva2012-12-071-17/+2
| | | | | | | | | | | | | | | | | | | 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-0/+12
| | | | | | | | 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-1/+1
| | | | | | 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.
* Move where with blank conditions test to the correct where tests fileCarlos Antonio da Silva2012-12-071-0/+6
| | | | This test does not belong to has many associations test.
* Relation.where with no args can be chained with not, like, and not_likeAkira Matsuda2012-11-301-0/+78
| | | | | | | | | | | | | | 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
* fix querying with an empty hashDamien Mathieu2012-09-191-1/+10
| | | | Closes #6960
* Fix nested association referencesJon Leighton2012-09-121-38/+31
| | | | | Previously the reflection would be looked up on the wrong class. However the test passed because the examples referred back to themselves.
* Accept belongs_to assoc. keys in ActiveRecord queriesbeerlington2012-09-111-1/+69
| | | | | | | | | | | | | 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)
* predicate builder should not recurse for determining where columns.Aaron Patterson2012-05-301-0/+19
Thanks to Ben Murphy for reporting this CVE-2012-2661