mysql2 0.4.3-x86-mingw32 → 0.4.4-x86-mingw32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9ae0dc4acab2906f732e22ca63a48e6b747e67d1
4
- data.tar.gz: ac760550b67d08b9b382a6df213b19b00f989dc3
3
+ metadata.gz: 0ace3bf3cdcf7ef0b26f56a0f8fe03fdc2b3e73c
4
+ data.tar.gz: daa4f6245c87aa76541b109c5fdada3e8e32151c
5
5
  SHA512:
6
- metadata.gz: 68372344c7f42c9382b45c712476f1fbf8f1819d3c83f99b1bc56eeac77ac08c2dece0e5fc9ff4d14743172f0a1ff3a1951864b0aca904f267c8b98969321bdc
7
- data.tar.gz: a784533f6d64d4ad652bd2361574634f8b7a45c44ff7a8c1b1f14192f8f7d7e5a77d8fb27fa7f62db42ebd3dbf8ef59ab4cd825a6798acbc36d5cc6454d2b610
6
+ metadata.gz: 51d2f7395264866d6bc6efbc6dcf0b5bd440230bae9896ae3add5d14402c05c0b9abf68c4464ef4ea06542225fc4b634f8f8437314855d6cdccf30b6b5cdc464
7
+ data.tar.gz: c366ede723d32365a539d0dd35fb6b4bcb0f01f0189e6e3df3e1775ccc1280ffd66f921eca34fa416164542e62e820788e06e5c5fe92050f7c6770c0e31e2e3a
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-mingw32
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: