Pratik Naik
2d6d8a72a3
Ensure association preloading properly merges default scope and association conditions
2012-08-28 12:50:06 -07:00
Carlos Antonio da Silva
51bb1c1d7a
Add order to tests that rely on db ordering, to fix failing tests on pg
...
Also skip persistente tests related to UPDATE + ORDER BY for postgresql
PostgreSQL does not support updates with order by, and these tests are
failing randomly depending on the fixture loading order now.
2012-03-23 14:39:37 -03:00
Sergey Nartimov
9f7fe5d38b
backport call scope within unscoped to prevent duplication of where values
2011-12-18 20:42:17 +03:00
Jon Leighton
63293d1bc8
Fix #3890 . (Calling proxy_association in scope chain.)
...
Conflicts:
activerecord/test/models/post.rb
2011-12-08 20:13:26 +00:00
Jon Leighton
a48e332f7b
Ensure we are not comparing a string with a symbol in HasManyAssociation#inverse_updates_counter_cache?. Fixes #2755 , where a counter cache could be decremented twice as far as it was supposed to be.
2011-09-06 16:06:43 +01:00
Arun Agrawal
e8761b34b0
We need to recorder here. Need to drop the order from default scope.
...
Fixes #2832
2011-09-04 23:45:50 +05:30
Jon Leighton
7abf441336
The join_nodes must be passed to the JoinDependency initializer and therefore counted by the alias tracker. This is because the association_joins are aliased on initialization and then the tables are cached, so it is no use to alias the join_nodes later. Fixes #2556 .
2011-08-29 15:08:13 +01:00
Jon Leighton
af96a91793
Fix default scope thread safety. Thanks @thedarkone for reporting.
2011-08-13 16:57:09 +01:00
Santiago Pastorino
434bbb0efc
Revert "Merge pull request #2194 from cldwalker/after_initialize"
...
This reverts commit 198300727d , reversing
changes made to ae65c0b7a4 .
2011-07-23 20:49:42 -03:00
Gabriel Horner
06c6252b10
simplify and be more explicit about create and after_initialize tests
2011-07-22 20:14:49 -04:00
Les Fletcher
3dc5f71c17
fix after_initialize edge case ( close #2074 and close #2175 )
...
fix behavior when after_initialize is defined and a block is passed to Base.create
2011-07-22 20:14:48 -04:00
Jon Leighton
5c591e5c96
Fix exception if old and new targets are both nil. Fixes #1471 .
...
Conflicts:
activerecord/test/models/comment.rb
2011-07-12 00:16:44 +01:00
Jon Leighton
65813a6317
Assign the association attributes to the associated record before the before_initialize callback of the record runs. Fixes #1842 .
2011-06-30 23:39:43 +01:00
Jon Leighton
03580e0fa3
Apply the default scope earlier when doing calculations. Fixes #1682 .
2011-06-23 19:58:15 +01:00
Andrew White
45509ee6b7
Pass mass-assignment options to nested models - closes #1673 .
2011-06-13 13:07:44 +01:00
Jon Leighton
bdd549a1c0
Refactor tests to be less brittle
2011-06-12 18:31:26 +01:00
Erik Fonselius
c22364b60d
Failing test for aggregating on default_scope with select
2011-05-31 21:12:40 +01:00
Farley Knight
842043e352
Tests for issue #1360
2011-05-31 20:32:47 +01:00
Jon Leighton
b519b0cac9
Fix infinite recursion where a lazy default scope references a scope. Fixes #1264 .
2011-05-25 00:18:08 +01:00
Andrew White
8a4263c957
Ignore :includes on through associations
2011-05-25 00:17:53 +01:00
Andrew White
0daf574648
Failing tests for #1233 .
2011-05-25 00:17:00 +01:00
Guillermo Iguaran
23e94a67f8
Refactoring test_has_many_with_pluralize_table_names_false test
2011-05-20 01:53:13 -05:00
Andrew White
42f1ad6865
Pass the attribute and option hashes to build_association
...
The build_association method was added as an API for plugins
to hook into in 1398db0 . This commit restores this API and the
ability to override class.new to return a subclass based on
a virtual attribute in the attributes hash.
2011-05-17 20:43:30 +01:00
Jon Leighton
2033ff825b
Merge pull request #560 from guilleiguaran/fix_pluralize_table_names_false
...
Fixing has_many when ActiveRecord::Base.pluralize_table_names is false
2011-05-16 15:40:12 -07:00
Guillermo Iguaran
ecbde46e57
Fixing has_many association when ActiveRecord::Base.pluralize_table_names is false. fixes #557
2011-05-15 03:53:10 -05:00
Jon Leighton
60b23ea1da
CollectionAssociation#merge_target_lists should write to the underlying attributes when copying, rather than using the assignment method
2011-05-14 19:49:22 +01:00
Jon Leighton
6e466f17c3
Don't use mass-assignment protection when setting foreign keys or association conditions on singular associations. Fixes #481 (again).
2011-05-12 23:29:22 +01:00
Jon Leighton
1dd90f8f12
Don't use select() values from the join model of a through association. Fixes #508 .
2011-05-11 08:56:01 +01:00
Jon Leighton
a8c1fa4afd
Add test to specify that attributes from an association's conditions should be assigned without mass-assignment protection when a record is built on the association.
2011-05-10 23:35:15 +01:00
Christopher Meiklejohn
4fbd8adf48
Don't quote ID's as Arel will quote them -- follow same conventions as the delete method.
2011-05-08 18:37:28 +01:00
David Heinemeier Hansson
a8861c8f5b
Merge pull request #357 from joshk/assign_attributes.
...
Assign protected attributes with create/new and control the role.
2011-05-01 16:59:33 -07:00
Josh Kalderimis
86d7ed3375
singular and collection relations in AR can now specify mass-assignment security options (:as and :without_protection) in build, create and create! methods.
2011-05-01 23:30:07 +02:00
Josh Kalderimis
5164c50d7f
removed the default_scope deprecations and updated the docs and tests to reflect its use cases
2011-04-28 18:46:40 +02:00
Josh Kalderimis
a08d04bedf
Added assign_attributes to Active Record which accepts a mass-assignment security scope using the :as option, while also allowing mass-assignment security to be bypassed using :with_protected
2011-04-24 09:53:18 +02:00
Jon Leighton
019cd51a3f
Bring back support for passing a callable object to the default_scope macro. You can also just use a block.
2011-04-18 23:35:22 +01:00
Jon Leighton
6f84c73dc4
Un-deprecate using 'default_scope' as a macro, but if you are calling the macro multiple times that will give deprecation warnings, and in 3.2 we will simply overwrite the default scope when you call the macro multiple times.
2011-04-18 23:15:38 +01:00
Jon Leighton
256b363eee
Revert "Deprecate defining scopes with a callable (lambda, proc, etc) via the scope class method. Just define a class method yourself instead."
...
This reverts commit f0e198bfa1 .
Conflicts:
activerecord/test/models/post.rb
2011-04-17 20:47:52 +01:00
Aaron Patterson
1b5b53da5e
common @jonleighton 💣
2011-04-12 20:29:35 -07:00
Jon Leighton
f0e198bfa1
Deprecate defining scopes with a callable (lambda, proc, etc) via the scope class method. Just define a class method yourself instead.
2011-04-12 19:46:05 -07:00
Jon Leighton
8572ae6671
Evaluate default scopes at the last possible moment in order to avoid problems with default scopes getting included into other scopes and then being unable to remove the default part via unscoped.
2011-04-12 19:46:04 -07:00
Jon Leighton
5740d4ec0c
Deprecated support for passing hashes and relations to default_scope, in favour of defining a 'default_scope' class method in the model. See the CHANGELOG for more details.
2011-04-12 19:46:04 -07:00
Jon Leighton
9abc94c445
oracle, y u defy me
2011-03-16 18:54:34 +00:00
Jon Leighton
ddf83d14f1
Add a test for STI on the through where the through is nested, and change the code which support this
2011-03-05 20:10:24 +00:00
Jon Leighton
735844db71
Merge branch 'master' into nested_has_many_through
...
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
2011-03-04 09:30:27 +00:00
Jon Leighton
d90b4e2615
Rewrote AssociationPreload.
2011-02-28 22:12:34 +00:00
Jon Leighton
91fd651056
Allow building and then later saving has_many :through records, such that 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]
2011-02-18 00:00:13 +00:00
Jon Leighton
f0b9805029
Ensure that association_ids uses the correct attribute where the association is a has_many :through with a :primary_key option on the source reflection. [ #6376 state:resolved]
2011-02-18 00:00:13 +00:00
Jon Leighton
a7e19b30ca
Add interpolation of association conditions back in, in the form of proc { ... } rather than instance_eval-ing strings
2011-02-14 01:40:31 +00:00
Jan
9643243204
make set_table_name take effect immediately
2011-02-08 10:31:09 -08:00
Jon Leighton
52f09eac5b
Correctly update counter caches on deletion for has_many :through [ #2824 state:resolved]. Also fixed a bunch of other counter cache bugs in the process, as once I fixed this one others started appearing like nobody's business.
2011-02-07 23:35:05 +00:00