ensure the query is a string earlier in the Mysql2::Client#query codepath for 1.9
This commit is contained in:
parent
90ddb63e52
commit
1057f976d0
|
@ -290,6 +290,7 @@ static VALUE rb_mysql_client_query(int argc, VALUE * argv, VALUE self) {
|
|||
opts = defaults;
|
||||
}
|
||||
|
||||
Check_Type(args.sql, T_STRING);
|
||||
#ifdef HAVE_RUBY_ENCODING_H
|
||||
rb_encoding *conn_enc = rb_to_encoding(wrapper->encoding);
|
||||
// ensure the string is in the encoding the connection is expecting
|
||||
|
|
|
@ -86,6 +86,12 @@ describe Mysql2::Client do
|
|||
end
|
||||
|
||||
context "#query" do
|
||||
it "should only accept strings as the query parameter" do
|
||||
lambda {
|
||||
@client.query ["SELECT 'not right'"]
|
||||
}.should raise_error(TypeError)
|
||||
end
|
||||
|
||||
it "should accept an options hash that inherits from Mysql2::Client.default_query_options" do
|
||||
@client.query "SELECT 1", :something => :else
|
||||
@client.query_options.should eql(@client.query_options.merge(:something => :else))
|
||||
|
|
Loading…
Reference in New Issue