execute raises an exception on error
This commit is contained in:
parent
7e95b543c9
commit
a3cdd92a9c
|
@ -51,7 +51,8 @@ static VALUE execute(VALUE self)
|
|||
MYSQL_STMT * stmt;
|
||||
Data_Get_Struct(self, MYSQL_STMT, stmt);
|
||||
|
||||
mysql_stmt_execute(stmt);
|
||||
if(mysql_stmt_execute(stmt))
|
||||
rb_raise(cMysql2Error, "%s", mysql_stmt_error(stmt));
|
||||
|
||||
return self;
|
||||
}
|
||||
|
|
|
@ -50,4 +50,9 @@ describe Mysql2::Statement do
|
|||
stmt.prepare 'SELECT 1'
|
||||
stmt.execute.should == stmt
|
||||
end
|
||||
|
||||
it "should raise an exception on error" do
|
||||
stmt = @client.create_statement
|
||||
lambda { stmt.execute }.should raise_error(Mysql2::Error)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue