execute raises an exception on error

This commit is contained in:
Aaron Patterson 2010-07-08 16:09:21 -07:00
parent 7e95b543c9
commit a3cdd92a9c
2 changed files with 7 additions and 1 deletions

View File

@ -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;
}

View File

@ -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