mysql2 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.8 (June 2nd, 2010)
4
+ * fixes for AR adapter for timezone juggling
5
+ * fixes to be able to run benchmarks and specs under 1.9.2
6
+
3
7
  ## 0.1.7 (May 22nd, 2010)
4
8
  * fix a bug when using the disconnect! method on a closed connection in the AR driver
5
9
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.7
1
+ 0.1.8
@@ -1,4 +1,5 @@
1
1
  # encoding: UTF-8
2
+ $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/..')
2
3
  $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
3
4
 
4
5
  require 'rubygems'
@@ -1,4 +1,5 @@
1
1
  # encoding: UTF-8
2
+ $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/..')
2
3
 
3
4
  require 'rubygems'
4
5
  require 'benchmark'
@@ -1,4 +1,5 @@
1
1
  # encoding: UTF-8
2
+ $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/..')
2
3
 
3
4
  require 'rubygems'
4
5
  require 'benchmark'
@@ -1,4 +1,5 @@
1
1
  # encoding: UTF-8
2
+ $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/..')
2
3
 
3
4
  require 'rubygems'
4
5
  require 'benchmark'
@@ -1,4 +1,5 @@
1
1
  # encoding: UTF-8
2
+ $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/..')
2
3
  $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
3
4
 
4
5
  require 'rubygems'
@@ -1,4 +1,5 @@
1
1
  # encoding: UTF-8
2
+ $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/..')
2
3
 
3
4
  # This script is for generating psudo-random data into a single table consisting of nearly every
4
5
  # data type MySQL 5.1 supports.
@@ -550,7 +550,7 @@ static VALUE rb_mysql_result_fetch_row(int argc, VALUE * argv, VALUE self) {
550
550
  case MYSQL_TYPE_TIME: { // TIME field
551
551
  int hour, min, sec, tokens;
552
552
  tokens = sscanf(row[i], "%2d:%2d:%2d", &hour, &min, &sec);
553
- val = rb_funcall(rb_cTime, intern_local, 6, INT2NUM(0), INT2NUM(1), INT2NUM(1), INT2NUM(hour), INT2NUM(min), INT2NUM(sec));
553
+ val = rb_funcall(rb_cTime, intern_utc, 6, INT2NUM(0), INT2NUM(1), INT2NUM(1), INT2NUM(hour), INT2NUM(min), INT2NUM(sec));
554
554
  break;
555
555
  }
556
556
  case MYSQL_TYPE_TIMESTAMP: // TIMESTAMP field
@@ -564,7 +564,7 @@ static VALUE rb_mysql_result_fetch_row(int argc, VALUE * argv, VALUE self) {
564
564
  rb_raise(cMysql2Error, "Invalid date: %s", row[i]);
565
565
  val = Qnil;
566
566
  } else {
567
- val = rb_funcall(rb_cTime, intern_local, 6, INT2NUM(year), INT2NUM(month), INT2NUM(day), INT2NUM(hour), INT2NUM(min), INT2NUM(sec));
567
+ val = rb_funcall(rb_cTime, intern_utc, 6, INT2NUM(year), INT2NUM(month), INT2NUM(day), INT2NUM(hour), INT2NUM(min), INT2NUM(sec));
568
568
  }
569
569
  }
570
570
  break;
