Skip to content

result.affectedRows and result.changedRows retuning incorrect values #2214

Open
@niswork

Description

@niswork

I am executing query like this -

INSERT INTO ...
(...)
.
ON DUPLICATE KEY UPDATE
.
VALUES(...)

The result object I get back in .query's callback function always shows affected rows as >0 and changed rows as >0 even when no rows were updated.

Sample result object when no insert was made - 
result obj = {"fieldCount":0,"affectedRows":35,"insertId":0,"serverStatus":2,"warningCount":0,"message":"(Records: 35  Duplicates: 35  Warnings: 0","protocol41":true,"changedRows":35}

MySQL Workbench Response for the same query = 
0 row(s) affected Records: 35  Duplicates: 0  Warnings: 0

Interestingly, when rows get inserted, I see changedRows = 0;

Sample result object when rows were inserted - 
{"fieldCount":0,"affectedRows":35,"insertId":0,"serverStatus":2,"warningCount":0,"message":"'Records: 35  Duplicates: 0  Warnings: 0","protocol41":true,"changedRows":0}

MySQL Workbench Response for the same query = 
35 row(s) affected Records: 35  Duplicates: 0  Warnings: 0

Please check if this is a bug. If not, please let me know if there is something I am doing incorrectly which might be causing such results for me.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions