Commit Graph

91 Commits

Author SHA1 Message Date
David Heinemeier Hansson
1671609063 Fixed that has_many.create ended up with duplicate objects (closes #5250) [daniel@nouvelles-solutions.com]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4416 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2006-06-03 21:16:50 +00:00
Rick Olson
cc88679c0c band-aid for oracle
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4380 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2006-05-29 04:22:49 +00:00
Rick Olson
06075a9eb5 Fix the has_and_belongs_to_many #create doesn't populate the join for new records. Closes #3692 [josh@hasmanythrough.com]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4379 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2006-05-29 03:48:17 +00:00
Rick Olson
ea51d72edb Provide Association Extensions access to the instance that the association is being accessed from. Closes #4433 [josh@hasmanythrough.com]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4372 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2006-05-28 21:33:34 +00:00
David Heinemeier Hansson
cc1c943aa1 Make Oracle happy
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4357 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2006-05-21 22:17:56 +00:00
David Heinemeier Hansson
66586bc168 Fixed that has_many collections shouldn't load the entire association to do build or create [DHH]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4354 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2006-05-21 19:17:37 +00:00
Jeremy Kemper
d59f3a78a4 uniq preserves order. References [4325].
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4326 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2006-05-07 02:03:25 +00:00
Rick Olson
df7b74668e Fix the HasManyAssociation#count method so it uses the new ActiveRecord::Base#count syntax, while maintaining backwards compatibility. [Rick]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4237 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2006-04-19 21:37:54 +00:00
Florian Weber
bb4c6797bf Fixed that AssociationCollection#delete_all should work even if the records of the association are not loaded yet. [Florian Weber]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4144 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2006-04-03 22:37:56 +00:00
David Heinemeier Hansson
53aa8da1a7 Fixed that records returned from has_and_belongs_to_many associations with additional attributes should be marked as read only (fixes #4512) [DHH] DEPRECATED: Using additional attributes on has_and_belongs_to_many associations. Instead upgrade your association to be a real join model [DHH]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4123 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2006-04-01 20:03:10 +00:00
Rick Olson
229c0f4367 Rework table aliasing to account for truncated table aliases. Add smarter table aliasing when doing eager loading of STI associations. This allows you to use the association name in the order/where clause. [Jonathan Viney / Rick Olson] closes #4108
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3921 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2006-03-18 07:31:01 +00:00
Rick Olson
02d34440cf Alias the has_and_belongs_to_many join table on eager includes. closes #4106 [jeremyevans0@gmail.com]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3895 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2006-03-16 04:18:12 +00:00
Rick Olson
a0c459bca7 fix test_find_in_association_with_options test, tweak other tests affected by developer/project addition
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3890 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2006-03-16 03:24:40 +00:00
Jamis Buck
b95b09f32d a few more tests for the custom counter_cache naming code
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3826 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2006-03-09 18:11:41 +00:00
Jamis Buck
87898badba Allow counter_cache to accept a column name
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3825 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2006-03-09 17:23:57 +00:00
Jamis Buck
ff881c7f8b Make counter cache work when replacing an association (closes #3245). Thanks for the patch!
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3762 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2006-03-04 19:42:41 +00:00
David Heinemeier Hansson
116658e69b Fixed that calling HasOneProxy#build_model repeatedly would cause saving to happen (closes #4058) [anna@wota.jp]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3753 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2006-03-03 06:25:39 +00:00
David Heinemeier Hansson
6a2104d792 Added assert_date_from_db to do cleaner tests for SQL Server (closes #3557) [Tom Ward]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3452 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2006-01-21 23:20:00 +00:00
Marcel Molina
b98684c3e1 Fix date errors for SQLServer in association tests. Closes #3406.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3404 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2006-01-13 02:04:34 +00:00
Florian Weber
c6e01f5b60 Fixed that saving a model with multiple habtm associations, would only save the first habtm association.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3331 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-12-21 15:50:31 +00:00
David Heinemeier Hansson
e5d9ad3e29 Added option inheritance for find calls on has_and_belongs_to_many and has_many assosociations [DHH] Added option to specify :group, :limit, :offset, and :select options from find on has_and_belongs_to_many and has_many assosociations [DHH]
Added form_remote_for (form_for meets form_remote_tag) [DHH]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3287 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-12-13 00:39:51 +00:00
Jeremy Kemper
dc106b932c Fix some test failures due to MySQL assumptions. Closes #3149.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3254 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-12-08 23:23:34 +00:00
Florian Weber
1f951bbf9f Made test_update_attributes_after_push_without_duplicate_join_table_rows pass with Oracle Adapter. #2888
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3186 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-11-24 12:45:33 +00:00
Florian Weber
c66ac2102b Fixed bug where using update_attribute after pushing a record to a habtm association of the object caused duplicate rows in the join table. #2888
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3167 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-11-23 21:03:25 +00:00
Jeremy Kemper
2076dca63f r3095@asus: jeremy | 2005-11-15 22:40:51 -0800
Ticket #1874 - Firebird adapter
 r3107@asus:  jeremy | 2005-11-16 00:06:14 -0800
 quote column aliases
 r3108@asus:  jeremy | 2005-11-16 00:08:12 -0800
 quote columns in construct_conditions_from_arguments.  update sequence_name docs.  introduce prefetched primary keys.
 r3109@asus:  jeremy | 2005-11-16 00:09:08 -0800
 double-quote rather than single-quote sqlite columns
 r3110@asus:  jeremy | 2005-11-16 00:09:56 -0800
 quote column names and use attribute_condition in validates_uniqueness_of
 r3111@asus:  jeremy | 2005-11-16 00:12:24 -0800
 Use QUOTED_TYPE constant in tests
 r3112@asus:  jeremy | 2005-11-16 00:13:28 -0800
 restrict test_inserts_with_pre_and_suffix to those adapters which support migrations
 r3113@asus:  jeremy | 2005-11-16 00:14:09 -0800
 Use QUOTED_TYPE constant in tests
 r3114@asus:  jeremy | 2005-11-16 00:14:30 -0800
 Use QUOTED_TYPE constant in tests


git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3051 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-11-16 08:16:54 +00:00
Jeremy Kemper
3441dfdb12 Associations handle case-equality more consistently: item.parts.is_a?(Array) and item.parts === Array. Closes #1345.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3043 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-11-15 10:48:32 +00:00
Jeremy Kemper
3309268120 Add :group option, correspond to GROUP BY, to the find method and to the has_many association. Closes #2818.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2974 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-11-10 16:36:01 +00:00
Jeremy Kemper
35b4bdcff0 Destroy associated has_and_belongs_to_many records after all before_destroy callbacks but before destroy. This allows you to act on the habtm association as you please while preserving referential integrity. Closes #2065.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2940 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-11-08 10:19:09 +00:00
David Heinemeier Hansson
a5a82d978b Added extension capabilities to has_many and has_and_belongs_to_many proxies [DHH] Added find_or_create_by_X as a second type of dynamic finder that'll create the record if it doesn't already exist [DHH] Added constrain scoping for creates using a hash of attributes bound to the :creation key [DHH]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2872 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-11-04 19:39:50 +00:00
David Heinemeier Hansson
bc73b838e0 Made more tests for SQLServer pass (closes #2486) [Tom Ward]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2779 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-10-28 07:42:16 +00:00
David Heinemeier Hansson
beff664f2a Refactor DB exceptions and deal more with DB2 (closes #2624)
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2761 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-10-27 08:18:41 +00:00
Jeremy Kemper
3ab3a70b7c Clarify semantics of ActiveRecord::Base#respond_to? Closes #2560.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2705 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-10-22 16:43:39 +00:00
Tobias Lütke
5f0b9369cc Fix Associations#clear for not-yet-loaded associations (Patrick Lenz)
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2695 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-10-20 15:05:48 +00:00
Tobias Lütke
2a1a0e5275 Fixed a few sqlserver test case errors. Closes #2486
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2666 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-10-17 18:17:05 +00:00
Jeremy Kemper
7117fdb8ce r3616@asus: jeremy | 2005-09-26 23:09:28 -0700
Ticket 2292 - Sequences, schemas, and fixtures
 r3917@asus:  jeremy | 2005-10-15 10:43:24 -0700
 fix pk assert
 r3918@asus:  jeremy | 2005-10-15 10:46:52 -0700
 rework query cache connection= override
 r3919@asus:  jeremy | 2005-10-15 10:47:45 -0700
 correct fixtures usage
 r3920@asus:  jeremy | 2005-10-15 10:53:23 -0700
 correct attr assignment
 r3921@asus:  jeremy | 2005-10-15 12:59:10 -0700
 sequences
 r3922@asus:  jeremy | 2005-10-15 16:36:09 -0700
 reset fixtures work with sequences
 r3951@asus:  jeremy | 2005-10-15 23:23:12 -0700
 cut down excess features
 r3952@asus:  jeremy | 2005-10-15 23:40:30 -0700
 don't test for PostgreSQL specifically


git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2639 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-10-16 03:45:39 +00:00
Tobias Lütke
7086993161 Adds :nullify option to :depends. Closes #2015 (Robby Russell)
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2595 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-10-15 00:46:55 +00:00
Tobias Lütke
5fa8793f02 DRYed up Associations#clear. Closes #1906 [Caleb]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2580 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-10-14 12:53:39 +00:00
Jamis Buck
99f3ae0845 Fix errors caused by assigning a has-one or belongs-to property to itself
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2562 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-10-13 19:21:45 +00:00
Jeremy Kemper
e19bd169fa Association validation does not belong in a before_save callback: move it into a validation method. Restores the expected model.valid? == model.save. Add tests for cancelling save by returning false from a before_save callback. Remove assumption that before_destroy's return value indicates whether the record was destroyed.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2434 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-10-02 02:00:50 +00:00
Jeremy Kemper
dd21e9ae39 r3657@asus: jeremy | 2005-09-28 00:32:33 -0700
Also test that client.firm_id.nil? after firm.clients.clear when clients is not :dependent


git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2385 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-09-28 04:00:59 +00:00
Jeremy Kemper
efaf2af07c r3653@asus: jeremy | 2005-09-28 00:23:49 -0700
Ticket 2221 - model.association.clear should destroy associated objects if :dependent => true instead of nullifying their foreign keys


git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2384 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-09-28 03:52:57 +00:00
David Heinemeier Hansson
66ecf31ffe Fixed that the create_x method from belongs_to wouldn't save the association properly #2042 [Florian Weber]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2279 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-09-20 18:36:14 +00:00
Jamis Buck
5213a1f733 Fixed saving a record with two unsaved belongs_to associations pointing to the same object #2023 [Tobias Luetke]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2278 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-09-20 16:12:13 +00:00
David Heinemeier Hansson
4307d7ecbe Fixed various problems with has_and_belongs_to_many when using customer finder_sql #2094 [Florian Weber]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2233 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-09-13 10:15:54 +00:00
David Heinemeier Hansson
3004217855 Fixed that the SQL Server adapter would sometimes return DBI::Timestamp objects instead of Time #2127 [Tom Ward]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2169 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-09-09 08:37:05 +00:00
David Heinemeier Hansson
0439769324 Refactored away all the legacy validate_options calls and replaced them with Hash#assert_valid_keys
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2167 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-09-09 08:32:47 +00:00
Jamis Buck
7d65f7cd3d Revert [2040], caused assignment of belongs_to associations to fail in some cases
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2048 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-08-24 16:45:46 +00:00
Jamis Buck
943fde0a55 Add a failing test
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2047 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-08-24 16:25:56 +00:00
Jamis Buck
dfe1aeb776 Saving a record with two unsaved belongs_to associations pointing to the same object fails #2023 [Tobias Luetke]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2040 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-08-23 11:05:04 +00:00
Jamis Buck
83e2f6ae1e Allow unspecified join-table columns to use to their default values when adding to a habtm collection
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1860 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2005-07-18 11:06:41 +00:00