Aaron Patterson
0aef847927
push !loaded? conditional up
2011-01-14 17:08:27 -08:00
Aaron Patterson
b8ed2d5ddf
return early in case the left or right side lists are empty
2011-01-14 17:03:15 -08:00
Aaron Patterson
75e29e871e
only find_target can raise the exception, so isolate the rescue around that call
2011-01-14 16:57:14 -08:00
Aaron Patterson
f548054700
we always have a target, so stop checking
2011-01-14 16:54:02 -08:00
Aaron Patterson
f5d2cb9cac
we should use [] instead of Array.new
2011-01-14 16:50:26 -08:00
Aaron Patterson
17687e4f96
@target is always a list, so stop doing is_a? checks
2011-01-14 16:47:31 -08:00
Aaron Patterson
2afd6c75f1
move complex logic to it's own method
2011-01-14 16:46:02 -08:00
Aaron Patterson
a0a69b045a
loaded? will not raise an AR::RecordNotFound exception, so move the rescue inside the conditional
2011-01-14 15:58:59 -08:00
Aaron Patterson
c326969745
reduce funcalls by using falsey objects
2011-01-14 14:45:46 -08:00
Aaron Patterson
dc11a77ab7
write the delegate method directly to avoid delegate callstack overhead
2011-01-14 14:40:11 -08:00
Aaron Patterson
ef4ffed660
reduce some lasigns
2011-01-14 14:30:47 -08:00
Aaron Patterson
92499b3c7e
Arel::Table.engine will be deprecated, so stop using it
2011-01-14 13:11:24 -08:00
Aaron Patterson
3165dca28c
include_in_memory? should check against @target list in case of new records. [ #6257 state:resolved]
2011-01-12 18:07:53 -08:00
Aaron Patterson
e1beb7d287
use array maths rather than *args
2011-01-12 15:15:45 -08:00
Aaron Patterson
8f9944d5bc
just use return value of load_target
2011-01-12 14:29:17 -08:00
Aaron Patterson
e9980f17fd
just call methods on return value of load_target
2011-01-12 14:27:08 -08:00
Aaron Patterson
bc993c690b
default return value is nil
2011-01-12 14:27:08 -08:00
Aaron Patterson
49696e0a62
@loaded is defined in initialize, so we should not need this
2011-01-12 14:27:08 -08:00
Aaron Patterson
8bee98fe3a
just use respond_to? and super rather than aliasing around methods
2011-01-12 14:27:08 -08:00
Aaron Patterson
f8700038af
adding a test for no method error
2011-01-11 17:57:02 -08:00
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
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
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
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