mysql2 0.4.6-x86-mingw32 → 0.4.7-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,11 +3,9 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  RSpec.describe Mysql2::Error do
6
- let(:client) { Mysql2::Client.new(DatabaseCredentials['root']) }
7
-
8
6
  let(:error) do
9
7
  begin
10
- client.query("HAHAHA")
8
+ @client.query("HAHAHA")
11
9
  rescue Mysql2::Error => e
12
10
  error = e
13
11
  end
@@ -28,7 +26,7 @@ RSpec.describe Mysql2::Error do
28
26
  let(:valid_utf8) { '造字' }
29
27
  let(:error) do
30
28
  begin
31
- client.query(valid_utf8)
29
+ @client.query(valid_utf8)
32
30
  rescue Mysql2::Error => e
33
31
  e
34
32
  end
@@ -37,7 +35,7 @@ RSpec.describe Mysql2::Error do
37
35
  let(:invalid_utf8) { ["e5c67d1f"].pack('H*').force_encoding(Encoding::UTF_8) }
38
36
  let(:bad_err) do
39
37
  begin
40
- client.query(invalid_utf8)
38
+ @client.query(invalid_utf8)
41
39
  rescue Mysql2::Error => e
42
40
  e
43
41
  end
@@ -153,18 +153,16 @@ RSpec.describe Mysql2::Result do
153
153
  end
154
154
 
155
155
  it "should raise an exception if streaming ended due to a timeout" do
156
- # Create an extra client instance, since we're going to time it out
157
- client = Mysql2::Client.new DatabaseCredentials['root']
158
- client.query "CREATE TEMPORARY TABLE streamingTest (val BINARY(255)) ENGINE=MEMORY"
156
+ @client.query "CREATE TEMPORARY TABLE streamingTest (val BINARY(255)) ENGINE=MEMORY"
159
157
 
160
158
  # Insert enough records to force the result set into multiple reads
161
159
  # (the BINARY type is used simply because it forces full width results)
162
160
  10000.times do |i|
163
- client.query "INSERT INTO streamingTest (val) VALUES ('Foo #{i}')"
161
+ @client.query "INSERT INTO streamingTest (val) VALUES ('Foo #{i}')"
164
162
  end
165
163
 
166
- client.query "SET net_write_timeout = 1"
167
- res = client.query "SELECT * FROM streamingTest", :stream => true, :cache_rows => false
164
+ @client.query "SET net_write_timeout = 1"
165
+ res = @client.query "SELECT * FROM streamingTest", :stream => true, :cache_rows => false
168
166
 
