Changeset 40
- Timestamp:
- 12/01/04 13:18:51 (4 years ago)
- Files:
-
- trunk/activerecord/CHANGELOG (modified) (1 diff)
- trunk/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb (modified) (4 diffs)
- trunk/activerecord/test/base_test.rb (modified) (3 diffs)
- trunk/activerecord/test/fixtures/db_definitions/mysql.sql (modified) (1 diff)
- trunk/activerecord/test/fixtures/db_definitions/postgresql.sql (modified) (1 diff)
- trunk/activerecord/test/fixtures/db_definitions/sqlite.sql (modified) (1 diff)
- trunk/activerecord/test/fixtures/topics/first (modified) (1 diff)
- trunk/activerecord/test/reflection_test.rb (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/activerecord/CHANGELOG
r38 r40 1 1 *CVS* 2 3 * Added proper handling of time fields that are turned into Time objects with the dummy date of 2000/1/1 [HariSeldon] 2 4 3 5 * Added reverse order of deleting fixtures, so referential keys can be maintained #247 [Tim Bates] trunk/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
r35 r40 183 183 when :datetime then Time 184 184 when :date then Date 185 when :time then Time 185 186 when :text, :string then String 186 187 when :boolean then Object … … 196 197 when :float then value.to_f 197 198 when :datetime then string_to_time(value) 199 when :time then string_to_dummy_time(value) 198 200 when :date then string_to_date(value) 199 201 when :boolean then (value == "t" or value == true ? true : false) … … 221 223 end 222 224 225 def string_to_dummy_time(string) 226 return string if Time === string 227 time_array = ParseDate.parsedate(string) 228 # pad the resulting array with dummy date information 229 time_array[0] = 2000; time_array[1] = 1; time_array[2] = 1; 230 Time.local(*time_array) rescue nil 231 end 232 223 233 def extract_limit(sql_type) 224 234 $1.to_i if sql_type =~ /\((.*)\)/ … … 231 241 when /float|double|decimal|numeric/i 232 242 :float 233 when / time/i243 when /datetime/i 234 244 :datetime 245 when /time/i 246 :time 235 247 when /date/i 236 248 :date trunk/activerecord/test/base_test.rb
r4 r40 148 148 "The last_read attribute should be of the Date class" 149 149 ) 150 151 assert_kind_of( 152 Time, Topic.find(1).bonus_time, 153 "The bonus_time attribute should be of the Time class" 154 ) 150 155 end 151 156 … … 312 317 assert_equal 1, topic.approved 313 318 assert_nil topic.written_on 319 assert_nil topic.bonus_time 314 320 assert_nil topic.last_read 315 321 … … 425 431 topic.attributes = attributes 426 432 assert_equal Time.local(2004, 6, 24, 16, 24, 0), topic.written_on 433 end 434 435 def test_attributes_on_dummy_time 436 attributes = { 437 "bonus_time" => "5:42:00AM" 438 } 439 topic = Topic.find(1) 440 topic.attributes = attributes 441 assert_equal Time.local(2000, 1, 1, 5, 42, 0), topic.bonus_time 427 442 end 428 443 trunk/activerecord/test/fixtures/db_definitions/mysql.sql
r4 r40 24 24 `author_email_address` varchar(255) default NULL, 25 25 `written_on` datetime default NULL, 26 `bonus_time` time default NULL, 26 27 `last_read` date default NULL, 27 28 `content` text, trunk/activerecord/test/fixtures/db_definitions/postgresql.sql
r4 r40 47 47 author_email_address character varying(255), 48 48 written_on timestamp without time zone, 49 bonus_time time, 49 50 last_read date, 50 51 content text, trunk/activerecord/test/fixtures/db_definitions/sqlite.sql
r4 r40 22 22 'author_email_address' VARCHAR(255) DEFAULT NULL, 23 23 'written_on' DATETIME DEFAULT NULL, 24 'bonus_time' TIME DEFAULT NULL, 24 25 'last_read' DATE DEFAULT NULL, 25 26 'content' TEXT, trunk/activerecord/test/fixtures/topics/first
r4 r40 4 4 author_email_address => david@loudthinking.com 5 5 written_on => 2003-07-16 15:28 6 bonus_time => 12:13:14 6 7 last_read => 2004-04-15 7 8 content => Have a nice day trunk/activerecord/test/reflection_test.rb
r4 r40 16 16 def test_read_attribute_names 17 17 assert_equal( 18 %w( id title author_name author_email_address written_on last_read content approved replies_count parent_id type ).sort,18 %w( id title author_name author_email_address bonus_time written_on last_read content approved replies_count parent_id type ).sort, 19 19 @first.attribute_names 20 20 ) … … 22 22 23 23 def test_columns 24 assert_equal 1 1, Topic.columns.length24 assert_equal 12, Topic.columns.length 25 25 end 26 26 27 27 def test_content_columns 28 assert_equal 7, Topic.content_columns.length28 assert_equal 8, Topic.content_columns.length 29 29 end 30 30