aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations/has_many_associations_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Don't preserve SELECT columns on COUNTSteve Klabnik2012-09-161-1/+31
| | | | | | | | | | | | | | | | | | The COUNT clause of a finder_sql relationship is being rewritten from COUNT(*) to COUNT(table_name.*). This does not appear to be valid syntax in MySQL: ``` mysql> SELECT COUNT( table_name.* ) FROM `table_name`; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '* ) FROM `table_name`' at line 1 ``` This fixes the bug, as well as adding tests so we don't re-introduce it in the future. Fixes #3956.
* Remove the dependent_restrict_raises option.Jon Leighton2012-08-101-24/+17
| | | | | | | | | | | | | | | It's not really a good idea to have this as a global config option. We should allow people to specify the behaviour per association. There will now be two new values: * :dependent => :restrict_with_exception implements the current behaviour of :restrict. :restrict itself is deprecated in favour of :restrict_with_exception. * :dependent => :restrict_with_error implements the new behaviour - it adds an error to the owner if there are dependent records present See #4727 for the original discussion of this.
* Remove ActiveRecord::Base.to_aJon Leighton2012-08-031-1/+1
| | | | | On reflection, it seems like a bit of a weird method to have on ActiveRecord::Base, and it shouldn't be needed most of the time anyway.
* Deprecate :finder_sql, :counter_sql, :insert_sql, :delete_sql.Jon Leighton2012-08-011-12/+28
|
* Revert "Remove :finder_sql, :counter_sql, :insert_sql, :delete_sql."Jon Leighton2012-08-011-0/+102
| | | | | | | | | This reverts commit 3803fcce26b837c0117f7d278b83c366dc4ed370. Conflicts: activerecord/CHANGELOG.md It will be deprecated only in 4.0, and removed properly in 4.1.
* AR::Relation#order: make new order prepend old oneBogdan Gusiev2012-07-311-2/+2
| | | | | | | User.order("name asc").order("created_at desc") # SELECT * FROM users ORDER BY created_at desc, name asc This also affects order defined in `default_scope` or any kind of associations.
* Deprecate ActiveRecord::Base.scoped.Jon Leighton2012-07-271-40/+40
| | | | | | | It doesn't serve much purpose now that ActiveRecord::Base.all returns a Relation. The code is moved to active_record_deprecated_finders.
* ActiveRecord::Base.all returns a Relation.Jon Leighton2012-07-271-14/+14
| | | | | | | | | | | Previously it returned an Array. If you want an array, call e.g. `Post.to_a` rather than `Post.all`. This is more explicit. In most cases this should not break existing code, since Relations use method_missing to delegate unknown methods to #to_a anyway.
* Deprecate update_column in favor of update_columns.Rafael Mendonça França2012-07-241-3/+3
| | | | Closes #1190
* rm redundant testJon Leighton2012-07-201-7/+0
| | | | now everything is converted to the new style, this is not needed
* Remove :finder_sql, :counter_sql, :insert_sql, :delete_sql.Jon Leighton2012-07-201-102/+0
|
* Fix class_eval without __FILE__ and __LINE__.kennyj2012-07-181-2/+2
|
* Allow associations to take a lambda which builds the scopeJon Leighton2012-07-131-0/+7
|
* Remove ActiveRelation#inspectBrian Cardarella2012-06-291-1/+1
|
* No need to cache table metadata in advance now that #6683 was merged.Rafael Mendonça França2012-06-111-5/+0
|
* Merge pull request #6492 from pmahoney/fair-connection-pool2Rafael Mendonça França2012-06-111-0/+3
|\ | | | | | | | | | | | | Fair connection pool2 Conflicts: activerecord/test/cases/associations/eager_test.rb
| * Make connection pool fair with respect to waiting threads.Patrick Mahoney2012-05-251-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The core of this fix is a threadsafe, fair Queue class. It is very similar to Queue in stdlib except that it supports waiting with a timeout. The issue this solves is that if several threads are contending for database connections, an unfair queue makes is possible that a thread will timeout even while other threads successfully acquire and release connections. A fair queue means the thread that has been waiting the longest will get the next available connection. This includes a few test fixes to avoid test ordering issues that cropped up during development of this patch.
* | Add support for CollectionAssociation#delete by Fixnum or StringFrancesco Rodriguez2012-05-281-3/+17
|/ | | | | | | | | | | | | | | | | | | | | | | | I found the next issue between CollectionAssociation `delete` and `destroy`. class Person < ActiveRecord::Base has_many :pets end person.pets.destroy(1) # => OK, returns the destroyed object person.pets.destroy("2") # => OK, returns the destroyed object person.pets.delete(1) # => ActiveRecord::AssociationTypeMismatch person.pets.delete("2") # => ActiveRecord::AssociationTypeMismatch Adding support for deleting with a fixnum or string like `destroy` method.
* Ensure that CollectionAssociation#replace returns proper targetPiotr Sarnacki2012-05-191-2/+2
| | | | | | | | The fix commited in e2a070c was returning the `new_target`, as a try to return whatever user replaced association with. The problem is, the resulting association target may be ordered differently. In such case we want to return the target that will be later used for that association.
* Perf: Don't load the association for #delete_all.Jon Leighton2012-05-181-0/+12
| | | | Bug #6289
* quarantine deprecated testsJon Leighton2012-05-181-121/+8
|
* Fix CollectionAssociation#replace to return new target (closes #6231)Piotr Sarnacki2012-05-161-0/+12
|
* Remove #=== quirkJon Leighton2012-05-111-6/+0
| | | | Makes it consistent with Relation. Can't see a use for this.
* CollectionProxy < RelationJon Leighton2012-05-111-4/+17
| | | | | | | | | | | | | | | | | | | | | 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.
* Fix issue with private kernel methods and collection associations. Closes #2508Carlos Antonio da Silva2012-05-021-0/+5
| | | | | | | | Change CollectionProxy#method_missing to use scoped.public_send, to avoid a problem described in issue #2508 when trying to use class methods with names like "open", that clash with private kernel methods. Also changed the dynamic matcher instantiator to send straight to scoped, to avoid another roundtrip to method_missing.
* remove deprecated callsJon Leighton2012-04-271-2/+2
|
* find and replace deprecated keysJon Leighton2012-04-271-24/+24
|
* %s/find(:\(first\|last\|all\), \([^()]*\))/scoped(\2).\1/gcI amongst other ↵Jon Leighton2012-04-271-57/+57
| | | | things
* don't need this testJon Leighton2012-04-261-5/+0
|
* remove calls to find(:first), find(:last) and find(:all)Jon Leighton2012-04-261-11/+6
|
* remove deprecated #first callsJon Leighton2012-04-261-12/+1
|
* remove deprecate #calculate callsJon Leighton2012-04-261-9/+1
|
* remove deprecated #find_in_batches callsJon Leighton2012-04-261-1/+1
|
* In AR depths use &:to_i before :uniq to process mixed arrays likes ["1", 1] ↵Alexey Vakhov2012-03-091-0/+7
| | | | correct
* Fix #5069 - Protect foreign key from mass assignment throught association ↵Jean Boussier2012-03-051-0/+22
| | | | builder
* Merge pull request #4543 from jdelStrother/find_or_initJon Leighton2012-02-011-0/+12
|\ | | | | Don't instantiate two objects in collection proxy / find_or_instantiate_by
| * Don't instantiate two objects in collection proxy / find_or_instantiator_byJonathan del Strother2012-01-191-0/+12
| |
* | fix has_one, has_many restrict error messageManoj2012-02-011-1/+1
| |
* | Merge pull request #4791 from gregolsen/reflection_test_fixedJosé Valim2012-01-311-1/+1
|\ \ | | | | | | reflection test fixed
| * | test_get_ids_for_ordered_association fixedgregolsen2012-01-311-1/+1
| | |
* | | Remove deprecation warnings from testsRafael Mendonça França2012-01-311-7/+13
|/ /
* | Merge pull request #4783 from gregolsen/ids_reader_fixJon Leighton2012-01-311-0/+4
|\ \ | | | | | | ids_reader method fixed, test added to has_many association (for PostgreSQL)
| * | ids_reader method fixed, test added to has_many associationgregolsen2012-01-311-0/+4
| |/
* | suggested fixes for :dependent => :restrict deprecation.Manoj2012-01-311-16/+5
| |
* | has_many/has_one, :dependent => :restrict, deprecation added.Manoj2012-01-291-12/+55
|/
* allow reorder to affect eager loading correctlyMatt Jones + Scott Walker2011-12-281-0/+10
|
* load has_many associations keyed off a custom primary key if that key is ↵Brian Samson2011-11-251-1/+28
| | | | present but the record is unsaved
* Merge pull request #3507 from jmazzi/issue-3503Jeremy Kemper2011-11-031-0/+15
| | | | Preserve SELECT columns on the COUNT for finder_sql when possible
* Fixed failed test under 1.8.7 as map.keys order in indeterminableRocky Jaiswal2011-09-281-1/+1
|
* Merge pull request #3030 from htanata/fix_habtm_select_query_methodJon Leighton2011-09-261-0/+8
| | | | Fix: habtm doesn't respect select query method