aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/finder_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Use frozen-string-literal in ActiveRecordKir Shatrov2017-07-191-0/+2
|
* Skip query cache for in_batches and friendsEugene Kenny2017-07-061-0/+28
| | | | | | | | | | | The `find_each`, `find_in_batches` and `in_batches` APIs usually operate on large numbers of records, where it's preferable not to load them all into memory at once. If the query cache is enabled, it will hold onto the query results until the end of the execution context (request/job), which means the memory used is still proportional to the total number of records. These queries are typically not repeated, so the query cache isn't desirable here.
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-021-1/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
|
* Remove the redundant `test_find_all_with_join` in ARKoichi ITO2017-06-021-10/+0
|
* Remove a redundant test assertionKoichi ITO2017-05-271-1/+0
|
* exclude ORDER BY clause for exists? (#28699)Boris Slobodin2017-04-101-0/+5
|
* More exercise `exists?` testsRyuta Kamizono2017-04-081-5/+18
|
* Fix `find_nth` with `limit_value`Ryuta Kamizono2017-02-261-3/+3
| | | | | If the `index` exceeds a `limit`, simply return an empty result without querying the database.
* Correct spellingBenjamin Fleischer2017-02-051-4/+4
| | | | | | | ``` go get -u github.com/client9/misspell/cmd/misspell misspell -w -error -source=text . ```
* Fix `find_by` and `where` consistencyRyuta Kamizono2017-01-041-0/+5
| | | | | | | | | | The alternative of #26213. Currently `find_by` and `where` with AR object return inconsistent result. This is caused by statement cache does not support AR object. Passing to finder method to fix the issue. Fixes #26210.
* Fix test name `deprecated` to `not_permitted`Ryuta Kamizono2017-01-031-2/+2
| | | | Follow up to 4b6709e818177792735e99a70ec03210c0ac38dc.
* Raise ArgumentError when a instance of ActiveRecord::Base is passed toRafael Mendonça França2017-01-031-3/+3
| | | | find and exists?
* Raises IrreversibleOrderError when using last with an irreversible orderRafael Mendonça França2016-12-291-1/+1
|
* "Use assert_nil if expecting nil. This will fail in minitest 6."Akira Matsuda2016-12-251-12/+12
|
* Privatize unneededly protected methods in Active Record testsAkira Matsuda2016-12-241-1/+1
|
* Remove duplicated lineRyuta Kamizono2016-12-111-1/+0
|
* Add more rubocop rules about whitespacesRafael Mendonça França2016-10-291-26/+26
|
* improve error message when include assertions failMichael Grosser2016-09-161-3/+3
| | | | | | assert [1, 3].includes?(2) fails with unhelpful "Asserting failed" message assert_includes [1, 3], 2 fails with "Expected [1, 3] to include 2" which makes it easier to debug and more obvious what went wrong
* Merge pull request #25671 from ↵Rafael França2016-08-161-2/+2
|\ | | | | | | | | kamipo/dont_handle_as_associated_predicate_if_table_has_column Do not handle as an associated predicate if a table has the column
| * Do not handle as an associated predicate if a table has the columnRyuta Kamizono2016-08-161-2/+2
| | | | | | | | | | | | If handled as an associated predicate even though a table has the column, will generate invalid SQL by valid column name treated as a table name.
* | Merge pull request #26000 from kamipo/remove_sanitizeRafael França2016-08-161-5/+0
|\ \ | |/ |/| Remove internal `sanitize` method
| * Remove internal `sanitize` methodRyuta Kamizono2016-07-311-5/+0
| | | | | | | | | | Currently internal `sanitize`/`quote_value` method is only used for `quoted_id`. Simply it is enough to use `connection.quote` public API instead.
* | Merge pull request #26097 from Dagnan/fix_recordnotfound_args_rebasedRafael França2016-08-161-0/+10
|\ \ | | | | | | When calling association.find RecordNotFound is now raised with the s…
| * | When calling association.find RecordNotFound is now raised with the same ↵Michel Pigassou2016-08-131-0/+10
| | | | | | | | | | | | argument as when we do it in Record.find (primary_key, id and model).
* | | Add three new rubocop rulesRafael Mendonça França2016-08-161-6/+6
|/ / | | | | | | | | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* | Use `FETCH FIRST` for Oracle12 database and Arel Oracle12 visitorYasuo Honda2016-08-081-3/+3
| | | | | | | | | | also test `ROWNUM <=` for Oracle 11g or older version of Oracle and Oracle visitor Oracle 12c database and Arel Oracle12 visitor supports better top N query.
* | applies remaining conventions across the projectXavier Noria2016-08-061-3/+2
| |
* | normalizes indentation and whitespace across the projectXavier Noria2016-08-061-1/+1
| |
* | modernizes hash syntax in activerecordXavier Noria2016-08-061-20/+17
| |
* | applies new string literal convention in activerecord/testXavier Noria2016-08-061-113/+113
|/ | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Prevent `RangeError` for `FinderMethods#exists?`Ryuta Kamizono2016-06-161-4/+2
| | | | | | | | | | | | | `FinderMethods#exists?` should return a boolean rather than raising an exception. `UniquenessValidator#build_relation` catches a `RangeError` because it includes type casting due to a string value truncation. But a string value truncation was removed at #23523 then type casting in `build_relation` is no longer necessary. aa06231 removes type casting in `build_relation` then a `RangeError` moves to `relation.exists?`. This change will remove the catching a `RangeError`.
* Followup of #24835Vipul A M2016-05-031-1/+1
| | | | Fix failing tests
* Allow symbols using "dot notation" to be passed to whereSean Griffin2016-04-121-1/+6
| | | | | | | | | | | | | | | | | In 04ac5655be91f49cd4dfe2838df96213502fb274 I assumed that we would never want to pass the "table_name.column_name" form to where with a symbol. However, in Ruby 2.2 and later, you can quote symbols using the new hash syntax, so it's a semi-reasonable thing to do if we want to support the dot notation (which I'd rather deprecate, but that would be too painful of a migration). Instead we've changed the definition of "this is a table name with a dot" to when the value associated is a hash. It would make very little sense to write `where("table_name.column_name": { foo: :bar })` in any scenario (other than equality for a JSON column which we don't support through `where` in this way). Close #24514.
* comment out failing .second and .third testsBrian Christian2016-02-271-3/+3
|
* adding additional tests for offset and limit behaviorBrian Christian2016-02-271-0/+8
|
* additional test assertions (limit and offset)Brian Christian2016-02-271-0/+16
|
* AR #second_to_last tests and finder methodsBrian Christian2016-02-271-0/+36
|
* remove args from assert_nothing_raised in testsTara Scherner de la Fuente2016-02-221-3/+3
|
* Merge pull request #23377 from bogdan/last-with-sqlEileen M. Uchitelle2016-02-131-8/+36
|\ | | | | Fix AR::Relation#last bugs instroduced in 7705fc
| * Make ActiveRecord::Relation#last to reverse SQL orderBogdan Gusiev2016-02-131-8/+36
| | | | | | | | instead of loading the relation into memory
* | Fix grammar `a` to `an` [ci skip]Ryuta Kamizono2016-02-131-1/+1
|/
* Revert "Merge pull request #16400 from bogdan/last-with-sql"Sean Griffin2016-02-011-23/+9
| | | | | | | | | | This reverts commit 9f3730a516f30beb0050caea9539f8d6b808e58a, reversing changes made to 2637fb75d82e1c69333855abd58c2470994995d3. There are additional issues with this commit that need to be addressed before this change is ready (see #23377). This is a temporary revert in order for us to have more time to address the issues with that PR, without blocking the release of beta2.
* Reworked ActiveRecord::Relation#last to always use SQLBogdan Gusiev2016-01-281-9/+23
| | | | instead of loading relation
* Fix ↵Ryuta Kamizono2015-12-191-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `test_find_with_order_on_included_associations_with_construct_finder_sql_for_association_limiting_and_is_distinct` to NULL-agnostic way The sort order of NULL depends on the RDBS implementation. This commit is to fix the test to NULL-agnostic way. Example: ``` activerecord_unittest=# SELECT DISTINCT "posts"."id", author_addresses_authors.id AS alias_0 FROM "posts" LEFT OUTER JOIN "authors" ON "authors"."id" = "posts"."author_id" LEFT OUTER JOIN "author_addresses" ON "author_addresses"."id" = "authors"."author_address_id" LEFT OUTER JOIN "categorizations" ON "categorizations"."category_id" = "posts"."id" LEFT OUTER JOIN "authors" "authors_posts" ON "authors_posts"."id" = "categorizations"."author_id" LEFT OUTER JOIN "author_addresses" "author_addresses_authors" ON "author_addresses_authors"."id" = "authors_posts"."author_address_id" ORDER BY author_addresses_authors.id DESC; id | alias_0 ----+--------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 1 | 1 (12 rows) ``` ``` root@localhost [activerecord_unittest] > SELECT DISTINCT `posts`.`id`, author_addresses_authors.id AS alias_0 FROM `posts` LEFT OUTER JOIN `authors` ON `authors`.`id` = `posts`.`author_id` LEFT OUTER JOIN `author_addresses` ON `author_addresses`.`id` = `authors`.`author_address_id` LEFT OUTER JOIN `categorizations` ON `categorizations`.`category_id` = `posts`.`id` LEFT OUTER JOIN `authors` `authors_posts` ON `authors_posts`.`id` = `categorizations`.`author_id` LEFT OUTER JOIN `author_addresses` `author_addresses_authors` ON `author_addresses_authors`.`id` = `authors_posts`.`author_address_id` ORDER BY author_addresses_authors.id DESC; +----+---------+ | id | alias_0 | +----+---------+ | 1 | 1 | | 3 | NULL | | 1 | NULL | | 2 | NULL | | 4 | NULL | | 5 | NULL | | 6 | NULL | | 7 | NULL | | 8 | NULL | | 9 | NULL | | 10 | NULL | | 11 | NULL | +----+---------+ 12 rows in set (0.00 sec) ```
* Merge pull request #22653 from matthewd/find_array_orderedMatthew Draper2015-12-181-1/+74
|\ | | | | | | ActiveRecord::Base#find(array) returning result in the same order as the array passed
| * Implement limit & offset for ourselvesMatthew Draper2015-12-181-2/+2
| | | | | | | | | | | | | | | | | | | | We know the query will return exactly one row for each entry in the `ids` array, so we can do all the limit/offset calculations on that array, in advance. I also split our new ordered-ids behaviour out of the existing `find_some` method: especially with this change, the conditionals were overwhelming the actual logic.
| * Adding a new test using chained where, limit and find([pks])Miguel Grazziotin2015-08-071-2/+12
| |
| * WIP: fixing the limit bug and introducing new tests (failing for now) on ↵Miguel Grazziotin2015-06-191-4/+25
| | | | | | | | .find(array) with offset
| * do not change the order of the result if the object was already ordered by ↵Miguel Grazziotin2015-06-051-0/+5
| | | | | | | | the user via :order clause