Aaron Patterson
fcd8925f23
use underlying _read_attribute method rather than causing NoMethodErrors
2011-01-11 15:39:26 -08:00
Aaron Patterson
5696d948ed
kill unused variable warnings
2011-01-11 15:29:35 -08:00
Aaron Patterson
8c71e8b18f
lazily instantiate AR objects in order to avoid NoMethodErrors
2011-01-11 15:16:09 -08:00
Jon Leighton
af96018c91
test_with_polymorphic_and_condition works without the conditions methods in BelongsToPolymorphicAssociation because the conditions are added straight to the association_scope as of a few days ago
2011-01-11 13:45:09 -08:00
Jon Leighton
552df9b933
Support for create_association! for has_one associations
2011-01-11 13:45:09 -08:00
Jon Leighton
d88caa6e4a
Refactor the code for singular association constructors. This will allow me to define a create_association! method in a minute.
2011-01-11 13:45:09 -08:00
Jon Leighton
f4a88e810f
It's not necessary to pass the association proxy class around now
2011-01-11 13:45:09 -08:00
Jon Leighton
681ab53ba1
Get rid of set_association_target and association_loaded? as the parts of the code that need that can now just use association_proxy(:name).loaded?/target=
2011-01-11 13:45:08 -08:00
Jon Leighton
42b2e4f85b
We can use the association_proxy method directly in HasOneThroughAssociation now
2011-01-11 13:45:08 -08:00
Jon Leighton
3b797c8c86
DRY up the code which instantiates the association proxy
2011-01-11 13:45:08 -08:00
Jon Leighton
4754018272
find_target can be inherited
2011-01-11 13:45:07 -08:00
Jon Leighton
9086b02ba5
Document the recent changes to association assignment
2011-01-11 13:45:07 -08:00
Jon Leighton
6055bbedaa
Raise ActiveRecord::RecordNotSaved if an AssociationCollection fails to be replaced
2011-01-11 13:45:07 -08:00
Jon Leighton
1d6e218428
When assigning a has_one, if anything fails, the assignment should be rolled back entirely
2011-01-11 13:45:07 -08:00
Jon Leighton
4e19ec566c
In a number of places in the tests, we only need to turn off transactional fixtures when the DB does not support savepoints. This speeds the test run up by about 8-9% on my computer, when running rake test_sqlite3_mem :)
2011-01-11 13:45:07 -08:00
Jon Leighton
29452abb84
SQLite3 has supported savepoints since version 3.6.8, we should use this!
2011-01-11 13:45:07 -08:00
Jon Leighton
7f7b480098
When assigning a has_one, if the new record fails to save, raise an error
2011-01-11 13:45:07 -08:00
Jon Leighton
1bc71ed960
When assigning a has_one, if the existing record fails to be removed from the association, raise an error
2011-01-11 13:45:06 -08:00
Jon Leighton
c47c541402
Have a separate test connection directory for sqlite3 in-memory so that the tests can be run without having to specifically rename the connection file (which then causes git to pick up the changes)
2011-01-11 13:45:06 -08:00
Jon Leighton
80df74bf51
Enable the sqlite3 in-memory test connection to work
2011-01-11 13:45:06 -08:00
Jon Leighton
c6e10b0f60
has_one should always remove the old record (properly), even if not saving the new record, so we don't get the database into a pickle
2011-01-11 13:45:06 -08:00
Jon Leighton
665880c080
Return value is irrelevant here as the RHS of the assignment is always returned by methods ending in '='
2011-01-11 13:45:06 -08:00
Jon Leighton
15adcc3927
Remove incorrect documentation about build_assoc on has_one. This is proven, for example, by test_successful_build_association in has_one_associations_test.rb
2011-01-11 13:45:06 -08:00
Jon Leighton
00dc8f77a2
For a singular association, it should be build_association, rather than association.build (as association may be nil)
2011-01-11 13:45:06 -08:00
Jon Leighton
1390a44328
Correctly indent the bullet points under 'One-to-one associations', so that the lines are not broken in the generated rdoc html
2011-01-11 13:45:05 -08:00
Aaron Patterson
f6b71dea15
avoid splatting arrays by using concat
2011-01-11 13:45:05 -08:00
Ernie Miller
7d4d745730
Fix polymorphic belongs_to associationproxy raising errors when loading target.
2011-01-11 09:19:19 -08:00
Aaron Patterson
a60ea74222
only use one array when collecting split up queries
2011-01-10 17:30:40 -08:00
Raimonds Simanovskis
f4f4964ce0
Always return decimal average of integer fields
...
In previous version if database adapter (e.g. SQLite and Oracle) returned non-String calculated values then type_cast_using_column converted decimal average value of intefer field to integer value. Now operation parameter is always checked to decide which conversion of calculated value should be done.
2011-01-10 15:51:32 -08:00
Aaron Patterson
0616585619
use SQLite3::VERSION rather than the deprecated class
2011-01-10 11:40:19 -08:00
Kevin Moore
3e2465521b
Aligning master changelog w/ 3-0-stable
2011-01-09 16:07:25 -08:00
Katrina Owen
4690bee301
Adding postgresql template option when executing db:test:clone_structure
...
Specify the template to use in config/database.yml, e.g.
test:
adapter: postgresql
template: template_postgis
If no template is specified, postgresql defaults to template1
2011-01-09 15:35:47 -08:00
Aaron Patterson
12f5158f09
remove unused string substitution
2011-01-08 20:15:15 -08:00
Aaron Patterson
3b677aa006
use select_all because not all database adapters support bind values
2011-01-08 19:59:31 -08:00
Aaron Patterson
ec960c3730
join the cult of cargo. reduce the number of NoMethodErrors in the system
2011-01-07 18:45:30 -08:00
Aaron Patterson
36d7bd1898
stop creating intermediate AR objects, just construct AR objects from a list of hashes
2011-01-07 18:45:17 -08:00
Aaron Patterson
84f81f5779
no need for to_sym
2011-01-07 16:50:44 -08:00
Aaron Patterson
33ebf9bd56
String#insert() mutates the string, so no need for lasgn
2011-01-07 16:27:34 -08:00
Aaron Patterson
1e2ab564f9
fewer funcalls to the cached attributes variable
2011-01-07 16:27:34 -08:00
Jeremy Kemper
63ed6ca998
Add test for e0e3adf
2011-01-07 16:25:25 -08:00
Jon Leighton
82b0ce9c97
Refactor HasOneAssociation#replace
2011-01-07 15:03:16 -08:00
Jon Leighton
5b28e52542
Don't not remove double negatives
2011-01-07 15:03:16 -08:00
Jon Leighton
d23c332e02
Clean up create, create! and build in HasOneAssociation
2011-01-07 15:03:15 -08:00
Jon Leighton
5ecf692248
merge_with_conditions is not necessary because the conditions will already be in the scope_for_create hash in the scope
2011-01-07 15:03:15 -08:00
Jon Leighton
45d0d18bae
Not really worth having the HasAssociation module for just a single method
2011-01-07 15:03:15 -08:00
Jon Leighton
770e6893b9
Construct an actual ActiveRecord::Relation object for the association scope, rather than a hash which is passed to apply_finder_options. This allows more flexibility in how the scope is created, for example because scope.where(a, b) and scope.where(a).where(b) mean different things.
2011-01-07 15:03:15 -08:00
Jon Leighton
441118458d
Use encode_with for marshalling
2011-01-07 15:03:15 -08:00
Aaron Patterson
2efd780dcb
send() will raise an ArgumentError, so we should leverage ruby
2011-01-07 14:30:20 -08:00
Aaron Patterson
6e63e7a874
no need for parens
2011-01-07 14:10:46 -08:00
Aaron Patterson
344a2d5adc
use a hash for caching aggregations rather than ivars
2011-01-07 13:53:34 -08:00