aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation/spawn_methods.rb
Commit message (Collapse)AuthorAgeFilesLines
* No need to nodoc private methodsAkira Matsuda2016-12-241-1/+1
|
* applies remaining conventions across the projectXavier Noria2016-08-061-1/+0
|
* applies new string literal convention in activerecord/libXavier Noria2016-08-061-3/+3
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Mutating the result of Relation#to_a should not affect the relationMatthew Draper2016-02-211-1/+1
| | | | | | Clarifying this separation and enforcing relation immutability is the culmination of the previous efforts to remove the mutator method delegations.
* Raise ArgumentError when passing a truthy value to mergeAndrew White2015-11-171-1/+3
| | | | | | In b71e08f we started raising when nil or false was passed to merge to fix #12264, however we should also do this for truthy values that are invalid like true.
* Make `AR::SpawnMethods#merge!` to check an arg is a Procyui-knk2015-11-121-3/+5
| | | | | | | | | | From Ruby ( 2.3.0dev trunk 52520), `Hash#to_proc` is defined (https://github.com/ruby/ruby/commit/fbe967ec02cb65a7efa3fb8f3d747cf6f620dde1), and many tests have been failed with `ArgumentError: wrong number of arguments (given 0, expected 1)`. Because we call `Hash#to_proc` with no args in `#merge!`. This commit changes order of conditionals to not call `Hash#to_proc`.
* applies new doc guidelines to Active Record.Yves Senn2015-10-141-1/+1
| | | | | | | | | | | | | | | | | | | The focus of this change is to make the API more accessible. References to method and classes should be linked to make it easy to navigate around. This patch makes exzessiv use of `rdoc-ref:` to provide more readable docs. This makes it possible to document `ActiveRecord::Base#save` even though the method is within a separate module `ActiveRecord::Persistence`. The goal here is to bring the API closer to the actual code that you would write. This commit only deals with Active Record. The other gems will be updated accordingly but in different commits. The pass through Active Record is not completely finished yet. A follow up commit will change the spots I haven't yet had the time to update. /cc @fxn
* Raise ArgumentError when passing nil to Relation#mergeRafael Mendonça França2015-02-061-1/+1
| | | | | | nil or false should not be valid argument to the merge method. Closes #12264
* Remove references to `:bind` in `except`Sean Griffin2015-01-251-3/+0
| | | | Bind values are no longer a thing, so this is unnecessary.
* Inject the `PredicateBuilder` into the `Relation` instanceSean Griffin2014-12-261-1/+1
| | | | | | | Construction of relations can be a hotspot, we don't want to create one of these in the constructor. This also allows us to do more expensive things in the predicate builder's constructor, since it's created once per AR::Base subclass
* where needs to bring the bind params when creating a new relationAaron Patterson2014-01-141-0/+3
|
* add a specific factory method rather than using newAaron Patterson2013-07-231-1/+1
|
* Simplify/fix implementation of default scopesJon Leighton2013-06-281-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The previous implementation was necessary in order to support stuff like: class Post < ActiveRecord::Base default_scope where(published: true) scope :ordered, order("created_at") end If we didn't evaluate the default scope at the last possible moment before sending the SQL to the database, it would become impossible to do: Post.unscoped.ordered This is because the default scope would already be bound up in the "ordered" scope, and therefore wouldn't be removed by the "Post.unscoped" part. In 4.0, we have deprecated all "eager" forms of scopes. So now you must write: class Post < ActiveRecord::Base default_scope { where(published: true) } scope :ordered, -> { order("created_at") } end This prevents the default scope getting bound up inside the "ordered" scope, which means we can now have a simpler/better/more natural implementation of default scoping. A knock on effect is that some things that didn't work properly now do. For example it was previously impossible to use #except to remove a part of the default scope, since the default scope was evaluated after the call to #except.
* refatctoring of some code repetition in spawn_methodsAngelo capilleri2012-12-311-8/+10
|
* remove unneeded Examples tag [ci skip]Carlos Duclos2012-12-011-10/+0
|
* Mark Relation mutators as :nodoc:Jon Leighton2012-11-301-2/+1
| | | | | These are for internal use only and cannot be relied on as part of the public API. See discussion on 8c2c60511beaad05a218e73c4918ab89fb1804f0.
* 1.9 Syntax related changesAvnerCohen2012-11-101-2/+2
|
* Allow Relation#merge to take a proc.Jon Leighton2012-08-031-2/+13
| | | | | | | | | | | | | | | | | | This was requested by DHH to allow creating of one's own custom association macros. For example: module Commentable def has_many_comments(extra) has_many :comments, -> { where(:foo).merge(extra) } end end class Post < ActiveRecord::Base extend Commentable has_many_comments -> { where(:bar) } end
* load active_support/core_ext/object/blank in active_support/railsXavier Noria2012-08-021-1/+0
|
* Add nodocs to delegation module and docs for merge!Oscar Del Ben2012-07-171-0/+1
|
* CollectionProxy < RelationJon Leighton2012-05-111-4/+9
| | | | | | | | | | | | | | | | | | | | | This helps bring the interfaces of CollectionProxy and Relation closer together, and reduces the delegation backflips we need to perform. For example, first_or_create is defined thus: class ActiveRecord::Relation def first_or_create(...) first || create(...) end end If CollectionProxy < Relation, then post.comments.first_or_create will hit the association's #create method which will actually add the new record to the association, just as post.comments.create would. With the previous delegation, post.comments.first_or_create expands to post.comments.scoped.first_or_create, where post.comments.scoped has no knowledge of the association.
* SpawnMethods#merge returns the intersection when passed an array, and not ↵Mitch Crowe2012-05-051-2/+2
| | | | the union. Update the documentation to reflect this.
* fix interpolation for hash mergingJon Leighton2012-04-251-5/+2
|
* Add documentation to the SpawnMethods#merge method.Mitch Crowe2012-04-171-0/+14
|
* now we can just manipulate the values hash in #only and #exceptJon Leighton2012-04-131-22/+4
|
* Make Relation#extending work like other value methodsJon Leighton2012-04-131-4/+2
|
* Add Relation#merge!Jon Leighton2012-04-131-9/+12
|
* Allow Relation#merge to take a hashJon Leighton2012-04-131-2/+5
|
* we have no need for the ASSOCIATION_METHODS constantJon Leighton2012-04-131-2/+2
|
* Extract clusterfuck method for surgeryJon Leighton2012-04-131-71/+8
|
* move apply_finder_options to active_record_deprecated_findersJon Leighton2012-04-121-22/+0
|
* use bind values for join columnsAaron Patterson2012-02-271-1/+4
|
* use regular ruby for fewer method calls. we do not need :gift:s!Aaron Patterson2012-02-241-1/+4
|
* Deprecate inferred JOINs with includes + SQL snippets.Jon Leighton2012-01-161-2/+2
| | | | | | See the CHANGELOG for details. Fixes #950.
* Revert "Deprecate implicit eager loading. Closes #950."Jon Leighton2012-01-161-2/+2
| | | | This reverts commit c99d507fccca2e9e4d12e49b4387e007c5481ae9.
* correctly handle order calls after a reorderMatt Jones + Scott Walker2012-01-031-2/+11
|
* Deprecate implicit eager loading. Closes #950.Jon Leighton2011-12-291-2/+2
|
* default create_with_value to a hash so we can eliminate conditionals, add ↵Aaron Patterson2011-06-271-1/+1
| | | | test surrounding create_with(nil) behavior
* Evaluate default scopes at the last possible moment in order to avoid ↵Jon Leighton2011-04-121-0/+4
| | | | problems with default scopes getting included into other scopes and then being unable to remove the default part via unscoped.
* Reapply extensions when using except and onlyIain Hecker2011-03-211-0/+6
|
* Remove Relation#& alias for Relation#mergeErnie Miller2011-02-121-2/+0
|
* Merge branch 'master' of git://github.com/lifo/docrailsXavier Noria2011-01-201-0/+14
|\
| * document ActiveRecord's except and onlyJordi Romero2011-01-151-0/+14
| | | | | | | | Document methods that allow easily override arel queries
* | Make Relation#create_with always merge rather than overwrite, not just when ↵Jon Leighton2011-01-031-3/+1
| | | | | | | | merging two relations. If you wish to overwrite, you can do relation.create_with(nil), or for a specific attribute, relation.create_with(:attr => nil).
* | Let AssociationCollection#find use #scoped to do its finding. Note that I am ↵Jon Leighton2011-01-031-1/+1
| | | | | | | | removing test_polymorphic_has_many_going_through_join_model_with_disabled_include, since this specifies different behaviour for an association than for a regular scope. It seems reasonable to expect scopes and association proxies to behave in roughly the same way rather than having subtle differences.
* | Specify the STI type condition using SQL IN rather than a whole load of ORs. ↵Jon Leighton2010-12-311-1/+5
|/ | | | Required a fix to ActiveRecord::Relation#merge for properly merging create_with_value. This also fixes a situation where the type condition was appearing twice in the resultant SQL query.
* making relationship merge cheaperAaron Patterson2010-11-301-3/+4
|
* only returning where values for the corresponding relation, also filtering ↵Aaron Patterson2010-10-301-4/+5
| | | | where value hash based on table name [#5234 state:resolved] [#5184 state:resolved]
* no need to merge where values if no new where values have been addedAaron Patterson2010-10-301-11/+13
|
* reduce duplicate where removal to one loopAaron Patterson2010-10-201-15/+13
|