Commit Graph

555 Commits

Author SHA1 Message Date
Jon Leighton
f307f4d884 Delete obsolete comment 2011-12-16 14:52:02 +00:00
Jon Leighton
0b08ff7d92 Cache columns at the model level.
Allows two models to use the same table but have different primary keys.
2011-12-16 13:52:07 +00:00
Jon Leighton
8a37970312 Remove that there copy/pasted code 💣 2011-12-14 17:34:35 +00:00
Jon Leighton
909b337da8 Don't try to autosave nested assocs. Fixes #2961. 2011-12-14 17:28:59 +00:00
Aaron Patterson
5b82f50fef Use table_exists? from the schema cache. 2011-12-09 11:23:19 -08:00
Jon Leighton
5da90b3483 Fix #3890. (Calling proxy_association in scope chain.) 2011-12-08 20:10:04 +00:00
Jay Levitt
24b8814db0 reintroduce patch from #726 to handle nested eager loading via associations 2011-11-30 18:12:24 -05:00
Jon Leighton
0b72a04d0c Deprecate set_table_name in favour of self.table_name= or defining your own method. 2011-11-29 20:13:36 +00:00
Jon Leighton
2169603385 Merge pull request #3636 from joshsusser/master
association methods are now generated in modules
2011-11-29 10:09:42 -08:00
Josh Susser
61bcc318c8 use GeneratedFeatureMethods module for associations 2011-11-27 11:22:12 -08:00
Brian Samson
0f5104d720 load has_many associations keyed off a custom primary key if that key is present but the record is unsaved 2011-11-25 08:24:54 -07:00
Jeremy Kemper
533a9f84b0 Merge pull request #3507 from jmazzi/issue-3503
Preserve SELECT columns on the COUNT for finder_sql when possible
2011-11-03 21:17:15 -07:00
Jon Leighton
19b2a5f2bd Remove all revelant through records.
If a record is removed from a has_many :through, all of the join records
relating to that record should also be removed from the through
association's target.

