mysql2 0.4.3-x86-mswin32-60 → 0.4.4-x86-mswin32-60

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1675b29f46f0d2fb95871b2e02dfd7b54ae67961
4
- data.tar.gz: dfdc07c1b462ce463ce76bff22efcd5e023c3b0a
3
+ metadata.gz: 8d3d89002871b3e2ffd20a2806da903df2c91be5
4
+ data.tar.gz: fab5958163645e803b127f4dbf3aa36dc4cada80
5
5
  SHA512:
6
- metadata.gz: d413f98ad2026ea69c45e6c82336c66568bffe8c56b8acdbfb0c977720890151eb5aaa7df7cd7ee5e5ffa417c5144294812c0aa9039f33cf68795a928df27c4d
7
- data.tar.gz: 9ac615edf2e19d3ddaad7dd251810992a6ad08230e594957f8af5ed2735e5640c8595799edcfadf26e36cedcdab4e27dd767b4880649f545c2f1883593282697
6
+ metadata.gz: 4d0457807e8e41d263fbba7b3ef465e9786311e8cccbaf0f1782f75870f5e97f204fb753e222f61efcc93a4856a7049474295afbdf4ca883af714a3e346140cf
7
+ data.tar.gz: 0549007b62a4353d439c57a1aee1206c39ca1013e7e56965ff96fb70836eebbeb0654b1a6cece0b330fdaf2e02ff9a7527e11464847eb2b08b1acc75dc767955
data/README.md CHANGED
@@ -484,9 +484,9 @@ As for field values themselves, I'm workin on it - but expect that soon.
484
484
 
485
485
  This gem is tested with the following Ruby versions on Linux and Mac OS X:
486
486
 
487
- * Ruby MRI 1.8.7, 1.9.3, 2.0.0, 2.1.x, 2.2.x
487
+ * Ruby MRI 1.8.7, 1.9.3, 2.0.0, 2.1.x, 2.2.x, 2.3.x
488
488
  * Ruby Enterprise Edition (based on MRI 1.8.7)
489
- * Rubinius 2.x
489
+ * Rubinius 2.x, 3.x
490
490
 
491
491
  This gem is tested with the following MySQL and MariaDB versions:
492
492
 
@@ -494,11 +494,11 @@ This gem is tested with the following MySQL and MariaDB versions:
494
494
  * MySQL Connector/C 6.0 and 6.1 (primarily on Windows)
495
495
  * MariaDB 5.5, 10.0, 10.1
496
496
 
497
- ### Rails / Active Record
497
+ ### Ruby on Rails / Active Record
498
498
 
499
- * mysql2 0.4.x works with Active Record 4.2.5 and higher.
500
- * mysql2 0.3.x works with Active Record 3.1 and higher (the AR adapter is now included in AR proper).
501
- * mysql2 0.2.x includes an Active Record adapter compatible with AR 2.3 and 3.0, and should not be used with AR 3.1 or higher.
499
+ * mysql2 0.4.x works with Rails / Active Record 4.2.5 - 5.0 and higher.
500
+ * mysql2 0.3.x works with Rails / Active Record 3.1, 3.2, 4.x, 5.0.
501
+ * mysql2 0.2.x works with Rails / Active Record 2.3 - 3.0.
502
502
 
503
503
  ### Asynchronous Active Record
504
504
 
