Empty error when 0 rows updated
See original GitHub issueFirst of all thank you a lot for all the support and implementation of this module. Great work!
However I faced a bug and decided to share my thoughts about it with you.
So, the following code:
"use strict";
const odbc = require("odbc");
odbc.connect("Dsn=example;Uid=example;Pwd=example;", function (err, connection) {
if (err) {
return console.error(err);
}
connection.query("UPDATE some_entity SET value = 10000 WHERE book = (SELECT id FROM books WHERE name = 'Best book of the world')", function (error, results) {
if (error) {
return console.error(error);
}
console.log(results);
});
});
Shows the following output on the terminal:
[Error: "errors": []]
This error is shown when I execute an UPDATE
query that the WHERE
criteria does not match any rows, if it matches at least 1 row, there’s no error…
I don’t know if this is the correct behaviour although I don’t agree it should be.
Imagine the following situation: I want to execute an UPDATE
, and if no rows were updated on that same query, I want to be able to execute an INSERT
query instead.
Currently using version 2.0.0-4
.
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
mySQL UPDATE query returns "0 rows affected"
If the column you want to update is an integer or boolean, and you set it to a string, it won't be updated...
Read more >Question about 0 rows updated when there should have been 1
So, the error "0 rows updated when there should have been 1" is the result of a INSERT or UPDATE which had zero...
Read more >How to fail a transaction when update affected 0 rows #77
I can detect zero row update using .result, but I don't know how to do ... rowCount) { // 1. throw new Error("Ops,...
Read more >Bulk Insert giving no error but 0 rows affected
UPDATE - It is clearly someting at the very end of the file. If I set the LASTROW = 500 it will import...
Read more >Update Statement and Exception Handling - Ask TOM
There are NO exceptions when 0 rows are updated-- that is NOT an error. If is the right way to catch that. 2)...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I think the issue is probably that the query is returning
SQL_NO_DATA
, which isn’t passing the error check (which is only passing onSQL_SUCCESS
andSQL_SUCCESS_WITH_INFO
). I actually found this same bug this morning and I am hoping to remedy for the next release.Going to mark as closed, a lot of development since the last update and I just tried on my Db2 for i ODBC connection. For both update and delete where 0 rows were affected, the query ran fine and produced no errors.