(Previously the records were removed in the database, but only one was
removed from the in-memory target array.)
2011-11-03 13:13:13 +00:00
Jon Leighton
71bc921ec8 Fix adding multiple instances of the same record to a has_many :through.
Fixes #3425.
2011-11-03 12:39:05 +00:00
Jon Leighton
b4b178f7e9 Fix #3247.
Fixes creating records in a through association with a polymorphic source
type.
2011-11-03 10:23:42 +00:00
Rocky Jaiswal
aefc40324d Fixed failed test under 1.8.7 as map.keys order in indeterminable 2011-09-28 11:57:34 +05:30
Jon Leighton
89e98e278a Merge pull request #3030 from htanata/fix_habtm_select_query_method
Fix: habtm doesn't respect select query method
2011-09-26 16:52:23 +01:00
Jon Leighton
3b87c38d02 Fix belongs_to polymorphic with custom primary key on target.
Closes #3104.
2011-09-26 15:42:34 +01:00
Jon Leighton
b838059817 CollectionProxy#replace should change the DB records rather than just mutating the array. Fixes #3020. 2011-09-26 10:41:58 +01:00
Jon Leighton
143769051b Don't include any of includes, preload, joins, eager_load in the through association scope. 2011-09-07 09:27:41 +01:00
Jon Leighton
9bde73ff72 Nested through associations: preloads from the default scope of a through model should not be included in the association scope. (We're already excluding includes.) Fixes #2834. 2011-09-06 16:34:32 +01:00
Jon Leighton
b24d668859 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 15:58:07 +01:00
Jon Leighton
77ff1ce541 Disable active record marshalling tests on Ruby 1.8.7 on Travis CI, as they have been failing intermittently for a long while due to what appears to be a Ruby bug. If anyone has the skills/expertise/time to debug this, please speak to the Travis guys. 2011-09-06 11:45:08 +01:00
Georg Friedrich
2175012230 Don't find belongs_to target when the foreign_key is NULL. Fixes #2828 2011-09-05 13:49:29 -07:00
Jon Leighton
735d985b01 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:05:47 +01:00
Jon Leighton
57423d815b Ensure empty has_many :through association preloaded via joins is marked as loaded. Fixes #2054. 2011-08-15 16:01:01 +01:00
Jon Leighton
34689c40a0 Work around for lolruby bug. (Read on for explanation.)
We were experiencing CI test failures, for example:

* 3-1-stable: http://travis-ci.org/#!/rails/rails/builds/79473/L407
* master: http://travis-ci.org/#!/rails/rails/builds/79507/L80

These failures only happened on 1.8.7-p352, and we were only able to
reproduce on the Travis CI VM worker. We even tried creating a new 32
bit Ubuntu VM and running the tests on that, and it all worked fine.

After some epic trial and error, we discovered that replacing the
following:

  fuu = Marshal.load(Marshal.dump(fuu))

with:

  marshalled = Marshal.dump(fuu)
  fuu = Marshal.load(marshalled)

seemed to prevent the failure.

We have NO IDEA why this is. If anyone has some great insight to
contribute then that is welcome. Otherwise, hopefully this will just
help us get the CI green again.

Many thanks to @joshk for help with sorting this out.
2011-08-13 13:54:54 +01:00
Santiago Pastorino
e0a6ec2149 Fix test for Rubinius 2011-08-05 16:48:46 -03:00
Elliot Winkler
0e1d617b8b ActiveRecord: Fix eager loading so that giving a blank order clause generates valid SQL 2011-07-18 14:56:37 -06:00
Jon Leighton
1712d90050 Fix exception if old and new targets are both nil. Fixes #1471. 2011-07-12 00:14:45 +01:00
Jon Leighton
111968d402 Foo.joins(:bar).includes(:bar) should result in a single query with :bar as a join. Related: #1873. 2011-07-09 11:39:04 +01:00
Jon Leighton
dfec3737b0 Ensure that the foreign key gets set when doing record.create_association or record.create_association. Fixes #1960. 2011-07-08 21:03:54 +01:00
Anatoliy Lysenko
66dd2d3d10 Fix bug in collection_singular_ids on has many through association with conditions and includes,
when condtions references tables from includes.
Test fail because of invalid sql:
ActiveRecord::StatementInvalid: SQLite3::SQLException: no such column: comments.id:
SELECT "posts".id FROM "posts" INNER JOIN "readers" ON "posts"."id" = "readers"."post_id"
WHERE "readers"."person_id" = 1 AND (comments.id is null)

Bug described in github#925

This commit will revert fix from 3436fdfc12 , but tests is ok.

Bug described in #6569 ticket.
2011-07-06 23:23:34 +03:00
Santiago Pastorino
b27871a66f Merge pull request #1968 from bogdan/associations_find_array_compatibility2
Fixed CollectionAssociation#find to be compatible with Array#find
2011-07-05 09:41:09 -07:00
Bogdan Gusiev
8ba0c1ac53 Fixed CollectionAssociation#find to be compatible with Array#find
In order to make CollectionAssociation behave closer to Array
Add the ability to pass block to #find method just like Array#find does.
2011-07-05 10:51:40 +03:00
Dieter Komendera
7d3aa2462c Only call set_owner_attributes for has_one association if target exists. 2011-07-04 18:43:09 +02:00
Jon Leighton
0e225ec583 Assign the association attributes to the associated record before the before_initialize callback of the record runs. Fixes #1842. 2011-06-30 23:39:58 +01:00
Jon Leighton
c52520166b Make assert_no_queries literally enforce that there are no queries. As in, not a single line of SQL should be sent to the database, not even stuff that is ignored by assert_queries. The argument being that if you write assert_no_queries, you really do not want there to be any queries. 2011-06-12 18:50:24 +01:00
Jon Leighton
14e6bbb149 Refactor tests to be less brittle 2011-06-12 18:19:21 +01:00
benedikt
fa8dfad765 Don't wrap operations on collection associations in transactions when they are not needed, so the connection adapter does not send empty BEGIN COMMIT transactions blocks to the database. 2011-06-12 18:19:21 +01:00
Raimonds Simanovskis
e58ee1dccc Do not hardcode :id as it was ignored by mass assignment filter
As a result test was failing on Oracle where ids are assigned by default from 1000
2011-06-08 11:56:23 +03:00
Jon Leighton
7d1782a2c1 Allow polymorphic has_one to work when the association is set before the owner has been saved. Fixes #1524. 2011-06-08 00:32:49 +01:00
Jon Leighton
4f5f6a3257 When you add a record to a polymorphic has_one, you should be able to access the owner from the associated record 2011-06-08 00:32:49 +01:00
José Valim
e32e8ed966 Merge pull request #1474 from ganeshkumar/update_column_changes
added  tests for update_column
2011-06-07 00:14:42 -07:00
Aaron Patterson
61774e0d49 please use ruby -I lib:test path/to/test.rb, or export RUBY_OPT 2011-06-06 15:47:13 -07:00
Jon Leighton
253bb6b926 Refactor Active Record test connection setup. Please see the RUNNING_UNIT_TESTS file for details, but essentially you can now configure things in test/config.yml. You can also run tests directly via the command line, e.g. ruby path/to/test.rb (no rake needed, uses default db connection from test/config.yml). This will help us fix the CI by enabling us to isolate the different Rails versions to different databases. 2011-06-04 23:47:03 +01:00
ganesh
5f66f7a9a2 added more tests for update_column 2011-06-04 00:04:59 +05:30
Josh Kalderimis
eb7ef2ccd6 added an alias for new to build to the AR collection proxy, this corrects an issue where the collection proxies were not consistent 2011-06-01 00:01:35 +01:00
Farley Knight
aa316e27b7 Tests for issue #1360 2011-05-31 19:47:34 +01:00
Arun Agrawal
e04f2c1d42 Opening class CascadedEagerLoadingTest at once. 2011-05-31 12:35:37 +05:30