aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation
Commit message (Collapse)AuthorAgeFilesLines
* 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
| |
* | modernizes hash syntax in activerecordXavier Noria2016-08-061-2/+2
| |
* | applies new string literal convention in activerecord/libXavier Noria2016-08-0610-48/+48
|/ | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Merge pull request #25941 from kamipo/finder_methods_uses_load_targetRafael França2016-07-281-4/+4
|\ | | | | `FinderMethods` uses `records` (`load_target`) when `loaded?` is true
| * `FinderMethods` uses `records` (`load_target`) when `loaded?` is trueRyuta Kamizono2016-07-281-4/+4
| |
* | adds missing requiresXavier Noria2016-07-242-0/+2
|/
* systematic revision of =~ usage in ARXavier Noria2016-07-232-5/+5
| | | | | Where appropriatei, prefer the more concise Regexp#match?, String#include?, String#start_with?, or String#end_with?
* small reword [ci skip]Xavier Noria2016-07-141-3/+3
|
* removes a unnecessary limit callXavier Noria2016-07-131-1/+0
| | | | | We are setting a limit unconditionally just below, which overrides any existing one anyway.
* adds support for limits in batch processingXavier Noria2016-07-131-41/+71
|
* Always prefer class types to query types when casting `group`Sean Griffin2016-07-111-4/+6
| | | | | | | | | | | | | When `group` is used in combination with any calculation method, the resulting hash uses the grouping expression as the key. Currently we're incorrectly always favoring the type reported by the query, instead of the type known by the class. This causes differing behavior depending on whether the adaptor actually gives proper types with the query or not. After this change, the behavior will be the same on all adaptors -- we see if we know the type from the class, fall back to the type from the query, and finally fall back to the identity type. Fixes #25595
* Remove unused `predicate_builder` for `BasicObjectHandler` and `RangeHandler`Ryuta Kamizono2016-07-023-19/+3
|
* Merge pull request #25271 from kamipo/prevent_range_error_for_existsSean Griffin2016-06-151-1/+3
|\ | | | | Prevent `RangeError` for `FinderMethods#exists?`
| * Prevent `RangeError` for `FinderMethods#exists?`Ryuta Kamizono2016-06-161-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | `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`.
* | Fix `calculate` with a string value in `from` and eager loadingRyuta Kamizono2016-06-131-9/+1
| | | | | | | | | | | | | | | | | | | | `construct_relation_for_association_calculations` pass a string value to `construct_join_dependency` when setting a string value in `from`. It should not pass a string value, but always `joins_values`. Related #14834, #19452. Fixes #24193.
* | Fix `or` result SQL [ci skip]Ryuta Kamizono2016-06-111-1/+1
|/
* Merge pull request #25179 from kamipo/reuse_result_of_associated_tableSean Griffin2016-05-301-2/+3
|\ | | | | Reuse a result of `table.associated_table(column)` in `AssociationQueryHandler.value_for`
| * Reuse a result of `table.associated_table(column)` in ↵Ryuta Kamizono2016-05-281-2/+3
| | | | | | | | `AssociationQueryHandler.value_for`
* | Exists shouldn't error when used with `includes`Sean Griffin2016-05-301-3/+3
|/ | | | | | | | | | | | | | | | Currently `exists?` does some hackery where it assumes that we can join onto anything that we passed to `eager_load` or `includes`, which doesn't work if we are joining onto a polymorphic association. Actually figuring out if we want to include something would require knowledge deep within the join dependency module, which is hard to pull up. The simplest solution is just to pass a flag down that says we're not actually going to try to eager load any of the data. It's not the solution I'd like, but that code really needs to be untangled before we can do much with it. This is another attempt at 6d5b1fd which should address the concerns that led to reverting it in 4ecabed.
* Remove unused `association_for_table` private methodRyuta Kamizono2016-05-271-6/+0
| | | | `association_for_table` is unused since 50a8cdf.
* Support for unified Integer class in Ruby 2.4+Jeremy Daer2016-05-181-1/+1
| | | | | | | | Ruby 2.4 unifies Fixnum and Bignum into Integer: https://bugs.ruby-lang.org/issues/12005 * Forward compat with new unified Integer class in Ruby 2.4+. * Backward compat with separate Fixnum/Bignum in Ruby 2.2 & 2.3. * Drops needless Fixnum distinction in docs, preferring Integer.
* Merge pull request #24203 from sferik/count_with_blockKasper Timm Hansen2016-05-161-1/+5
|\ | | | | Forward ActiveRecord::Relation#count to Enumerable#count if block given
| * Forward ActiveRecord::Relation#count to Enumerable#count if block givenErik Michaels-Ober2016-03-191-1/+5
| |
* | Allow the connection adapters to determine the order of bind paramsSean Griffin2016-05-061-4/+10
| | | | | | | | | | | | | | | | | | | | | | | | In 5.0 we use bind parameters for limit and offset, while in 4.2 we used the values directly. The code as it was written assumed that limit and offset worked as `LIMIT ? OFFSET ?`. Both Oracle and SQL Server have a different syntax, where the offset is stated before the limit. We delegate this behavior to the connection adapter so that these adapters are able to determine how the bind parameters are flattened based on what order their specification has the various clauses appear. Fixes #24775
* | Merge pull request #24868 from vipulnsward/delegate_encode_withRafael França2016-05-051-1/+1
|\ \ | | | | | | delegate encode_with instead of to_yaml, which is deprecated
| * | delegate encode_with instead of to_yaml, which is deprecatedVipul A M2016-05-051-1/+1
| | |
* | | do not pass conditions to `#destroy_all` [ci skip]yuuji.yaginuma2016-05-051-1/+1
|/ / | | | | | | Passing conditions to `#destroy_all` was deprecated in c82c5f8.
* | Merge pull request #24317 from Gaurav2728/unused_set_in_active_recordJeremy Daer2016-04-191-1/+0
|\ \ | | | | | | | | | connection adapters column, delegation in Active Record have not use …
| * | connection adapters column, delegation in Active Record have not use of ↵Gaurav Sharma2016-03-311-1/+0
| |/ | | | | | | | | ‘set’ found these commits https://github.com/rails/rails/commit/9cc8c6f3730df3d94c81a55be9ee1b7b4ffd29f6, https://github.com/rails/rails/commit/9d79334a1dee67e31222c790e231772deafcaeb8 that also should remove it.
* | Don't create new arrays when trying to compute non_empty_predicates for ↵Vipul A M2016-04-181-1/+2
| | | | | | | | | | | | where clause predicate. Get a 3-4% improvement in AST generation. Perf compare: https://gist.github.com/vipulnsward/7e4e9ecb157e574002313249a7969c82
* | Allow symbols using "dot notation" to be passed to whereSean Griffin2016-04-122-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | Pass over all Rails 5 warnings, to make sure:Vipul A M2016-04-122-3/+3
| | | | | | | | | | | | | | | | | | | | - we are ending sentences properly - fixing of space issues - fixed continuity issues in some sentences. Reverts https://github.com/rails/rails/commit/8fc97d198ef31c1d7a4b9b849b96fc08a667fb02 . This change reverts making sure we add '.' at end of deprecation sentences. This is to keep sentences within Rails itself consistent and with a '.' at the end.