Jon Leighton
e9b6659c4c
Add missing require
2011-12-03 20:39:49 +00:00
Jon Leighton
51c2ef0b81
Avoid postgres 9.X syntax
2011-12-03 20:06:46 +00:00
Jon Leighton
9c172b2931
Fix #3837 .
...
We also need to time zone convert time zone aware attributes when
accessed via read_attribute, not only when via direct access.
2011-12-03 16:46:46 +00:00
Xavier Noria
de24ed9f2d
removes the convenience instance version of AR::Base.silence_auto_explain
...
Rationale: As discussed with José and Jon, this convenience
shortcut is not clearly justified and it could let the user
thing the disabled EXPLAINs are related to the model instance
rather than being globally disabled.
2011-12-03 14:26:34 +01:00
Jon Leighton
a02691ce09
Merge pull request #3820 from jaylevitt/nested_loading_through_assoc
...
reintroduce patch from #726 to handle nested eager loading via associations
2011-12-03 04:01:14 -08:00
Xavier Noria
0be5adaedf
implements AR::Base(.|#)silence_auto_explain
2011-12-02 11:16:26 -08:00
Xavier Noria
0306f82e0c
implements automatic EXPLAIN logging for slow queries
2011-12-02 04:35:43 -08:00
Jon Leighton
9ead4130de
Create method with known identifier then alias into place.
...
This means we never have to rely on define_method (which is slower and
uses more memory), even when we have attributes containing characters
that are not allowed in standard method names.
(I am mainly changing this because the duplication annoys me, though.)
2011-12-01 23:41:51 +00:00
Jon Leighton
e9fb6d04bd
Add test for read_attribute(:id) with non-standard PK.
...
Also make it actually work.
It slows down all read_attribute accesses to map 'id' to whatever the PK
actually is, inside read_attribute. So instead make sure the necessary
methods are defined and that they redirect wherever they need to go.
2011-12-01 23:41:51 +00:00
Jon Leighton
47b97a739d
Fix up test altering global state that was causing me grief
2011-12-01 23:41:51 +00:00
Jon Leighton
3a40d38619
Get rid of the underscore versions of attribute methods!
...
This makes me happy!
2011-12-01 23:41:51 +00:00
Jon Leighton
52eedf5e2b
Add hackery to make Syck use encode_with/init_with. Fixes 1.8 after recent changes to attribute serialization.
2011-12-01 01:15:16 +00:00
Jon Leighton
1c783c6040
don't alter global state in test
2011-11-30 23:47:16 +00:00
Julius de Bruijn
4e380828ff
If the table behind has no primary key, do not ask again and just return nil.
2011-11-30 23:47:16 +00:00
Jon Leighton
7895182d0f
omg computer science!
...
Implement a mini state machine for serialized attributes. This means we
do not have to deserialize the values upon initialization, which means
that if we never actually access the attribute, we never have to
deserialize it.
2011-11-30 23:18:40 +00:00
Jon Leighton
4f20eb5908
Fix typo
2011-11-30 23:18:40 +00:00
Jon Leighton
61489dc684
Use inheritance to avoid special-case code for the 'id' method
2011-11-30 23:18:40 +00:00
Jay Levitt
24b8814db0
reintroduce patch from #726 to handle nested eager loading via associations
2011-11-30 18:12:24 -05:00
Bogdan Gusiev
a382d60f6a
ActiveRecord::Relation#pluck method
2011-11-30 11:03:00 +02:00
Aaron Patterson
0e2477b602
Automatic closure of connections in threads is deprecated. For example
...
the following code is deprecated:
Thread.new { Post.find(1) }.join
It should be changed to close the database connection at the end of
the thread:
Thread.new {
Post.find(1)
Post.connection.close
}.join
Only people who spawn threads in their application code need to worry
about this change.
2011-11-29 15:04:41 -08:00
Aaron Patterson
29d2040b29
AbstractAdapter#close can be called to add the connection back to the
...
pool.
2011-11-29 14:40:37 -08:00
Aaron Patterson
f866f66b30
expire will set in_use to false
2011-11-29 14:02:58 -08:00
Aaron Patterson
79306de791
last_use is set on connection lease
2011-11-29 14:02:58 -08:00
Aaron Patterson
134cc8f939
Leased connections return false on second lease
2011-11-29 14:02:58 -08:00
Aaron Patterson
9bf8bf82b9
Adapters keep in_use flag when leased
2011-11-29 14:02:58 -08:00
Aaron Patterson
7837574e5b
namespace the adapter test
2011-11-29 14:02:58 -08:00
Jon Leighton
8df787d428
Deprecated define_attr_method in ActiveModel::AttributeMethods
...
This only existed to support methods like `set_table_name` in Active
Record, which are themselves being deprecated.
2011-11-29 20:13:37 +00:00
Jon Leighton
f3c84dc316
Deprecate set_locking_column in favour of self.locking_column=
2011-11-29 20:13:37 +00:00
Jon Leighton
1a474cc8e4
Deprecate set_primary_key in favour of self.primary_key=
2011-11-29 20:13:37 +00:00
Jon Leighton
4aad289428
Make sure the original_foo accessor still works (but deprecated) if we are using self.foo=
2011-11-29 20:13:37 +00:00
Jon Leighton
7af719e81c
Deprecate set_sequence_name in favour of self.sequence_name=
2011-11-29 20:13:37 +00:00
Jon Leighton
fd7ca98bb6
Add tests for set_sequence_name etc
2011-11-29 20:13:36 +00:00
Jon Leighton
34609d67b4
Deprecate set_inheritance_column in favour of self.inheritance_column=
2011-11-29 20:13:36 +00: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
Aaron Patterson
f73f53455a
respond_to? information of AR is not the responsibility of the spec
...
resolver.
2011-11-29 11:48:55 -08: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
c347b3c06c
don't change class definition in test case
2011-11-29 09:14:21 -08:00
Jon Leighton
d534c8fbe2
Fix resolver_test.rb on travis (postgresql isn't setup, so it can't load the connection adapter)
2011-11-29 12:47:54 +00:00
Jon Leighton
1defb6adb8
Fix schema_cache_test.rb for sqlite3_mem
2011-11-29 12:29:42 +00:00
Aaron Patterson
dde2113867
Move connection resoluion logic to it's own testable class.
2011-11-28 15:23:25 -08:00
Aaron Patterson
ffb218c750
pools are 1:1 with spec now rather than 1:1 with class
2011-11-28 15:23:25 -08:00
Aaron Patterson
2a9a8ad4df
break establish_connection to smaller methods
2011-11-28 15:23:24 -08:00
Aaron Patterson
ba0b3eee14
Merge pull request #3768 from janv/master
...
Test and fix for Issue 3450
2011-11-28 09:35:43 -08:00
Jan Varwig
cba5a3a367
Test case and fix for rails/rails#3450
...
Asssigning a parent id to a belongs_to association actually updates the object that is validated when the association has :validates => true
2011-11-27 22:29:56 +01:00
Jon Leighton
b00cf122e2
Merge pull request #3748 from samsonasu/has_many_custom_pk_new_record
...
New records should load has_many relationships with custom primary keys
2011-11-27 13:05:19 -08:00
Josh Susser
61bcc318c8
use GeneratedFeatureMethods module for associations
2011-11-27 11:22:12 -08:00
Xavier Noria
1be9830d4d
add the query to AR::Relation#explain output
...
Rationale: this is more readable if serveral queries
are involved in one call. Also, it will be possible
to let AR log EXPLAINs automatically in production
mode, where queries are not even around.
2011-11-25 14:29:34 -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
Aaron Patterson
008abd17dc
fixing tests on ruby 1.8
2011-11-20 15:09:03 -08:00
Aaron Patterson
bd2f5c062d
pushing caching and visitors down to the connection
2011-11-19 20:19:53 -08:00