Skip to content

Commit bcefd29

Browse files
nyaxtjustincase
authored andcommitted
added failing test: query with param in different encoding
1 parent fb91095 commit bcefd29

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

spec/mysql2/statement_spec.rb

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
statement.execute(Date.today)
109109
end
110110

111-
context "utf8_db_field" do
111+
context "utf8_db" do
112112
before(:each) do
113113
@client.query("DROP DATABASE IF EXISTS test_mysql2_stmt_utf8")
114114
@client.query("CREATE DATABASE test_mysql2_stmt_utf8")
@@ -124,6 +124,29 @@
124124
it "should be able to retrieve utf8 field names correctly" do
125125
statement = @client.prepare 'SELECT * FROM `テーブル`'
126126
statement.fields.should == ['整数', '文字列']
127+
result = statement.execute
128+
129+
result.to_a.should == [{"整数"=>1, "文字列"=>"イチ"}, {"整数"=>2, "文字列"=>"弐"}, {"整数"=>3, "文字列"=>"さん"}]
130+
end
131+
132+
it "should be able to retrieve utf8 param query correctly" do
133+
statement = @client.prepare 'SELECT 整数 FROM テーブル WHERE 文字列 = ?'
134+
statement.param_count.should == 1
135+
136+
result = statement.execute 'イチ'
137+
138+
result.to_a.should == [{"整数"=>1}]
127139
end
140+
141+
it "should be able to retrieve query with param in different encoding correctly" do
142+
statement = @client.prepare 'SELECT 整数 FROM テーブル WHERE 文字列 = ?'
143+
statement.param_count.should == 1
144+
145+
param = 'イチ'.encode("EUC-JP")
146+
result = statement.execute param
147+
148+
result.to_a.should == [{"整数"=>1}]
149+
end
150+
128151
end
129152
end

0 commit comments

Comments
 (0)