Commit Graph

4584 Commits

Author SHA1 Message Date
Josh Susser
5214e73850 add #first! and #last! to models & relations 2011-03-24 09:55:51 -07:00
Adam Meehan
c5908a8649 Fix before_type_cast for timezone aware attributes by caching converted value on write. Also remove read method reload arg on timezone attributes. 2011-03-23 15:38:51 -07:00
Murray Steele
54c963c89b Make clearing of HABTM join table contents happen in an after_destory callback.
The old method of redefining destroy meant that clearing the HABTM join table would happen as long as the call to destroy succeeded.  Which meant if there was a before_destroy that stopped the instance being destroyed using normal means (returning false, raising ActiveRecord::Rollback) rather than exceptional means the join table would be cleared even though the instance wasn't destroyed.  Doing it in an after_destroy hook avoids this and has the advantage of happening inside the DB transaction too.
2011-03-23 14:45:21 -07:00
Xavier Noria
3b91b3726d Merge branch 'master' of git://github.com/lifo/docrails 2011-03-23 21:52:33 +01:00
Santiago Pastorino
450f7cf01b use class_eval with a string when it's possible 2011-03-22 20:11:36 -03:00
Santiago Pastorino
baa237c974 Allow to read and write AR attributes with non valid identifiers 2011-03-22 20:02:32 -03:00
Santiago Pastorino
da6c7bd4b4 Do not in place modify what table_name returns 2011-03-22 19:36:16 -03:00
Aaron Patterson
2ef6270f8f Merge branch 'master' into fuuu
* master:
  Do not show optional (.:format) block for wildcard route [#6605 state:resolved]
  pushing id insertion and prefetch primary keys down to Relation#insert
  use prepared statements to fetch the last insert id
  escaping binary data encoding when inserting to sqlite3. Thanks Naruse! [#6559 state:resolved]
  schemas set by set_table_name are respected by the mysql adapter. [#5322 state:resolved]
  Reapply extensions when using except and only
  SJIS is an alias to Windows-31J in ruby trunk. Use SHIFT_JIS for this test
  Improved resolver docs a bit
  [action_view] docs for FileSystemResolver
  [action_view] added custom patterns to template resolver
2011-03-22 09:34:33 -07:00
Aaron Patterson
15d3cc21f4 pushing id insertion and prefetch primary keys down to Relation#insert 2011-03-22 09:18:01 -07:00
Aaron Patterson
3378d77b04 use prepared statements to fetch the last insert id 2011-03-21 16:32:13 -07:00
Aaron Patterson
88636f7195 escaping binary data encoding when inserting to sqlite3. Thanks Naruse! [#6559 state:resolved] 2011-03-21 14:49:07 -07:00
Aaron Patterson
ea8fcfb729 schemas set by set_table_name are respected by the mysql adapter. [#5322 state:resolved] 2011-03-21 11:20:45 -07:00
Iain Hecker
96b9fc4400 Reapply extensions when using except and only 2011-03-21 10:29:45 -07:00
Paco Guzman
f3666040a0 remove bank line 2011-03-18 11:29:52 +01:00
Jon Leighton
8aaf3c1e55 Merge branch 'master' into nested_has_many_through 2011-03-16 18:54:51 +00:00
Manuel Meurer
64fe0d4cba Remove incorrect comment that a default value of NULL cannot be set with change_column_default. 2011-03-16 11:01:43 +07:00
Xavier Noria
21b12d89a6 Merge branch 'master' of git://github.com/lifo/docrails 2011-03-14 22:09:52 +01:00
Anders Elfving
9b64399684 Adjust unique constraint comment to include info about the RecordNotUnique exception 2011-03-13 11:49:56 +01:00
Chris Oliver
015192560b Fixed a bug when empty? was called on a grouped Relation that wasn't loaded
[#5829 state:resolved]

Signed-off-by: Andrew White <andyw@pixeltrix.co.uk>
2011-03-12 22:31:21 +00:00
Mike Gehard
58de03f077 Add additional text to NotImplementedErrors [#6328 state:resolved]
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2011-03-12 13:43:23 -02:00
Jon Leighton
37d93ea160 Fix tests under postgres - we should always put conditions in the WHERE part not in ON constraints because postgres requires that the table has been joined before the condition references it. 2011-03-12 09:32:20 +00:00
Jon Leighton
02a43f9f45 Resolve some TODO comments which I decided did not need anything done 2011-03-12 08:42:57 +00:00
Paco Guzman
0a51e43866 remove some blanks 2011-03-11 23:08:55 +01:00
Jon Leighton
39a6f4f25d Simplify implementation of ThroughReflection#chain 2011-03-11 00:51:57 +00:00
Jon Leighton
e18679ab04 Abstract some common code from AssociationScope and JoinDependency::JoinAssociation into a JoinHelper module 2011-03-11 00:47:18 +00:00
Jon Leighton
aef3629c6e Refactor JoinAssociation 2011-03-10 23:55:29 +00:00
Jon Leighton
2d3d9e3531 Rename Reflection#through_reflection_chain and #through_options to Reflection#chain and Reflection#options as they now no longer relate solely to through associations. 2011-03-10 19:28:26 +00:00
Jon Leighton
6490d65234 Move the code which builds a scope for through associations into a generic AssociationScope class which is capable of building a scope for any association. 2011-03-10 19:04:00 +00:00
Jon Leighton
bb063b2f1b Fix test_has_many_association_through_a_has_many_association_with_nonstandard_primary_keys 2011-03-07 20:58:32 +00:00
Jon Leighton
532f915037 Referencing a table via the ON condition in a join should force that table to be eager-loaded via a JOIN rather than via subsequent queries. 2011-03-07 08:51:17 -08:00
Jon Leighton
cee3f9b36d Referencing a table via the ON condition in a join should force that table to be eager-loaded via a JOIN rather than via subsequent queries. 2011-03-07 00:04:20 +00:00
Jon Leighton
5dc1fb39dd Refactor ThroughAssociation#join_to to be much smaller, and independent of construct_owner_conditions. 2011-03-06 23:38:10 +00:00
Jon Leighton
d02c326a8b Refactor ThroughAssociation#tables to just be a flat array of tables in the order that they should be joined together. 2011-03-06 18:14:39 +00:00
Jon Leighton
28ed10d3f2 Merge branch 'master' into nested_has_many_through
Conflicts:
	activerecord/CHANGELOG
2011-03-05 22:58:48 +00:00
Jon Leighton
b7f1b3641a Use Base#type_condition in JoinAssociation 2011-03-05 22:32:49 +00:00
Jon Leighton
7fddb94262 Push source_type and polymorphic conditions out of ThroughAssociation and JoinDependency::JoinAssociation and into the reflection instead. 2011-03-05 22:07:30 +00:00
Jon Leighton
ddf83d14f1 Add a test for STI on the through where the through is nested, and change the code which support this 2011-03-05 20:10:24 +00:00
Aaron Patterson
74818a3543 use Arel::Table#alias rather than passing the :as parameter 2011-03-05 11:56:24 -08:00
R.T. Lechow
a1b4d8e7b2 Active Record typos. 2011-03-05 11:56:34 +01:00
mjy
045ca30394 fixes a missmatched column in example 2011-03-05 11:56:33 +01:00
Xavier Noria
3b10b8a201 implements ActiveRecord::Base.connection_config to be able to check the configuration of the current connection at runtime 2011-03-05 01:35:02 +01:00
Jon Leighton
8987cda2bb When preloading has_and_belongs_to_many associations, we should only instantiate one AR object per actual record in the database. (Even when IM is off.) 2011-03-04 15:16:07 -08:00
Jon Leighton
af27262ec3 Fix a couple of tests in join_model_test.rb which were failing when the identity map is turned off 2011-03-04 14:49:19 -08:00
Jon Leighton
4206eff189 Stop identity-mapping the through records in the preloader since I fixed the underlying problem in the habtm preloader. 2011-03-04 22:36:44 +00:00
Jon Leighton
b5b5558d2f Fix a couple of tests in join_model_test.rb which were failing when the identity map is turned off 2011-03-04 22:35:46 +00:00
Jon Leighton
73c0b390b3 When preloading has_and_belongs_to_many associations, we should only instantiate one AR object per actual record in the database. (Even when IM is off.) 2011-03-04 22:33:16 +00:00
Jon Leighton
a5ef8b9fa0 Merge branch 'master' into nested_has_many_through 2011-03-04 20:36:11 +00:00
Jon Leighton
735844db71 Merge branch 'master' into nested_has_many_through
Conflicts:
	activerecord/CHANGELOG
	activerecord/lib/active_record/association_preload.rb
	activerecord/lib/active_record/associations.rb
	activerecord/lib/active_record/associations/class_methods/join_dependency.rb
	activerecord/lib/active_record/associations/class_methods/join_dependency/join_association.rb
	activerecord/lib/active_record/associations/has_many_association.rb
	activerecord/lib/active_record/associations/has_many_through_association.rb
	activerecord/lib/active_record/associations/has_one_association.rb
	activerecord/lib/active_record/associations/has_one_through_association.rb
	activerecord/lib/active_record/associations/through_association_scope.rb
	activerecord/lib/active_record/reflection.rb
	activerecord/test/cases/associations/has_many_through_associations_test.rb
	activerecord/test/cases/associations/has_one_through_associations_test.rb
	activerecord/test/cases/reflection_test.rb
	activerecord/test/cases/relations_test.rb
	activerecord/test/fixtures/memberships.yml
	activerecord/test/models/categorization.rb
	activerecord/test/models/category.rb
	activerecord/test/models/member.rb
	activerecord/test/models/reference.rb
	activerecord/test/models/tagging.rb
2011-03-04 09:30:27 +00:00
Alexander Uvarov
24faddd60c Move ActiveModel::AttributeMethods#attribute_methods_generated? to ActiveRecord, so it's flexible now
[#6428 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
2011-03-01 20:22:45 +01:00
Jon Leighton
b171b9e73d Move JoinDependency and friends from ActiveRecord::Associations::ClassMethods to just ActiveRecord::Associations 2011-02-28 22:12:43 +00:00