From 5e4080e4e56580c212f6991cbd69360752d2b3db Mon Sep 17 00:00:00 2001 From: Brian Lopez Date: Thu, 22 Apr 2010 12:37:05 -0700 Subject: [PATCH] Revert "for DATE columns, return ruby Date object instead of Time (didn't realize I could create them from y,m,d integers without ActiveSupport)" The Date class is sooooo sllooowwww :) Will probably look into bringing in http://github.com/rtomayko/date-performance at some point. This reverts commit 51babb3362d36ceb6a701ae67c0b625a5f421ede. --- ext/mysql2_ext.c | 2 +- lib/active_record/connection_adapters/mysql2_adapter.rb | 2 +- spec/mysql2/result_spec.rb | 9 +-------- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/ext/mysql2_ext.c b/ext/mysql2_ext.c index 4ec401f..0f2b02a 100644 --- a/ext/mysql2_ext.c +++ b/ext/mysql2_ext.c @@ -393,7 +393,7 @@ static VALUE rb_mysql_result_fetch_row(int argc, VALUE * argv, VALUE self) { val = Qnil; } else { strptime(row[i], "%F", &parsedTime); - val = rb_funcall(cDate, intern_new, 3, INT2NUM(1900+parsedTime.tm_year), INT2NUM(parsedTime.tm_mon+1), INT2NUM(parsedTime.tm_mday)); + val = rb_funcall(rb_cTime, intern_local, 3, INT2NUM(1900+parsedTime.tm_year), INT2NUM(parsedTime.tm_mon+1), INT2NUM(parsedTime.tm_mday)); } break; case MYSQL_TYPE_TINY_BLOB: diff --git a/lib/active_record/connection_adapters/mysql2_adapter.rb b/lib/active_record/connection_adapters/mysql2_adapter.rb index af7666a..6e2784d 100644 --- a/lib/active_record/connection_adapters/mysql2_adapter.rb +++ b/lib/active_record/connection_adapters/mysql2_adapter.rb @@ -21,7 +21,7 @@ module ActiveRecord when :float then Float when :decimal then BigDecimal when :datetime then Time - when :date then Date + when :date then Time when :timestamp then Time when :time then Time when :text, :string then String diff --git a/spec/mysql2/result_spec.rb b/spec/mysql2/result_spec.rb index fa63608..b2b2623 100644 --- a/spec/mysql2/result_spec.rb +++ b/spec/mysql2/result_spec.rb @@ -140,6 +140,7 @@ describe Mysql2::Result do end { + 'date_test' => 'DATE', 'date_time_test' => 'DATETIME', 'timestamp_test' => 'TIMESTAMP', 'time_test' => 'TIME' @@ -149,14 +150,6 @@ describe Mysql2::Result do end end - { - 'date_test' => 'DATE' - }.each do |field, type| - it "should return a Date for #{type}" do - @test_result[field].class.should eql(Date) - end - end - { 'char_test' => 'CHAR', 'varchar_test' => 'VARCHAR',