Changeset 5475
- Timestamp:
- 11/09/06 19:36:39 (2 years ago)
- Files:
-
- branches/1-2-pre-release/activerecord/CHANGELOG (modified) (1 diff)
- branches/1-2-pre-release/activerecord/lib/active_record/associations.rb (modified) (1 diff)
- branches/1-2-pre-release/activerecord/lib/active_record/base.rb (modified) (3 diffs)
- branches/1-2-pre-release/activerecord/test/inheritance_test.rb (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1-2-pre-release/activerecord/CHANGELOG
r5460 r5475 1 1 *SVN* 2 3 * Cache inheritance_column. #6592 [Stefan Kaes] 2 4 3 5 * Firebird: decimal/numeric support. #6408 [macrnic] branches/1-2-pre-release/activerecord/lib/active_record/associations.rb
r5446 r5475 1171 1171 sql << "GROUP BY #{options[:group]} " if options[:group] 1172 1172 1173 add_order!(sql, options[:order] )1173 add_order!(sql, options[:order], scope) 1174 1174 add_limit!(sql, options, scope) if using_limitable_reflections?(join_dependency.reflections) 1175 1175 branches/1-2-pre-release/activerecord/lib/active_record/base.rb
r5453 r5475 649 649 end 650 650 651 # Defines the column name for use with single table inheritance -- can be overridden in subclasses. 651 # Defines the column name for use with single table inheritance 652 # -- can be set in subclasses like so: self.inheritance_column = "type_id" 652 653 def inheritance_column 653 "type"654 @inheritance_column ||= "type".freeze 654 655 end 655 656 … … 801 802 def reset_column_information 802 803 read_methods.each { |name| undef_method(name) } 803 @column_names = @columns = @columns_hash = @content_columns = @dynamic_methods_hash = @read_methods = nil804 @column_names = @columns = @columns_hash = @content_columns = @dynamic_methods_hash = @read_methods = @inheritance_column = nil 804 805 end 805 806 … … 1058 1059 # Ignore type if no column is present since it was probably 1059 1060 # pulled in from a sloppy join. 1060 unless self.columns_hash.include?(inheritance_column)1061 unless columns_hash.include?(inheritance_column) 1061 1062 allocate 1062 1063 branches/1-2-pre-release/activerecord/test/inheritance_test.rb
r4848 r5475 31 31 switch_to_alt_inheritance_column 32 32 test_inheritance_find 33 switch_to_default_inheritance_column 33 34 end 34 35 … … 42 43 switch_to_alt_inheritance_column 43 44 test_inheritance_find_all 45 switch_to_default_inheritance_column 44 46 end 45 47 … … 56 58 switch_to_alt_inheritance_column 57 59 test_inheritance_save 60 switch_to_default_inheritance_column 58 61 end 59 62 … … 67 70 switch_to_alt_inheritance_column 68 71 test_inheritance_condition 72 switch_to_default_inheritance_column 69 73 end 70 74 … … 77 81 switch_to_alt_inheritance_column 78 82 test_finding_incorrect_type_data 83 switch_to_default_inheritance_column 79 84 end 80 85 … … 88 93 switch_to_alt_inheritance_column 89 94 test_update_all_within_inheritance 95 switch_to_default_inheritance_column 90 96 end 91 97 … … 99 105 switch_to_alt_inheritance_column 100 106 test_destroy_all_within_inheritance 107 switch_to_default_inheritance_column 101 108 end 102 109 … … 110 117 switch_to_alt_inheritance_column 111 118 test_find_first_within_inheritance 119 switch_to_default_inheritance_column 112 120 end 113 121 … … 125 133 switch_to_alt_inheritance_column 126 134 test_complex_inheritance 135 switch_to_default_inheritance_column 127 136 end 128 137 … … 139 148 c.save 140 149 end 141 142 def Company.inheritance_column() "ruby_type" end 150 [ Company, Firm, Client].each { |klass| klass.reset_column_information } 151 def Company.inheritance_column; @inheritance_column ||= "ruby_type"; end 152 end 153 def switch_to_default_inheritance_column 154 [ Company, Firm, Client].each { |klass| klass.reset_column_information } 143 155 end 144 156 end