IBM / nodejs-idb-connector

A JavaScript (Node.js) library for communicating with Db2 for IBM i, with support for queries, procedures, and much more. Uses traditional callback-style syntax
MIT License
38 stars 23 forks source link

fix: Check for Javascript empty-string in `bindParameters` #149

Closed sgrezza closed 2 years ago

sgrezza commented 2 years ago

When trying to insert a JS empty string "" into a CHAR field via a dynamic prepared statement, the error is thrown: SQLSTATE=22504 SQLCODE=-191 Mixed data or UTF-8 data not properly formed. Currently, on driver version 1.2.13, this can be replicated by running the test added in this pull request in test/asyncStatementTest.js.

This fix allows empty strings to be used as CHAR values by specifying their length as SQL_NTS rather than checking their actual length, which is 0.