Skip to content

Empty error when 0 rows updated #30

@luisbraganca

Description

@luisbraganca

First 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions