Changeset 3092
- Timestamp:
- 11/19/05 09:53:36 (3 years ago)
- Files:
-
- trunk/activerecord/CHANGELOG (modified) (1 diff)
- trunk/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb (modified) (3 diffs)
- trunk/activerecord/test/abstract_unit.rb (modified) (1 diff)
- trunk/activerecord/test/base_test.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/activerecord/CHANGELOG
r3089 r3092 1 1 *SVN* 2 3 * Correct boolean handling in generated reader methods. #2945 [don.park@gmail.com, Stefan Kaes] 2 4 3 5 * Don't generate read methods for columns whose names are not valid ruby method names. #2946 [Stefan Kaes] trunk/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
r2866 r3092 60 60 when :date then self.class.string_to_date(value) 61 61 when :binary then self.class.binary_to_string(value) 62 when :boolean then value == true or (value =~ /^t(rue)?$/i) == 0 or value.to_s == '1'62 when :boolean then self.class.value_to_boolean(value) 63 63 else value 64 64 end … … 76 76 when :date then "#{self.class.name}.string_to_date(#{var_name})" 77 77 when :binary then "#{self.class.name}.binary_to_string(#{var_name})" 78 when :boolean then " (#{var_name} == true or (#{var_name} =~ /^t(?:true)?$/i) == 0 or #{var_name}.to_s == '1')"78 when :boolean then "#{self.class.name}.value_to_boolean(#{var_name})" 79 79 else nil 80 80 end … … 119 119 time_array[0] = 2000; time_array[1] = 1; time_array[2] = 1; 120 120 Time.send(Base.default_timezone, *time_array) rescue nil 121 end 122 123 # convert something to a boolean 124 def self.value_to_boolean(value) 125 return value if value==true || value==false 126 case value.to_s.downcase 127 when "true", "t", "1" then true 128 else false 129 end 121 130 end 122 131 trunk/activerecord/test/abstract_unit.rb
r3051 r3092 25 25 ActiveRecord::Base.connection.instance_of?(ActiveRecord::ConnectionAdapters.const_get(type)) 26 26 end 27 28 #ActiveRecord::Base.logger = Logger.new(STDOUT) 29 #ActiveRecord::Base.colorize_logging = false trunk/activerecord/test/base_test.rb
r3089 r3092 207 207 topic.approved = false 208 208 assert !topic.approved?, "approved should be false" 209 topic.approved = "false" 210 assert !topic.approved?, "approved should be false" 211 end 212 213 def test_read_attribute_when_true 214 topic = topics(:first) 215 topic.approved = true 216 assert topic.approved?, "approved should be true" 217 topic.approved = "true" 218 assert topic.approved?, "approved should be true" 219 end 220 221 def test_read_write_boolean_attribute 222 topic = Topic.new 223 # puts "" 224 # puts "New Topic" 225 # puts topic.inspect 226 topic.approved = "false" 227 # puts "Expecting false" 228 # puts topic.inspect 229 assert !topic.approved, "approved should be false" 230 topic.approved = "false" 231 # puts "Expecting false" 232 # puts topic.inspect 233 assert !topic.approved, "approved should be false" 234 topic.approved = "true" 235 # puts "Expecting true" 236 # puts topic.inspect 237 assert topic.approved, "approved should be true" 238 topic.approved = "true" 239 # puts "Expecting true" 240 # puts topic.inspect 241 assert topic.approved, "approved should be true" 242 # puts "" 209 243 end 210 244