aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models/person.rb
Commit message (Collapse)AuthorAgeFilesLines
* Prevent Relation#merge from collapsing wheres on the RHSJon Leighton2013-01-271-0/+1
| | | | | | | | | | | | | | | | | | | | | | | This caused a bug with the new associations implementation, because now association conditions are represented as Arel nodes internally right up to when the whole thing gets turned to SQL. In Rails 3.2, association conditions get turned to raw SQL early on, which prevents Relation#merge from interfering. The current implementation was buggy when a default_scope existed on the target model, since we would basically end up doing: default_scope.merge(association_scope) If default_scope contained a where(foo: 'a') and association_scope contained a where(foo: 'b').where(foo: 'c') then the merger would see that the same column is representated on both sides of the merge and collapse the wheres to all but the last: where(foo: 'c') Now, the RHS of the merge is left alone. Fixes #8990
* Revert "Unused methods, module, etc."Akira Matsuda2013-01-241-0/+8
| | | | | | This reverts commit 4e05bfb8e254c3360a3ca4a6cb332995314338fe. Reason: BlankTopic#blank? should not be removed to check that dynamic finder with a bang can find a model that responds to `blank?`
* Unused methods, module, etc.Akira Matsuda2013-01-241-8/+0
|
* Fix broken test for postgresqlRafael Mendonça França2012-12-211-1/+1
| | | | | | For some reason postgresql doesn't pass an integer value to load. cc @tenderlove
* Serialized attribute can be serialized in an integer columnRafael Mendonça França2012-12-211-0/+21
| | | | Fix #8575
* Remove mass assignment security from ActiveRecordGuillermo Iguaran2012-09-161-12/+0
|
* reset_counters() was crashing when there were multiple belongs_to ↵Dave Desrochers2012-08-211-0/+2
| | | | | | associations with the same foreign key. This closes #5200.
* Convert association macros to the new syntaxJon Leighton2012-07-201-6/+6
|
* Ensure that mass assignment options are preservedAndrew White2012-06-101-1/+20
| | | | | | | | | | | | | | | | There are two possible scenarios where the @mass_assignment_options instance variable can become corrupted: 1. If the assign_attributes doesn't complete correctly, then subsequent calls to a nested attribute assignment method will use whatever options were passed to the previous assign_attributes call. 2. With nested assign_attributes calls, the inner call will overwrite the current options. This will only affect nested attributes as the attribute hash is sanitized before any methods are called. To fix this we save the current options in a local variable and then restore these options in an ensure block.
* Merge pull request #5334 from courtland/masterJon Leighton2012-03-301-0/+6
|\ | | | | Fix deleting from a HABTM join table upon destroying an object of a model with optimistic locking enabled.
| * Tests for removing a HABTM association when optimistic locking is enabled.Nick Rogers2012-03-071-0/+6
| |
* | Deprecate eager-evaluated scopes.Jon Leighton2012-03-211-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Don't use this: scope :red, where(color: 'red') default_scope where(color: 'red') Use this: scope :red, -> { where(color: 'red') } default_scope { where(color: 'red') } The former has numerous issues. It is a common newbie gotcha to do the following: scope :recent, where(published_at: Time.now - 2.weeks) Or a more subtle variant: scope :recent, -> { where(published_at: Time.now - 2.weeks) } scope :recent_red, recent.where(color: 'red') Eager scopes are also very complex to implement within Active Record, and there are still bugs. For example, the following does not do what you expect: scope :remove_conditions, except(:where) where(...).remove_conditions # => still has conditions
* | Add test case to has_many through association when mass_assignment_sanitizer isRafael Mendonça França2012-03-051-0/+2
|/ | | | :strict
* Deprecate inferred JOINs with includes + SQL snippets.Jon Leighton2012-01-161-1/+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.
* Deprecate implicit eager loading. Closes #950.Jon Leighton2011-12-291-2/+2
|
* added failing tests for has_many, has_one and belongs_to associations with ↵Jakub Kuźma2011-12-211-2/+2
| | | | strict mass assignment sanitizer, fixed build_record to not merge creation_attributes, removed failing nested attributes tests (that feature was broken anyway) #4051
* Pass mass-assignment options to nested models - closes #1673.Andrew White2011-06-131-2/+6
|
* singular and collection relations in AR can now specify mass-assignment ↵Josh Kalderimis2011-05-011-6/+17
| | | | security options (:as and :without_protection) in build, create and create! methods.
* Added assign_attributes to Active Record which accepts a mass-assignment ↵Josh Kalderimis2011-04-241-0/+19
| | | | security scope using the :as option, while also allowing mass-assignment security to be bypassed using :with_protected
* Merge branch 'master' into nested_has_many_throughJon Leighton2011-03-041-1/+29
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * Allow building and then later saving has_many :through records, such that ↵Jon Leighton2011-02-181-0/+2
| | | | | | | | the join record is automatically saved too. This requires the :inverse_of option to be set on the source association in the join model. See the CHANGELOG for details. [#4329 state:resolved]
| * Support the :dependent option on has_many :through associations. For ↵Jon Leighton2011-02-071-1/+26
| | | | | | | | historical and practical reasons, :delete_all is the default deletion strategy employed by association.delete(*records), despite the fact that the default strategy is :nullify for regular has_many. Also, this only works at all if the source reflection is a belongs_to. For other situations, you should directly modify the through association.
| * Fix hm:t to self table aliasing in construct_scopeErnie Miller2010-12-161-0/+1
| |
* | Fix naughty trailing whitespaceJon Leighton2010-10-311-1/+1
| |
* | Add support for nested through associations in JoinAssociation. Hence ↵Jon Leighton2010-10-091-0/+3
|/ | | | Foo.joins(:bar) will work for through associations. There is some duplicated code now, which will be refactored.
* Ensure default_scope can be overwriten by association conditions.José Valim2010-07-211-0/+1
|
* eagerly loaded association records should respect default_scope [#2931 ↵Subba Rao Pasupuleti2010-07-211-0/+1
| | | | | | state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>
* Rename named_scope to scopePratik Naik2010-01-181-2/+2
|
* Fixed limited eager loading associations with numbers in the name [#2668 ↵Benjamin Floering2009-05-181-0/+1
| | | | | | state:resolved] Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
* Preload uses exclusive scope [#643 state:resolved]Frederick Cheung2008-12-261-0/+6
| | | | | | | | | With self referential associations, the scope for the the top level should not affect fetching of associations, for example when doing Person.male.find :all, :include => :friends we should load all of the friends for each male, not just the male friends.
* fix eager loading with dynamic findersBrandon Keepers2008-06-091-1/+1
|
* Ensure table names are quoted by the association preloading code.Frederick Cheung2008-04-261-0/+5
| | | | | | [#45 state:resolved] Signed-off-by: Michael Koziarski <michael@koziarski.com>
* Make dynamic finders respect the :include on HasManyThrough associations. ↵Michael Koziarski2008-02-181-0/+1
| | | | | | Closes #10998. [cpytel] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8890 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* move assets and modelsJeremy Kemper2008-01-181-0/+4
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8657 5ecf4fe2-1ee6-0310-87b1-e25e094e27de