169
167
  expect {
170
168
  res.each_with_index do |_, i|
@@ -367,10 +365,9 @@ RSpec.describe Mysql2::Result do
367
365
  result = @client.query("SELECT * FROM mysql2_test ORDER BY id DESC LIMIT 1").first
368
366
  expect(result['enum_test'].encoding).to eql(Encoding::UTF_8)
369
367
 
370
- client2 = Mysql2::Client.new(DatabaseCredentials['root'].merge(:encoding => 'ascii'))
368
+ client2 = new_client(:encoding => 'ascii')
371
369
  result = client2.query("SELECT * FROM mysql2_test ORDER BY id DESC LIMIT 1").first
372
370
  expect(result['enum_test'].encoding).to eql(Encoding::ASCII)
373
- client2.close
374
371
  end
375
372
  end
376
373
 
@@ -400,10 +397,9 @@ RSpec.describe Mysql2::Result do
400
397
  result = @client.query("SELECT * FROM mysql2_test ORDER BY id DESC LIMIT 1").first
401
398
  expect(result['set_test'].encoding).to eql(Encoding::UTF_8)
402
399
 
403
- client2 = Mysql2::Client.new(DatabaseCredentials['root'].merge(:encoding => 'ascii'))
400
+ client2 = new_client(:encoding => 'ascii')
404
401
  result = client2.query("SELECT * FROM mysql2_test ORDER BY id DESC LIMIT 1").first
405
402
  expect(result['set_test'].encoding).to eql(Encoding::ASCII)
406
- client2.close
407
403
  end
408
404
  end
409
405
 
@@ -494,10 +490,9 @@ RSpec.describe Mysql2::Result do
494
490
  result = @client.query("SELECT * FROM mysql2_test ORDER BY id DESC LIMIT 1").first
495
491
  expect(result[field].encoding).to eql(Encoding::UTF_8)
496
492
 
497
- client2 = Mysql2::Client.new(DatabaseCredentials['root'].merge(:encoding => 'ascii'))
493
+ client2 = new_client(:encoding => 'ascii')
498
494
  result = client2.query("SELECT * FROM mysql2_test ORDER BY id DESC LIMIT 1").first
499
495
  expect(result[field].encoding).to eql(Encoding::ASCII)
500
- client2.close
501
496
  end
502
497
  end
503
498
 
@@ -3,7 +3,7 @@ require './spec/spec_helper.rb'
3
3
 
4
4
  RSpec.describe Mysql2::Statement do
5
5
  before :each do
6
- @client = Mysql2::Client.new(DatabaseCredentials['root'].merge(:encoding => "utf8"))
6
+ @client = new_client(:encoding => "utf8")
7
7
  end
8
8
 
9
9
  def stmt_count
@@ -326,18 +326,19 @@ RSpec.describe Mysql2::Statement do
326
326
  end
327
327
 
328
328
  context "#fields" do
329
- before(:each) do
330
- @client.query "USE test"
331
- @test_result = @client.prepare("SELECT * FROM mysql2_test ORDER BY id DESC LIMIT 1").execute
332
- end
333
-
334
329
  it "method should exist" do
335
- expect(@test_result).to respond_to(:fields)
330
+ stmt = @client.prepare("SELECT 1")
331
+ expect(stmt).to respond_to(:fields)
336
332
  end
337
333
 
338
334
  it "should return an array of field names in proper order" do
339
- result = @client.prepare("SELECT 'a', 'b', 'c'").execute
340
- expect(result.fields).to eql(%w(a b c))
335
+ stmt = @client.prepare("SELECT 'a', 'b', 'c'")
336
+ expect(stmt.fields).to eql(%w(a b c))
337
+ end
338
+
339
+ it "should return nil for statement with no result fields" do
340
+ stmt = @client.prepare("INSERT INTO mysql2_test () VALUES ()")
341
+ expect(stmt.fields).to eql(nil)
341
342
  end
342
343
  end
343
344
 
@@ -524,10 +525,9 @@ RSpec.describe Mysql2::Statement do
524
525
  result = @client.query("SELECT * FROM mysql2_test ORDER BY id DESC LIMIT 1").first
525
526
  expect(result['enum_test'].encoding).to eql(Encoding::UTF_8)
526
527
 
527
- client2 = Mysql2::Client.new(DatabaseCredentials['root'].merge(:encoding => 'ascii'))
528
+ client2 = new_client(:encoding => 'ascii')
528
529
  result = client2.query("SELECT * FROM mysql2_test ORDER BY id DESC LIMIT 1").first
529
530
  expect(result['enum_test'].encoding).to eql(Encoding::US_ASCII)
530
- client2.close
531
531
  end
532
532
  end
533
533
 
@@ -557,10 +557,9 @@ RSpec.describe Mysql2::Statement do
557
557
  result = @client.query("SELECT * FROM mysql2_test ORDER BY id DESC LIMIT 1").first
558
558
  expect(result['set_test'].encoding).to eql(Encoding::UTF_8)
559
559
 
560
- client2 = Mysql2::Client.new(DatabaseCredentials['root'].merge(:encoding => 'ascii'))
560
+ client2 = new_client(:encoding => 'ascii')
561
561
  result = client2.query("SELECT * FROM mysql2_test ORDER BY id DESC LIMIT 1").first
562
562
  expect(result['set_test'].encoding).to eql(Encoding::US_ASCII)
563
- client2.close
564
563
  end
565
564
  end
566
565
 
@@ -651,10 +650,9 @@ RSpec.describe Mysql2::Statement do
651
650
  result = @client.query("SELECT * FROM mysql2_test ORDER BY id DESC LIMIT 1").first
652
651
  expect(result[field].encoding).to eql(Encoding::UTF_8)
653
652
 
654
- client2 = Mysql2::Client.new(DatabaseCredentials['root'].merge(:encoding => 'ascii'))
653
+ client2 = new_client(:encoding => 'ascii')
655
654
  result = client2.query("SELECT * FROM mysql2_test ORDER BY id DESC LIMIT 1").first
656
655
  expect(result[field].encoding).to eql(Encoding::US_ASCII)
657
- client2.close
658
656
  end
659
657
  end
660
658
 
@@ -23,72 +23,86 @@ RSpec.configure do |config|
23
23
  $VERBOSE = old_verbose
24
24
  end
25
25
 
26
+ def new_client(option_overrides = {})
27
+ client = Mysql2::Client.new(DatabaseCredentials['root'].merge(option_overrides))
28
+ @clients ||= []
29
+ @clients << client
30
+ return client unless block_given?
31
+ begin
32
+ yield client
33
+ ensure
34
+ client.close
35
+ @clients.delete(client)
36
+ end
37
+ end
38
+
26
39
  config.before :each do
27
- @client = Mysql2::Client.new DatabaseCredentials['root']
40
+ @client = new_client
28
41
  end
29
42
 
30
43
  config.after :each do
31
- @client.close
44
+ @clients.each(&:close)
32
45
  end
33
46
 
34
47
  config.before(:all) do
35
- client = Mysql2::Client.new DatabaseCredentials['root']
36
- client.query %[
37
- CREATE TABLE IF NOT EXISTS mysql2_test (
38
- id MEDIUMINT NOT NULL AUTO_INCREMENT,
39
- null_test VARCHAR(10),
40
- bit_test BIT(64),
41
- single_bit_test BIT(1),
42
- tiny_int_test TINYINT,
43
- bool_cast_test TINYINT(1),
44
- small_int_test SMALLINT,
45
- medium_int_test MEDIUMINT,
46
- int_test INT,
47
- big_int_test BIGINT,
48
- float_test FLOAT(10,3),
49
- float_zero_test FLOAT(10,3),
50
- double_test DOUBLE(10,3),
51
- decimal_test DECIMAL(10,3),
52
- decimal_zero_test DECIMAL(10,3),
53
- date_test DATE,
54
- date_time_test DATETIME,
55
- timestamp_test TIMESTAMP,
56
- time_test TIME,
57
- year_test YEAR(4),
58
- char_test CHAR(10),
59
- varchar_test VARCHAR(10),
60
- binary_test BINARY(10),
61
- varbinary_test VARBINARY(10),
62
- tiny_blob_test TINYBLOB,
63
- tiny_text_test TINYTEXT,
64
- blob_test BLOB,
65
- text_test TEXT,
66
- medium_blob_test MEDIUMBLOB,
67
- medium_text_test MEDIUMTEXT,
68
- long_blob_test LONGBLOB,
69
- long_text_test LONGTEXT,
70
- enum_test ENUM('val1', 'val2'),
71
- set_test SET('val1', 'val2'),
72
- PRIMARY KEY (id)
73
- )
74
- ]
75
- client.query "DELETE FROM mysql2_test;"
76
- client.query %[
77
- INSERT INTO mysql2_test (
78
- null_test, bit_test, single_bit_test, tiny_int_test, bool_cast_test, small_int_test, medium_int_test, int_test, big_int_test,
79
- float_test, float_zero_test, double_test, decimal_test, decimal_zero_test, date_test, date_time_test, timestamp_test, time_test,
80
- year_test, char_test, varchar_test, binary_test, varbinary_test, tiny_blob_test,
81
- tiny_text_test, blob_test, text_test, medium_blob_test, medium_text_test,
82
- long_blob_test, long_text_test, enum_test, set_test
83
- )
48
+ new_client do |client|
49
+ client.query %[
50
+ CREATE TABLE IF NOT EXISTS mysql2_test (
51
+ id MEDIUMINT NOT NULL AUTO_INCREMENT,
52
+ null_test VARCHAR(10),
53
+ bit_test BIT(64),
54
+ single_bit_test BIT(1),
55
+ tiny_int_test TINYINT,
56
+ bool_cast_test TINYINT(1),
57
+ small_int_test SMALLINT,
58
+ medium_int_test MEDIUMINT,
59
+ int_test INT,
60
+ big_int_test BIGINT,
61
+ float_test FLOAT(10,3),
62
+ float_zero_test FLOAT(10,3),
63
+ double_test DOUBLE(10,3),
64
+ decimal_test DECIMAL(10,3),
65
+ decimal_zero_test DECIMAL(10,3),
66
+ date_test DATE,
67
+ date_time_test DATETIME,
68
+ timestamp_test TIMESTAMP,
69
+ time_test TIME,
70
+ year_test YEAR(4),
71
+ char_test CHAR(10),
72
+ varchar_test VARCHAR(10),
73
+ binary_test BINARY(10),
74
+ varbinary_test VARBINARY(10),
75
+ tiny_blob_test TINYBLOB,
76
+ tiny_text_test TINYTEXT,
77
+ blob_test BLOB,
78
+ text_test TEXT,
79
+ medium_blob_test MEDIUMBLOB,
80
+ medium_text_test MEDIUMTEXT,
81
+ long_blob_test LONGBLOB,
82
+ long_text_test LONGTEXT,
83
+ enum_test ENUM('val1', 'val2'),
84
+ set_test SET('val1', 'val2'),
85
+ PRIMARY KEY (id)
86
+ )
87
+ ]
88
+ client.query "DELETE FROM mysql2_test;"
89
+ client.query %[
90
+ INSERT INTO mysql2_test (
91
+ null_test, bit_test, single_bit_test, tiny_int_test, bool_cast_test, small_int_test, medium_int_test, int_test, big_int_test,
92
+ float_test, float_zero_test, double_test, decimal_test, decimal_zero_test, date_test, date_time_test, timestamp_test, time_test,
93
+ year_test, char_test, varchar_test, binary_test, varbinary_test, tiny_blob_test,
94
+ tiny_text_test, blob_test, text_test, medium_blob_test, medium_text_test,
95
+ long_blob_test, long_text_test, enum_test, set_test
96
+ )
84
97
 
85
- VALUES (
86
- NULL, b'101', b'1', 1, 1, 10, 10, 10, 10,
87
- 10.3, 0, 10.3, 10.3, 0, '2010-4-4', '2010-4-4 11:44:00', '2010-4-4 11:44:00', '11:44:00',
88
- 2009, "test", "test", "test", "test", "test",
89
- "test", "test", "test", "test", "test",
90
- "test", "test", 'val1', 'val1,val2'
91
- )
92
- ]
98
+ VALUES (
99
+ NULL, b'101', b'1', 1, 1, 10, 10, 10, 10,
100
+ 10.3, 0, 10.3, 10.3, 0, '2010-4-4', '2010-4-4 11:44:00', '2010-4-4 11:44:00', '11:44:00',
101
+ 2009, "test", "test", "test", "test", "test",
102
+ "test", "test", "test", "test", "test",
103
+ "test", "test", 'val1', 'val1,val2'
104
+ )
105
+ ]
106
+ end
93
107
  end
94
108
  end
Binary file
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.6
4
+ version: 0.4.7
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: 2017-05-04 00:00:00.000000000 Z
12
+ date: 2017-07-01 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description:
15
15
  email:
@@ -91,11 +91,11 @@ post_install_message: |2+
91
91
  ======================================================================================================
92
92
 
93
93
  You've installed the binary version of mysql2.
94
- It was built using MySQL Connector/C version 6.1.9.
94
+ It was built using MySQL Connector/C version 6.1.10.
95
95
  It's recommended to use the exact same version to avoid potential issues.
96
96
 
97
97
  At the time of building this gem, the necessary DLL files were retrieved from:
98
- http://cdn.mysql.com/Downloads/Connector-C/mysql-connector-c-6.1.9-win32.zip
98
+ http://cdn.mysql.com/Downloads/Connector-C/mysql-connector-c-6.1.10-win32.zip
99
99
 
100
100
  This gem *includes* vendor/libmysql.dll with redistribution notice in vendor/README.
101
101