aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation
Commit message (Collapse)AuthorAgeFilesLines
...
* | Merge pull request #26598 from ↵Eileen M. Uchitelle2016-10-151-2/+2
|\ \ | | | | | | | | | | | | rutaka-n/raise_record_not_found_with_correct_params initialize errors with name of class and other params
| * | initialize errors with name of class and other paramsv.promzelev2016-09-231-2/+2
| |/
* | Use attribute_names over column_namesKeenan Brock2016-10-041-6/+2
| |
* | Fix doc format for `RecordFetchWarning` [ci skip]Ryuta Kamizono2016-09-271-3/+3
|/
* Merge pull request #26447 from kamipo/reduce_array_allocationSantiago Pastorino2016-09-191-3/+1
|\ | | | | Reduce array allocation when `where` with passed hash
| * Reduce array allocation when `where` with passed hashRyuta Kamizono2016-09-101-3/+1
| | | | | | | | | | In most case `where` is called with passed hash. In the case initializing `binds` is unnecessary.
* | Merge pull request #26446 from kamipo/rename_type_var_name_to_typeEileen M. Uchitelle2016-09-171-10/+8
|\ \ | | | | | | Rename variable name that returning `type_for` to `type` from `column`
| * | Rename variable name that returning `type_for` to `type` from `column`Ryuta Kamizono2016-09-111-10/+8
| |/ | | | | | | | | | | `column_for` was changed to `type_for` to return `type` object at 36bd52b4. But variable name is still `column`. It is very confusing. Rename variable name `column` to `type` for readability.
* / Fix broken comments indentation caused by rubocop auto-correct [ci skip]Ryuta Kamizono2016-09-142-23/+23
|/ | | | | | All indentation was normalized by rubocop auto-correct at 80e66cc4d90bf8c15d1a5f6e3152e90147f00772. But comments was still kept absolute position. This commit aligns comments with method definitions for consistency.
* Fix Remaining Case-In-Assignment Statement FormattingAlex Kitchens2016-09-061-5/+6
| | | | | | | | | Recently, the Rails team made an effort to keep the source code consistent, using Ruboco (bb1ecdcc677bf6e68e0252505509c089619b5b90 and below). Some of the case statements were missed. This changes the case statements' formatting and is consistent with changes in 810dff7c9fa9b2a38eb1560ce0378d760529ee6b and db63406cb007ab3756d2a96d2e0b5d4e777f8231.
* Remove not used alias methodyui-knk2016-09-061-1/+0
| | | | | Bang methods of `AR::QueryMethods` are used only internally. We only use `left_outer_joins!`, so we can remove this alias.
* Fix broken heredoc indentation caused by rubocop auto-correctRyuta Kamizono2016-09-032-6/+6
| | | | | | All indentation was normalized by rubocop auto-correct at 80e66cc4d90bf8c15d1a5f6e3152e90147f00772. But heredocs was still kept absolute position. This commit aligns heredocs indentation for consistency.
* Revert "Extract `PredicateBuilder::CaseSensitiveHandler`"Sean Griffin2016-08-313-41/+10
| | | | | | | | | This reverts commit 3a1f6fe7b4a70bf0698b0684dd48ac712c6883b6. This commit takes the code in a direction that I am looking to avoid. The predicate builder should be purely concerned with AST construction as it matters to methods like `where`. Things like case sensitivity should continue to be handled elsewhere.
* Override `respond_to_missing?` instead of `respond_to?` when possibleSean Griffin2016-08-311-1/+1
| | | | | | | | | | This was almost every case where we are overriding `respond_to?` in a way that mirrors a parallel implementation of `method_missing`. There is one remaining case in Active Model that should probably do the same thing, but had a sufficiently strange implementation that I want to investigate it separately. Fixes #26333.
* Add `Type.default_value` and use it everywhere for internalRyuta Kamizono2016-08-262-3/+3
| | | | For reduce instantiating `Type::Value`.
* Merge pull request #26182 from bogdan/remove-relation-metaprogrammingRafael França2016-08-232-84/+53
|\ | | | | Remove over meta programming in AR::Relation
| * Remove over meta programming in AR::RelationBogdan Gusiev2016-08-232-84/+53
| | | | | | | | | | | | | | | | | | | | Introduced low level methods #set_value and #get_value for setting query attributes: relation.set_value(:where, {id: 1}) relation.get_value(:includes) Used those internally when working with relation's attributes at the abstract level
* | Remove unnecessary ordinal methods for collection associationRyuta Kamizono2016-08-181-2/+10
| | | | | | | | | | Currently `CollectionProxy` inherits `Relation` therefore we can use its own methods rather than delegating to collection association.
* | Merge pull request #25976 from kamipo/pluck_uses_loaded_targetRafael França2016-08-171-1/+1
|\ \ | | | | | | `pluck` should use `records` (`load_target`) when `loaded?` is true
| * | `pluck` should use `records` (`load_target`) when `loaded?` is trueRyuta Kamizono2016-08-041-1/+1
| | |
* | | Fix indentationRafael Mendonça França2016-08-171-3/+3
| | |
* | | Merge pull request #25987 from aquajach/masterRafael Mendonça França2016-08-171-1/+1
|\ \ \ | | | | | | | | | | | | Fix does_not_support_reverse? to find sql functions with commas in nested brackets
| * | | check if order contains comma first in does_not_support_reverse?Jack Chen Songyong2016-07-291-1/+1
| | | |
| * | | have does_not_support_reverse? support sql functions with commas in nested ↵Jack2016-07-291-1/+1
| |/ / | | | | | | | | | brackets
* | | Merge pull request #26021 from ↵Rafael França2016-08-171-16/+16
|\ \ \ | | | | | | | | | | | | | | | | kamipo/finder_bang_method_should_call_non_bang_method Finder bang method should call non bang method
| * | | Finder bang method should call non bang methodRyuta Kamizono2016-08-161-16/+16
| | |/ | |/| | | | | | | Otherwise CollectionProxy's bang methdos cannot respect dirty target.
* | | Merge pull request #26072 from kamipo/extract_case_sensitive_handlerRafael Mendonça França2016-08-173-10/+41
|\ \ \ | | | | | | | | | | | | Extract `PredicateBuilder::CaseSensitiveHandler`
| * | | Extract `PredicateBuilder::CaseSensitiveHandler`Ryuta Kamizono2016-08-163-10/+41
| |/ / | | | | | | | | | | | | | | | Currently uniqueness validator is coupled with building Arel ASTs. This commit extracts `PredicateBuilder::CaseSensitiveHandler` for decouple the building Arel ASTs.
* | | Merge pull request #26121 from MaxLap/fix_count_with_left_joinsRafael Mendonça França2016-08-161-6/+4
|\ \ \ | | | | | | | | | | | | Fix count which would sometimes force a DISTINCT
| * | | Fix count which would sometimes force a DISTINCTMaxime Lapointe2016-08-161-6/+4
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current behaviour of checking if there is a LEFT OUTER JOIN arel node to detect if we are doing eager_loading is wrong. This problem wasn't frequent before as only some pretty specific cases would add a LEFT OUTER JOIN arel node. However, the recent new feature left_outer_joins also add this node and made this problem happen frequently. Since in the perform_calculation function, we don't have access to eager_loading information, I had to extract the logic for the distinct out to the calculate method. As I was in the file for left_outer_join tests, I fixed a few that had bugs and I replaced some that were really weak with something that will catch more issues. In relation tests, the first test I changed would have failed if it had validated the hash returned by count instead of just checking how many pairs were in it. This is because this merge of join currently transforms the join node into an outer join node, which then made count do a distinct. So before this change, the return was {1=>1, 4=>1, 5=>1}.
* / / 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 #26117 from kamipo/make_association_quary_to_preparable_step1Rafael Mendonça França2016-08-161-11/+11
|\ \ | | | | | | | | | Make association queries to preparable: Step 1
| * | Make association queries to preparable: Step 1Ryuta Kamizono2016-08-111-11/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently association queries cannot be preparable. ```ruby Post.where(author_id: 1).to_a # => SELECT "posts".* FROM "posts" WHERE "posts"."author_id" = ? [["author_id", 1]] Post.where(author: 1).to_a # => SELECT "posts".* FROM "posts" WHERE "posts"."author_id" = 1 ``` To make association queries to preparable, it should be handled in `create_binds_for_hash`. This change is a first step for it.
* | | Merge pull request #26074 from kamipo/where_by_attribute_with_array_or_rangeRafael França2016-08-161-7/+11
|\ \ \ | | | | | | | | `where` by `array|range` attribute with array or range value
| * | | `where` by `array|range` attribute with array or range valueRyuta Kamizono2016-08-111-7/+11
| |/ / | | | | | | | | | | | | | | | | | | Currently predicate builder cannot build a predicate for `array|range` attribute. This commit fixes the issue. Related #25671.
* | | Merge pull request #26097 from Dagnan/fix_recordnotfound_args_rebasedRafael França2016-08-161-4/+6
|\ \ \ | | | | | | | | 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-4/+6
| |/ / | | | | | | | | | 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-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* | | Remove `find_nth_with_limit_and_offset` private methodRyuta Kamizono2016-08-151-34/+13
| | | | | | | | | | | | | | | | | | `find_nth` is protected method, therefore `offset` has not been passed anywhere. `find_nth_with_limit_and_offset` is unnecessary anymore because `offset` has not been passed.
* | | Merge pull request #26012 from grosser/grosser/missingSean Griffin2016-08-141-1/+1
|\ \ \ | |/ / |/| | add more array methods to straight delegation to speed up calling them
| * | add index to array methods so we can call it on relationsMichael Grosser2016-08-121-1/+1
| |/
* | code gardening: removes redundant selfsXavier Noria2016-08-081-1/+1
| | | | | | | | | | | | | | | | | | A few have been left for aesthetic reasons, but have made a pass and removed most of them. Note that if the method `foo` returns an array, `foo << 1` is a regular push, nothing to do with assignments, so no self required.
* | revises most Lint/EndAlignment offensesXavier Noria2016-08-071-7/+7
| | | | | | | | Some case expressions remain, need to think about those ones.
* | Merge pull request #26076 from yui-knk/privatize_expandKasper Timm Hansen2016-08-071-10/+10
|\ \ | | | | | | `ActiveRecord::PredicateBuilder#expand` to be private
| * | `ActiveRecord::PredicateBuilder#expand` to be privateyui-knk2016-08-071-10/+10
| | | | | | | | | | | | This method is not touched from outside.
* | | Add `Style/EmptyLines` in `.rubocop.yml` and remove extra empty linesRyuta Kamizono2016-08-071-1/+0
|/ /
* | Merge pull request #26073 from kamipo/revert_passing_splat_binds_for_arel_nodeSean Griffin2016-08-061-1/+0
|\ \ | | | | | | Revert passing arel node with splat binds for `where`
| * | Revert passing arel node with splat binds for `where`Ryuta Kamizono2016-08-061-1/+0
| |/ | | | | | | | | | | | | | | | | | | | | | | Passing arel node with splat binds for `where` was introduced at #22877 for uniqueness validator supports prepared statement. But I'd not like to introduce the following usage: ```ruby Foo.where(arel, *binds) ``` I'd like to revert this internal usage.
* | applies remaining conventions across the projectXavier Noria2016-08-062-4/+3
| |
* | normalizes indentation and whitespace across the projectXavier Noria2016-08-0614-789/+789
| |