ruby-mysql 3.0.1 → 4.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +57 -0
- data/README.md +95 -2
- data/lib/mysql/authenticator/caching_sha2_password.rb +3 -2
- data/lib/mysql/authenticator/mysql_native_password.rb +1 -0
- data/lib/mysql/authenticator/sha256_password.rb +1 -0
- data/lib/mysql/authenticator.rb +6 -4
- data/lib/mysql/charset.rb +6 -6
- data/lib/mysql/constants.rb +8 -0
- data/lib/mysql/error.rb +7 -5
- data/lib/mysql/field.rb +95 -0
- data/lib/mysql/packet.rb +6 -5
- data/lib/mysql/protocol.rb +299 -192
- data/lib/mysql/result.rb +212 -0
- data/lib/mysql/stmt.rb +219 -0
- data/lib/mysql.rb +113 -523
- metadata +13 -13
- data/test/test_mysql.rb +0 -1603
- data/test/test_mysql_packet.rb +0 -149
data/test/test_mysql_packet.rb
DELETED
@@ -1,149 +0,0 @@
|
|
1
|
-
# coding: binary
|
2
|
-
require 'test/unit'
|
3
|
-
require 'test/unit/rr'
|
4
|
-
begin
|
5
|
-
require 'test/unit/notify'
|
6
|
-
rescue LoadError
|
7
|
-
# ignore
|
8
|
-
end
|
9
|
-
|
10
|
-
require 'mysql'
|
11
|
-
|
12
|
-
class TestMysqlPacket < Test::Unit::TestCase
|
13
|
-
def self._(s)
|
14
|
-
s.unpack('H*').first
|
15
|
-
end
|
16
|
-
|
17
|
-
def subject
|
18
|
-
Mysql::Packet.new(data)
|
19
|
-
end
|
20
|
-
|
21
|
-
sub_test_case '#lcb' do
|
22
|
-
[
|
23
|
-
["\xfb", nil],
|
24
|
-
["\xfc\x01\x02", 0x0201],
|
25
|
-
["\xfd\x01\x02\x03", 0x030201],
|
26
|
-
["\xfe\x01\x02\x03\x04\x05\x06\x07\x08", 0x0807060504030201],
|
27
|
-
["\x01", 0x01],
|
28
|
-
].each do |data, result|
|
29
|
-
sub_test_case "for '#{_ data}'" do
|
30
|
-
define_method(:data){ data }
|
31
|
-
test '' do
|
32
|
-
assert{ subject.lcb == result }
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
sub_test_case '#lcs' do
|
39
|
-
[
|
40
|
-
["\x03\x41\x42\x43", 'ABC'],
|
41
|
-
["\x01", ''],
|
42
|
-
["", nil],
|
43
|
-
].each do |data, result|
|
44
|
-
sub_test_case "for '#{_ data}'" do
|
45
|
-
define_method(:data){ data }
|
46
|
-
test '' do
|
47
|
-
assert{ subject.lcs == result }
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
sub_test_case '#read' do
|
54
|
-
define_method(:data){'ABCDEFGHI'}
|
55
|
-
test '' do
|
56
|
-
assert{ subject.read(7) == 'ABCDEFG' }
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
sub_test_case '#string' do
|
61
|
-
define_method(:data){"ABC\0DEF"}
|
62
|
-
test 'should NUL terminated String' do
|
63
|
-
assert{ subject.string == 'ABC' }
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
sub_test_case '#utiny' do
|
68
|
-
[
|
69
|
-
["\x01", 0x01],
|
70
|
-
["\xFF", 0xff],
|
71
|
-
].each do |data, result|
|
72
|
-
sub_test_case "for '#{_ data}'" do
|
73
|
-
define_method(:data){data}
|
74
|
-
test '' do
|
75
|
-
assert{ subject.utiny == result }
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
sub_test_case '#ushort' do
|
82
|
-
[
|
83
|
-
["\x01\x02", 0x0201],
|
84
|
-
["\xFF\xFE", 0xfeff],
|
85
|
-
].each do |data, result|
|
86
|
-
sub_test_case "for '#{_ data}'" do
|
87
|
-
define_method(:data){data}
|
88
|
-
test '' do
|
89
|
-
assert{ subject.ushort == result }
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
sub_test_case '#ulong' do
|
96
|
-
[
|
97
|
-
["\x01\x02\x03\x04", 0x04030201],
|
98
|
-
["\xFF\xFE\xFD\xFC", 0xfcfdfeff],
|
99
|
-
].each do |data, result|
|
100
|
-
sub_test_case "for '#{_ data}'" do
|
101
|
-
define_method(:data){data}
|
102
|
-
test '' do
|
103
|
-
assert{ subject.ulong == result }
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
sub_test_case '#eof?' do
|
110
|
-
[
|
111
|
-
["\xfe\x00\x00\x00\x00", true],
|
112
|
-
["ABCDE", false],
|
113
|
-
].each do |data, result|
|
114
|
-
sub_test_case "for '#{_ data}'" do
|
115
|
-
define_method(:data){data}
|
116
|
-
test '' do
|
117
|
-
assert{ subject.eof? == result }
|
118
|
-
end
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
sub_test_case 'Mysql::Packet.lcb' do
|
124
|
-
[
|
125
|
-
[nil, "\xfb"],
|
126
|
-
[1, "\x01"],
|
127
|
-
[250, "\xfa"],
|
128
|
-
[251, "\xfc\xfb\x00"],
|
129
|
-
[65535, "\xfc\xff\xff"],
|
130
|
-
[65536, "\xfd\x00\x00\x01"],
|
131
|
-
[16777215, "\xfd\xff\xff\xff"],
|
132
|
-
[16777216, "\xfe\x00\x00\x00\x01\x00\x00\x00\x00"],
|
133
|
-
[0xffffffffffffffff, "\xfe\xff\xff\xff\xff\xff\xff\xff\xff"],
|
134
|
-
].each do |val, result|
|
135
|
-
sub_test_case "with #{val}" do
|
136
|
-
test '' do
|
137
|
-
assert{ Mysql::Packet.lcb(val) == result }
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
sub_test_case 'Mysql::Packet.lcs' do
|
144
|
-
test '' do
|
145
|
-
assert{ Mysql::Packet.lcs("hoge") == "\x04hoge" }
|
146
|
-
assert{ Mysql::Packet.lcs("あいう".force_encoding("UTF-8")) == "\x09\xe3\x81\x82\xe3\x81\x84\xe3\x81\x86" }
|
147
|
-
end
|
148
|
-
end
|
149
|
-
end
|