Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ext/mysql2/result.c
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,7 @@ static VALUE rb_mysql_result_each_(VALUE self,
rb_raise(cMysql2Error, "You have already fetched all the rows for this query and streaming is true. (to reiterate you must requery).");
}
} else {
if (args->cacheRows && wrapper->resultFreed) {
if (args->cacheRows && wrapper->lastRowProcessed == wrapper->numberOfRows) {
/* we've already read the entire dataset from the C result into our */
/* internal array. Lets hand that over to the user since it's ready to go */
for (i = 0; i < wrapper->numberOfRows; i++) {
Expand Down
7 changes: 7 additions & 0 deletions spec/mysql2/statement_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,13 @@ def stmt_count
expect(list[1]).to eq('2')
end

it "should give us fields when no rows" do
statement = @client.prepare 'SELECT 1 FROM mysql2_test WHERE 1=0'
r = statement.execute
list = r.fields
expect(list.length).to eq(1)
end

it "should handle as a decimal binding a BigDecimal" do
stmt = @client.prepare('SELECT ? AS decimal_test')
test_result = stmt.execute(BigDecimal("123.45")).first
Expand Down