Skip to content

Commit

Permalink
Handle prepared statements with floats
Browse files Browse the repository at this point in the history
The value returned from the server differs between MySQL 5.7 and MySQL 8.
With MySQL 5.7 we get back a float, with MySQL 8 we get back a double.
  • Loading branch information
adrianna-chang-shopify committed Jun 8, 2023
1 parent 5ccb8ea commit 7fe04a4
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion test/blocking_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,13 @@ TEST test_blocking_stmt_execute_float() {
err = trilogy_stmt_read_full_row(&conn, &stmt, columns, values);
ASSERT_OK(err);

ASSERT_EQ(values[0].as.flt, float_val);
// With MySQL 5.7, the value is returned from the server as a float.
// With MySQL 8, the value is returned from the server as a double.
if (columns[0].type == TRILOGY_TYPE_FLOAT) {
ASSERT_EQ(values[0].as.flt, float_val);
} else if (columns[0].type == TRILOGY_TYPE_DOUBLE) {
ASSERT_EQ(values[0].as.dbl, float_val);
}

err = trilogy_stmt_read_full_row(&conn, &stmt, columns, values);
ASSERT_EOF(err);
Expand Down

0 comments on commit 7fe04a4

Please sign in to comment.