@@ -721,7 +721,7 @@ void Init_mysql2_ext() {
721
721
  rb_include_module(cMysql2Result, mEnumerable);
722
722
 
723
723
  intern_new = rb_intern("new");
724
- intern_local = rb_intern("local");
724
+ intern_utc = rb_intern("utc");
725
725
 
726
726
  sym_symbolize_keys = ID2SYM(rb_intern("symbolize_keys"));
727
727
  sym_reconnect = ID2SYM(rb_intern("reconnect"));
@@ -25,7 +25,7 @@ static int utf8Encoding, binaryEncoding;
25
25
  #endif
26
26
 
27
27
  static VALUE cBigDecimal, cDate, cDateTime;
28
- static ID intern_new, intern_local;
28
+ static ID intern_new, intern_utc;
29
29
 
30
30
  /* Mysql2::Error */
31
31
  static VALUE cMysql2Error;
@@ -57,8 +57,8 @@ module ActiveRecord
57
57
  when :integer then value.to_i rescue value ? 1 : 0
58
58
  when :float then value.to_f # returns self if it's already a Float
59
59
  when :decimal then self.class.value_to_decimal(value)
60
- when :datetime, :timestamp then value.class == Time ? value : self.class.string_to_time(value)
61
- when :time then value.class == Time ? value : self.class.string_to_dummy_time(value)
60
+ when :datetime, :timestamp then value.class == Time ? value.in_time_zone : self.class.string_to_time(value)
61
+ when :time then value.class == Time ? value.in_time_zone : self.class.string_to_dummy_time(value)
62
62
  when :date then value.class == Date ? value : self.class.string_to_date(value)
63
63
  when :binary then value
64
64
  when :boolean then self.class.value_to_boolean(value)
@@ -73,8 +73,8 @@ module ActiveRecord
73
73
  when :integer then "#{var_name}.to_i rescue #{var_name} ? 1 : 0"
74
74
  when :float then "#{var_name}.to_f"
75
75
  when :decimal then "#{self.class.name}.value_to_decimal(#{var_name})"
76
- when :datetime, :timestamp then "#{var_name}.class == Time ? #{var_name} : #{self.class.name}.string_to_time(#{var_name})"
77
- when :time then "#{var_name}.class == Time ? #{var_name} : #{self.class.name}.string_to_dummy_time(#{var_name})"
76
+ when :datetime, :timestamp then "#{var_name}.class == Time ? #{var_name}.in_time_zone : #{self.class.name}.string_to_time(#{var_name})"
77
+ when :time then "#{var_name}.class == Time ? #{var_name}.in_time_zone : #{self.class.name}.string_to_dummy_time(#{var_name})"
78
78
  when :date then "#{var_name}.class == Date ? #{var_name} : #{self.class.name}.string_to_date(#{var_name})"
79
79
  when :binary then nil
80
80
  when :boolean then "#{self.class.name}.value_to_boolean(#{var_name})"
@@ -5,5 +5,5 @@ require 'mysql2_ext'
5
5
  #
6
6
  # A modern, simple and very fast Mysql library for Ruby - binding to libmysql
7
7
  module Mysql2
8
- VERSION = "0.1.7"
8
+ VERSION = "0.1.8"
9
9
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{mysql2}
8
- s.version = "0.1.7"
8
+ s.version = "0.1.8"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Brian Lopez"]
12
- s.date = %q{2010-05-22}
12
+ s.date = %q{2010-06-02}
13
13
  s.email = %q{seniorlopez@gmail.com}
14
14
  s.extensions = ["ext/extconf.rb"]
15
15
  s.extra_rdoc_files = [
@@ -27,6 +27,7 @@ describe ActiveRecord::ConnectionAdapters::Mysql2Adapter do
27
27
 
28
28
  context "columns" do
29
29
  before(:all) do
30
+ ActiveRecord::Base.default_timezone = 'Pacific Time (US & Canada)'
30
31
  ActiveRecord::Base.establish_connection(:adapter => 'mysql2', :database => 'test')
31
32
  Mysql2Test2.connection.execute %[
32
33
  CREATE TABLE IF NOT EXISTS mysql2_test2 (
@@ -86,9 +87,9 @@ describe ActiveRecord::ConnectionAdapters::Mysql2Adapter do
86
87
  test.double_test.should eql('1.0000'.to_f)
87
88
  test.decimal_test.should eql(BigDecimal.new('1.0000'))
88
89
  test.date_test.should eql(Date.parse('2010-01-01'))
89
- test.date_time_test.should eql(Time.parse('2010-01-01 00:00:00'))
90
+ test.date_time_test.should eql(DateTime.parse('2010-01-01 00:00:00'))
90
91
  test.timestamp_test.should be_nil
91
- test.time_test.class.should eql(Time)
92
+ test.time_test.class.should eql(DateTime)
92
93
  test.year_test.should eql(2010)
93
94
  test.char_test.should eql('abcdefghij')
94
95
  test.varchar_test.should eql('abcdefghij')
@@ -122,9 +123,9 @@ describe ActiveRecord::ConnectionAdapters::Mysql2Adapter do
122
123
  test.double_test.should eql('1.0000'.to_f)
123
124
  test.decimal_test.should eql(BigDecimal.new('1.0000'))
124
125
  test.date_test.should eql(Date.parse('2010-01-01'))
125
- test.date_time_test.should eql(Time.parse('2010-01-01 00:00:00'))
126
- test.timestamp_test.class.should eql(Time)
127
- test.time_test.class.should eql(Time)
126
+ test.date_time_test.should eql(DateTime.parse('2010-01-01 00:00:00'))
127
+ test.timestamp_test.class.should eql(ActiveSupport::TimeWithZone)
128
+ test.time_test.class.should eql(ActiveSupport::TimeWithZone)
128
129
  test.year_test.should eql(2010)
129
130
  test.char_test.should eql('abcdefghij')
130
131
  test.varchar_test.should eql('abcdefghij')
@@ -176,7 +176,11 @@ describe Mysql2::Result do
176
176
 
177
177
  it "should return Time for a TIME value" do
178
178
  @test_result['time_test'].class.should eql(Time)
179
- @test_result['time_test'].strftime("%F %T").should eql('2000-01-01 11:44:00')
179
+ if RUBY_VERSION =~ /1.9.2/
180
+ @test_result['time_test'].strftime("%F %T").should eql('0000-01-01 11:44:00')
181
+ else
182
+ @test_result['time_test'].strftime("%F %T").should eql('2000-01-01 11:44:00')
183
+ end
180
184
  end
181
185
 
182
186
  it "should return Date for a DATE value" do
@@ -1,4 +1,5 @@
1
1
  # encoding: UTF-8
2
+ $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/..')
2
3
  $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
3
4
 
4
5
  require 'mysql2'
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 7
9
- version: 0.1.7
8
+ - 8
9
+ version: 0.1.8
10
10
  platform: ruby
11
11
  authors:
12
12
  - Brian Lopez
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-05-22 00:00:00 -07:00
17
+ date: 2010-06-02 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies: []
20
20