aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/finder_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Backport a super-simplified version of #6792, fixingBen Woosley2013-05-141-0/+12
| | | | | | | | | | | | | that #exists? and others can produce invalid SQL: "SELECT DISTINCT DISTINCT" The combination of a :uniq => true association and the #distinct call in #construct_limited_ids_condition combine to create invalid SQL, because we're explicitly selecting DISTINCT, and also sending #distinct on to AREL, via the relation#distinct_value. Where #6792 was the forever fix, this is the minimal fix. Instead of properly indicating the distinctness of the query through #uniq_value alone, we use a literal select statement and set #uniq_value to always be falsey
* adding test for the symbol refsAaron Patterson2013-04-261-0/+7
|
* Merge branch '3-2-sec' into 3-2-secmergeAaron Patterson2012-12-231-0/+12
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 3-2-sec: CVE-2012-5664 options hashes should only be extracted if there are extra parameters updating changelog updating the changelogs updating the changelog for the CVE Add release date of Rails 3.2.9 to documentation Conflicts: actionmailer/CHANGELOG.md actionpack/CHANGELOG.md activemodel/CHANGELOG.md activerecord/CHANGELOG.md activeresource/CHANGELOG.md activesupport/CHANGELOG.md railties/CHANGELOG.md
| * CVE-2012-5664 options hashes should only be extracted if there are extra ↵Aaron Patterson2012-12-231-0/+12
| | | | | | | | parameters
* | Use nil? instead of blank? to check dynamic finder resultNikita Afanasenko2012-11-131-0/+5
|/ | | | | | | It's safe to use `nil?` instead of `blank?` because it's impossible to get an array on finder with bang; `all_by` finder matches against regex without bang: `when /^find_(all_|last_)?by_([_a-zA-Z]\w*)$/`. Fixes #7238
* Merge pull request #6698 from yahonda/address_ora_911_masterRafael Mendonça França2012-06-111-1/+1
| | | | Address ORA-00911 errors because of the heading underscore.
* Merge pull request #6521 from Empact/throw-resultRafael Mendonça França2012-06-101-1/+6
| | | | | | Fix that #exists? can blow up with ThrowResult exception Conflicts: activerecord/lib/active_record/relation/finder_methods.rb
* Add test to column alias in `exists?` SQL.Rafael Mendonça França2012-06-101-0/+6
| | | | | | | | This behavior was added in dd286a4c735dac1db8c9262581c7f29c44d1f695 Closes #1139. Fixes #2553, #1141, #1623 and #2062.
* Return false for exists? with new records - fixes #6199.Andrew White2012-05-101-0/+1
| | | | (cherry picked from commit fa21b73ebb8339ad388f149c817c433b6254d490)
* Add order to tests that rely on db ordering, to fix failing tests on pgCarlos Antonio da Silva2012-03-221-2/+2
| | | | | | | Also skip persistente tests related to UPDATE + ORDER BY for postgresql PostgreSQL does not support updates with order by, and these tests are failing randomly depending on the fixture loading order now.
* fix activerecord query_method regression with offset into FixnumDenis Jean2012-03-131-0/+4
| | | | | | add test to show offset query_methods on mysql & mysql2 change test to cover public API
* Add dynamic find_or_create_by_{attribute}! method.Andrew White2012-03-121-0/+22
| | | | | | | | | (cherry picked from commit 5282485d310d1a6ffcf55e4e7f56ab234e16880d) Conflicts: activerecord/CHANGELOG.md activerecord/lib/active_record/dynamic_finder_match.rb
* Merge pull request #4715 from pwim/find-create-multi-argsJon Leighton2012-01-271-0/+11
| | | | Fix regression from Rails 3.1
* Deprecate set_primary_key in favour of self.primary_key=Jon Leighton2011-11-291-1/+1
|
* Fixes issue #3483, regarding using a mixture of ranges and discrete values ↵Ryan Naughton2011-11-141-1/+1
| | | | in find conditions. Paired with Joey Schoblaska.
* Failing test case for issue #3483Gabriel Sobrinho2011-11-141-0/+4
|
* exclude ORDER BY clause when querying Relation#exists?Akira Matsuda2011-11-091-0/+5
|
* Add ROWNUM to test first and last to support Oracle.Yasuo Honda2011-09-071-2/+2
|
* Merge pull request #2485 from akaspick/exists_fixJon Leighton2011-09-071-0/+9
|\ | | | | fix exists? to return false if passed nil (which may come from a missing
| * fix exists? to return false if passed nil (which may come from a missing URL ↵Andrew Kaspick2011-08-101-0/+9
| | | | | | | | param)
* | Use LIMIT sql word in last when it's possibleDamien Mathieu2011-09-051-1/+18
| |
* | use LIMIT SQL word in first - Closes #2783Damien Mathieu2011-09-051-0/+9
|/
* Raise an ArgumentError if user passing less number of argument in the ↵Prem Sichanugrist2011-07-171-0/+8
| | | | | | | | | | | | | dynamic finder The previous behavior was unintentional, and some people was relying on it. Now the dynamic finder will always expecting the number of arguments to be equal or greater (so you can still pass the options to it.) So if you were doing this and expecting the second argument to be nil: User.find_by_username_and_group("sikachu") You'll now get `ArgumentError: wrong number of arguments (1 for 2).` You'll then have to do this: User.find_by_username_and_group("sikachu", nil)
* formatsAkira Matsuda2011-07-091-5/+5
|
* fix AR having() not to raise NoMethodError when the given argument does not ↵Akira Matsuda2011-07-091-0/+7
| | | | | | respond to empty? having raises NoMethodError: undefined method `empty?' when a Fixnum or Date/Time were passed via varargs
* please use ruby -I lib:test path/to/test.rb, or export RUBY_OPTAaron Patterson2011-06-061-1/+1
|
* Refactor Active Record test connection setup. Please see the ↵Jon Leighton2011-06-041-1/+1
| | | | RUNNING_UNIT_TESTS file for details, but essentially you can now configure things in test/config.yml. You can also run tests directly via the command line, e.g. ruby path/to/test.rb (no rake needed, uses default db connection from test/config.yml). This will help us fix the CI by enabling us to isolate the different Rails versions to different databases.
* Fix for #371Nick Howard2011-05-081-0/+21
| | | | | | | | | | | | if a query contains a limit or an offset, ActiveRecord::FinderMethods#find_last had inconsistent behavior. If the records were loaded, it returned the last record in the cached list. If they were not, it reversed the order of the query and changed the limit to one. If the earlier limit was less than the total matching the query in the db, it would return a different record than if the records had been cached. This commit changes find_last so that it loads the records when getting the last record on a query containing a limit or an offset, which makes the behavior consistent.
* supporting nil when passed in as an IN clauseAaron Patterson2011-04-291-3/+4
|
* Test that passing nil member of array in conditions retrieves records with nilgmile2011-04-291-0/+22
| | | | value on a selected field.
* Return nil from read_attribute(:foo) if 'foo' is not present in the ↵Jon Leighton2011-04-151-1/+2
| | | | @attributes hash, but the _foo method has been defined. This brings the behaviour into line with the 3-0-stable branch and the master branch before 93641ed6c8c684f6b4db02b6c8a22fa9bc7f0eaf (there were previously no assertions about this which is why the change slipped through). Note that actually calling the 'foo' method will still raise an error if the attribute is not present.
* test against AR class rather than the relation (thanks Andrew White!)Aaron Patterson2011-03-291-2/+2
|
* order is not guaranteed by this select, so add an order and call first!Aaron Patterson2011-03-291-1/+1
|
* Delegate first!, last!, any? and many? to scopedAndrew White2011-03-291-0/+16
|
* Change exists? so that it doesn't instantiate records [#6127 state:resolved]Andrew White2011-03-291-0/+5
|
* add #first! and #last! to models & relationsJosh Susser2011-03-241-0/+24
|
* Merge branch 'master' into nested_has_many_throughJon Leighton2011-03-041-1/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: activerecord/CHANGELOG activerecord/lib/active_record/association_preload.rb activerecord/lib/active_record/associations.rb activerecord/lib/active_record/associations/class_methods/join_dependency.rb activerecord/lib/active_record/associations/class_methods/join_dependency/join_association.rb activerecord/lib/active_record/associations/has_many_association.rb activerecord/lib/active_record/associations/has_many_through_association.rb activerecord/lib/active_record/associations/has_one_association.rb activerecord/lib/active_record/associations/has_one_through_association.rb activerecord/lib/active_record/associations/through_association_scope.rb activerecord/lib/active_record/reflection.rb activerecord/test/cases/associations/has_many_through_associations_test.rb activerecord/test/cases/associations/has_one_through_associations_test.rb activerecord/test/cases/reflection_test.rb activerecord/test/cases/relations_test.rb activerecord/test/fixtures/memberships.yml activerecord/test/models/categorization.rb activerecord/test/models/category.rb activerecord/test/models/member.rb activerecord/test/models/reference.rb activerecord/test/models/tagging.rb
| * using arel to compile sql statementsAaron Patterson2010-12-251-1/+1
| |
* | Merge branch 'master' into nested_has_many_throughJon Leighton2010-11-171-22/+32
|\| | | | | | | | | | | Conflicts: activerecord/lib/active_record/associations/has_many_through_association.rb activerecord/test/cases/associations/has_many_through_associations_test.rb
| * removing many unused variablesAaron Patterson2010-11-161-1/+1
| |
| * Finder gives a little bit more info on the lookup column (primary key)Franck Verrot2010-11-131-0/+10
| |
| * use persisted? instead of new_record? wherever possibleDavid Chelimsky2010-11-091-21/+21
| | | | | | | | | | | | | | | | | | | | | | - persisted? is the API defined in ActiveModel - makes it easier for extension libraries to conform to ActiveModel APIs without concern for whether the extended object is specifically ActiveRecord [#5927 state:committed] Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
| * Add some tests for functionality in JoinAssociation which already exists but ↵Jon Leighton2010-10-131-1/+1
| | | | | | | | was previously untested
* | Properly support conditions on any of the reflections involved in a nested ↵Jon Leighton2010-10-191-2/+4
| | | | | | | | through association
* | Refactoring JoinDependency and friends. This improves the code (IMO) ↵Jon Leighton2010-10-061-1/+1
| | | | | | | | including adding some explanatory comments, but more importantly structures it in such a way as to allow a JoinAssociation to produce an arbitrary number of actual joins, which will be necessary for nested has many through support. Also added 3 tests covering functionality which existed but was not previously covered.
* | Fix the tests (I have actually verified that these are also the 'right' ↵Jon Leighton2010-10-031-1/+1
|/ | | | fixes, rather than just making the tests pass again)
* fisting test organizationAaron Patterson2010-09-291-51/+0
|
* query value is converted to_s instead of to_yamlRainerBlessing2010-08-031-0/+8
| | | | Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* removing unused models from testsSubba Rao Pasupuleti2010-07-211-1/+0
| | | | | | [#5153 state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>
* Final iteration of use better testing methodsNeeraj Singh2010-05-191-1/+1
| | | | | | [#4652 state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>