mysql2 0.3.18 → 0.4.0
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 +4 -4
- data/CHANGELOG.md +1 -0
- data/LICENSE +21 -0
- data/README.md +28 -6
- data/examples/threaded.rb +4 -6
- data/ext/mysql2/client.c +124 -126
- data/ext/mysql2/client.h +21 -0
- data/ext/mysql2/extconf.rb +29 -15
- data/ext/mysql2/mysql2_ext.c +1 -0
- data/ext/mysql2/mysql2_ext.h +1 -0
- data/ext/mysql2/mysql_enc_name_to_ruby.h +6 -6
- data/ext/mysql2/result.c +499 -128
- data/ext/mysql2/result.h +9 -3
- data/ext/mysql2/statement.c +454 -0
- data/ext/mysql2/statement.h +22 -0
- data/lib/mysql2/client.rb +24 -1
- data/lib/mysql2/error.rb +9 -21
- data/lib/mysql2/field.rb +4 -0
- data/lib/mysql2/statement.rb +5 -0
- data/lib/mysql2/version.rb +1 -1
- data/lib/mysql2.rb +2 -0
- data/spec/em/em_spec.rb +13 -13
- data/spec/mysql2/client_spec.rb +337 -326
- data/spec/mysql2/error_spec.rb +37 -36
- data/spec/mysql2/result_spec.rb +197 -192
- data/spec/mysql2/statement_spec.rb +598 -0
- data/spec/spec_helper.rb +7 -0
- metadata +15 -46
data/spec/em/em_spec.rb
CHANGED
@@ -4,7 +4,7 @@ begin
|
|
4
4
|
require 'eventmachine'
|
5
5
|
require 'mysql2/em'
|
6
6
|
|
7
|
-
describe Mysql2::EM::Client do
|
7
|
+
RSpec.describe Mysql2::EM::Client do
|
8
8
|
it "should support async queries" do
|
9
9
|
results = []
|
10
10
|
EM.run do
|
@@ -24,8 +24,8 @@ begin
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
results[0].keys.
|
28
|
-
results[1].keys.
|
27
|
+
expect(results[0].keys).to include("second_query")
|
28
|
+
expect(results[1].keys).to include("first_query")
|
29
29
|
end
|
30
30
|
|
31
31
|
it "should support queries in callbacks" do
|
@@ -44,12 +44,12 @@ begin
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
-
results[0].keys.
|
48
|
-
results[1].keys.
|
47
|
+
expect(results[0].keys).to include("first_query")
|
48
|
+
expect(results[1].keys).to include("second_query")
|
49
49
|
end
|
50
50
|
|
51
51
|
it "should not swallow exceptions raised in callbacks" do
|
52
|
-
|
52
|
+
expect {
|
53
53
|
EM.run do
|
54
54
|
client = Mysql2::EM::Client.new DatabaseCredentials['root']
|
55
55
|
defer = client.query "SELECT sleep(0.1) as first_query"
|
@@ -63,13 +63,13 @@ begin
|
|
63
63
|
EM.stop_event_loop
|
64
64
|
end
|
65
65
|
end
|
66
|
-
}.
|
66
|
+
}.to raise_error('some error')
|
67
67
|
end
|
68
68
|
|
69
69
|
context 'when an exception is raised by the client' do
|
70
70
|
let(:client) { Mysql2::EM::Client.new DatabaseCredentials['root'] }
|
71
71
|
let(:error) { StandardError.new('some error') }
|
72
|
-
before { client.
|
72
|
+
before { allow(client).to receive(:async_result).and_raise(error) }
|
73
73
|
|
74
74
|
it "should swallow exceptions raised in by the client" do
|
75
75
|
errors = []
|
@@ -85,7 +85,7 @@ begin
|
|
85
85
|
EM.stop_event_loop
|
86
86
|
end
|
87
87
|
end
|
88
|
-
errors.
|
88
|
+
expect(errors).to eq([error])
|
89
89
|
end
|
90
90
|
|
91
91
|
it "should fail the deferrable" do
|
@@ -105,7 +105,7 @@ begin
|
|
105
105
|
end
|
106
106
|
end
|
107
107
|
end
|
108
|
-
callbacks_run.
|
108
|
+
expect(callbacks_run).to eq([:errback])
|
109
109
|
end
|
110
110
|
end
|
111
111
|
|
@@ -121,10 +121,10 @@ begin
|
|
121
121
|
callbacks_run << :errback
|
122
122
|
end
|
123
123
|
EM.add_timer(0.1) do
|
124
|
-
callbacks_run.
|
125
|
-
|
124
|
+
expect(callbacks_run).to eq([:callback])
|
125
|
+
expect {
|
126
126
|
client.close
|
127
|
-
}.
|
127
|
+
}.not_to raise_error
|
128
128
|
EM.stop_event_loop
|
129
129
|
end
|
130
130
|
end
|