data-api-client icon indicating copy to clipboard operation
data-api-client copied to clipboard

INSERT with parameters fails if less than 3 parameters

Open wallisch opened this issue 3 years ago • 2 comments

I've just encountered a very strange bug, which took me hours to figure out.

Apparently, if you execute an INSERT statement with parameters, it only works if the passed object contains more than 2 properties.

Fails with "cannot find parameter color_id";

dataAPI.query(
        `INSERT INTO component (color_id, name) 
        VALUES(:color_id, :name)` ,{ 
            color_id: 1,
            name: "test"
})

Passes:

dataAPI.query(
        `INSERT INTO component (color_id, name) 
        VALUES(:color_id, :name)` ,{ 
            color_id: 1,
            name: "test",
            dummy: "dummy"
})

Unfortunately I have no idea what causes this.

wallisch avatar Jan 22 '21 10:01 wallisch

@jeremydaly This is probably a semi-critical bug. It was fixed in PR #75 but hasn't been published to the npm registry, looks like.

ffxsam avatar Jan 22 '21 16:01 ffxsam

+1

Why is this not on NPM yet?

lucas-subli avatar Jul 15 '21 22:07 lucas-subli