Describe the bug
MySQL.Async.execute() is supposed to pass rowsAffected to the callback function.
Yet it appears to be passing rowsMatched.
To Reproduce
CREATE TABLE foo (id INTEGER, highscore BIGINT DEFAULT 0);
INSERT INTO foo (id) VALUES (1);
Run the following from MySQL shell vs. with the library:
UPDATE foo SET highscore = greatest(highscore, 1337); -- this is supposed to return 1 rows affected
UPDATE foo SET highscore = greatest(highscore, 42); -- this is supposed to return 0 rows affected (no change)
Set up callbackfunction like:
function(rowsAffected)
print(rowsAffected)
end
Expected behavior
An output of
1
0
instead of
1
1
Software:
OS: Debian 10
Version of the resource: 3.3.2
Database Version: 10.3.31-MariaDB-0+deb10u1
Additional context
I think the library is returning how many rows were matched, as MySQL Client reports 1 for that.
Also, I found this line in the MySQL documentation:
For UPDATE statements, the affected-rows value by default is the number of rows actually changed. If you specify the CLIENT_FOUND_ROWS flag to mysql_real_connect() when connecting to mysqld, the affected-rows value is the number of rows “found”; that is, matched by the WHERE clause.
Describe the bug MySQL.Async.execute() is supposed to pass rowsAffected to the callback function. Yet it appears to be passing rowsMatched.
To Reproduce
Run the following from MySQL shell vs. with the library:
Set up callbackfunction like:
Expected behavior An output of
instead of
Software:
Additional context I think the library is returning how many rows were matched, as MySQL Client reports 1 for that. Also, I found this line in the MySQL documentation:
So I guess this is the cause? Not sure.