mysql2 0.3.4 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,8 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.5 (June 15th, 2011)
4
+ * bug fix for Time/DateTime usage depending on 32/64bit Ruby
5
+
3
6
  ## 0.3.4 (June 15th, 2011)
4
7
  * fix a long standing bug where a signal would interrupt rb_thread_select and put the connection in a permanently broken state
5
8
  * turn on casting in the ActiveRecord again, users can disable it if they need to for performance reasons
@@ -4,13 +4,26 @@
4
4
  static rb_encoding *binaryEncoding;
5
5
  #endif
6
6
 
7
- #define MYSQL2_MAX_YEAR 2038
7
+ #if SIZEOF_INT < SIZEOF_LONG
8
+ /**
9
+ * on 64bit platforms we can handle dates way outside 2038-01-19T03:14:07
10
+ * because of how I'm performing the math below, this will allow a maximum
11
+ * timestamp of 9846-12-12T11:5999:59
12
+ */
13
+ #define MYSQL2_MAX_YEAR 9999
14
+ #else
15
+ /**
16
+ * on 32bit platforms the maximum date the Time class can handle is 2038-01-19T03:14:07
17
+ * 2082 = 2038+1+19+3+14+7
18
+ */
19
+ #define MYSQL2_MAX_YEAR 2082
20
+ #endif
8
21
 
9
22
  #ifdef NEGATIVE_TIME_T
10
- /* 1901-12-13 20:45:52 UTC : The oldest time in 32-bit signed time_t. */
23
+ /* 1901-12-13 20:45:52 UTC : The oldest time in 32-bit signed time_t. */
11
24
  #define MYSQL2_MIN_YEAR 1902
12
25
  #else
13
- /* 1970-01-01 00:00:00 UTC : The Unix epoch - the oldest time in portable time_t. */
26
+ /* 1970-01-01 00:00:00 UTC : The Unix epoch - the oldest time in portable time_t. */
14
27
  #define MYSQL2_MIN_YEAR 1970
15
28
  #endif
16
29
 
@@ -240,7 +253,7 @@ static VALUE rb_mysql_result_fetch_row(VALUE self, ID db_timezone, ID app_timezo
240
253
  rb_raise(cMysql2Error, "Invalid date: %s", row[i]);
241
254
  val = Qnil;
242
255
  } else {
243
- if (year < MYSQL2_MIN_YEAR || year+month+day > MYSQL2_MAX_YEAR) { // use DateTime instead
256
+ if (year < MYSQL2_MIN_YEAR || year+month+day+hour+min+sec > MYSQL2_MAX_YEAR) { // use DateTime instead
244
257
  VALUE offset = INT2NUM(0);
245
258
  if (db_timezone == intern_local) {
246
259
  offset = rb_funcall(cMysql2Client, intern_local_offset, 0);
@@ -1,3 +1,3 @@
1
1
  module Mysql2
2
- VERSION = "0.3.4"
2
+ VERSION = "0.3.5"
3
3
  end
@@ -189,9 +189,18 @@ describe Mysql2::Result do
189
189
  r.first['test'].class.should eql(DateTime)
190
190
  end
191
191
 
192
- it "should return DateTime when time > year 2038" do
193
- r = @client.query("SELECT CAST('2039-01-01 01:01:01' AS DATETIME) as test")
194
- r.first['test'].class.should eql(DateTime)
192
+ if 1.size == 4 # 32bit
193
+ it "should return DateTime when timestamp is > 2038-01-19T03:14:07" do
194
+ # 2038-01-19T03:14:07 is the max for 32bit Ruby 1.8
195
+ r = @client.query("SELECT CAST('2038-01-19 03:14:08' AS DATETIME) as test")
196
+ r.first['test'].class.should eql(DateTime)
197
+ end
198
+ elsif 1.size == 8 # 64bit
199
+ it "should return Time when timestamp is > 2038-01-19T03:14:07" do
200
+ # 2038-01-19 03:14:07 is the max for 32bit Ruby 1.8
201
+ r = @client.query("SELECT CAST('2038-01-19 03:14:08' AS DATETIME) as test")
202
+ r.first['test'].class.should eql(Time)
203
+ end
195
204
  end
196
205
 
197
206
  it "should return Time for a TIMESTAMP value when within the supported range" do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mysql2
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 4
10
- version: 0.3.4
9
+ - 5
10
+ version: 0.3.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Brian Lopez