@@ -346,15 +346,15 @@ static VALUE rb_mysql_result_fetch_row_stmt(VALUE self, MYSQL_FIELD * fields, co
346
346
  conn_enc = rb_to_encoding(wrapper->encoding);
347
347
  #endif
348
348
 
349
+ if (wrapper->fields == Qnil) {
350
+ wrapper->numberOfFields = mysql_num_fields(wrapper->result);
351
+ wrapper->fields = rb_ary_new2(wrapper->numberOfFields);
352
+ }
349
353
  if (args->asArray) {
350
354
  rowVal = rb_ary_new2(wrapper->numberOfFields);
351
355
  } else {
352
356
  rowVal = rb_hash_new();
353
357
  }
354
- if (wrapper->fields == Qnil) {
355
- wrapper->numberOfFields = mysql_num_fields(wrapper->result);
356
- wrapper->fields = rb_ary_new2(wrapper->numberOfFields);
357
- }
358
358
 
359
359
  if (wrapper->result_buffers == NULL) {
360
360
  rb_mysql_result_alloc_result_buffers(self, fields);
@@ -541,16 +541,16 @@ static VALUE rb_mysql_result_fetch_row(VALUE self, MYSQL_FIELD * fields, const r
541
541
  return Qnil;
542
542
  }
543
543
 
544
+ if (wrapper->fields == Qnil) {
545
+ wrapper->numberOfFields = mysql_num_fields(wrapper->result);
546
+ wrapper->fields = rb_ary_new2(wrapper->numberOfFields);
547
+ }
544
548
  if (args->asArray) {
545
549
  rowVal = rb_ary_new2(wrapper->numberOfFields);
546
550
  } else {
547
551
  rowVal = rb_hash_new();
548
552
  }
549
553
  fieldLengths = mysql_fetch_lengths(wrapper->result);
550
- if (wrapper->fields == Qnil) {
551
- wrapper->numberOfFields = mysql_num_fields(wrapper->result);
552
- wrapper->fields = rb_ary_new2(wrapper->numberOfFields);
553
- }
554
554
 
555
555
  for (i = 0; i < wrapper->numberOfFields; i++) {
556
556
  VALUE field = rb_mysql_result_fetch_field(self, i, args->symbolizeKeys);
@@ -834,7 +834,9 @@ static VALUE rb_mysql_result_each_(VALUE self,
834
834
 
835
835
  if (row == Qnil) {
836
836
  /* we don't need the mysql C dataset around anymore, peace it */
837
- rb_mysql_result_free_result(wrapper);
837
+ if (args->cacheRows) {
838
+ rb_mysql_result_free_result(wrapper);
839
+ }
838
840
  return Qnil;
839
841
  }
840
842
 
@@ -842,7 +844,7 @@ static VALUE rb_mysql_result_each_(VALUE self,
842
844
  rb_yield(row);
843
845
  }
844
846
  }
845
- if (wrapper->lastRowProcessed == wrapper->numberOfRows) {
847
+ if (wrapper->lastRowProcessed == wrapper->numberOfRows && args->cacheRows) {
846
848
  /* we don't need the mysql C dataset around anymore, peace it */
847
849
  rb_mysql_result_free_result(wrapper);
848
850
  }
@@ -886,6 +888,7 @@ static VALUE rb_mysql_result_each(int argc, VALUE * argv, VALUE self) {
886
888
 
887
889
  if (wrapper->stmt_wrapper && !cacheRows && !wrapper->is_streaming) {
888
890
  rb_warn(":cache_rows is forced for prepared statements (if not streaming)");
891
+ cacheRows = 1;
889
892
  }
890
893
 
891
894
  if (wrapper->stmt_wrapper && !cast) {
@@ -913,13 +916,12 @@ static VALUE rb_mysql_result_each(int argc, VALUE * argv, VALUE self) {
913
916
  app_timezone = Qnil;
914
917
  }
915
918
 
916
- if (wrapper->lastRowProcessed == 0 && !wrapper->is_streaming) {
919
+ if (wrapper->rows == Qnil && !wrapper->is_streaming) {
917
920
  wrapper->numberOfRows = wrapper->stmt_wrapper ? mysql_stmt_num_rows(wrapper->stmt_wrapper->stmt) : mysql_num_rows(wrapper->result);
918
- if (wrapper->numberOfRows == 0) {
919
- rb_mysql_result_free_result(wrapper);
920
- wrapper->rows = rb_ary_new();
921
- return wrapper->rows;
922
- }
921
+ wrapper->rows = rb_ary_new2(wrapper->numberOfRows);
922
+ } else if (wrapper->rows && !cacheRows) {
923
+ mysql_data_seek(wrapper->result, 0);
924
+ wrapper->lastRowProcessed = 0;
923
925
  wrapper->rows = rb_ary_new2(wrapper->numberOfRows);
924
926
  }
925
927
 
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -1,3 +1,3 @@
1
1
  module Mysql2
2
- VERSION = "0.4.3"
2
+ VERSION = "0.4.4"
3
3
  end
@@ -382,24 +382,24 @@ RSpec.describe Mysql2::Client do
382
382
 
383
383
  it "should expect connect_timeout to be a positive integer" do
384
384
  expect {
385
- Mysql2::Client.new(:connect_timeout => -1)
385
+ Mysql2::Client.new(DatabaseCredentials['root'].merge(:connect_timeout => -1))
386
386
  }.to raise_error(Mysql2::Error)
387
387
  end
388
388
 
389
389
  it "should expect read_timeout to be a positive integer" do
390
390
  expect {
391
- Mysql2::Client.new(:read_timeout => -1)
391
+ Mysql2::Client.new(DatabaseCredentials['root'].merge(:read_timeout => -1))
392
392
  }.to raise_error(Mysql2::Error)
393
393
  end
394
394
 
395
395
  it "should expect write_timeout to be a positive integer" do
396
396
  expect {
397
- Mysql2::Client.new(:write_timeout => -1)
397
+ Mysql2::Client.new(DatabaseCredentials['root'].merge(:write_timeout => -1))
398
398
  }.to raise_error(Mysql2::Error)
399
399
  end
400
400
 
401
401
  it "should allow nil read_timeout" do
402
- client = Mysql2::Client.new(:read_timeout => nil)
402
+ client = Mysql2::Client.new(DatabaseCredentials['root'].merge(:read_timeout => nil))
403
403
 
404
404
  expect(client.read_timeout).to be_nil
405
405
  end
@@ -82,6 +82,11 @@ RSpec.describe Mysql2::Result do
82
82
  expect(result.first.object_id).not_to eql(result.first.object_id)
83
83
  end
84
84
 
85
+ it "should be able to iterate a second time even if cache_rows is disabled" do
86
+ result = @client.query "SELECT 1 UNION SELECT 2", :cache_rows => false
87
+ expect(result.to_a).to eql(result.to_a)
88
+ end
89
+
85
90
  it "should yield different value for #first if streaming" do
86
91
  result = @client.query "SELECT 1 UNION SELECT 2", :stream => true, :cache_rows => false
87
92
  expect(result.first).not_to eql(result.first)
@@ -128,6 +128,14 @@ RSpec.describe Mysql2::Statement do
128
128
  expect(test_result['decimal_test']).to eql(123.45)
129
129
  end
130
130
 
131
+ it "should warn but still work if cache_rows is set to false" do
132
+ @client.query_options.merge!(:cache_rows => false)
133
+ statement = @client.prepare 'SELECT 1'
134
+ result = nil
135
+ expect { result = statement.execute.to_a }.to output(/:cache_rows is forced for prepared statements/).to_stderr
136
+ expect(result.length).to eq(1)
137
+ end
138
+
131
139
  context "utf8_db" do
132
140
  before(:each) do
133
141
  @client.query("DROP DATABASE IF EXISTS test_mysql2_stmt_utf8")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mysql2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.4
5
5
  platform: x86-mswin32-60
6
6
  authors:
7
7
  - Brian Lopez
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-02-24 00:00:00.000000000 Z
12
+ date: 2016-04-19 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description:
15
15
  email: