- Notifications
You must be signed in to change notification settings - Fork 155
Description
Summary
The errors thrown by the library have an inconsistent property name for the SQL state value. In some cases, it uses "state", and in other cases, it uses "sqlstate". The library should standardize on one or the other.
Examples:
Executing an insert query that tries to insert a duplicate row, the SQL state is returned in "state":
{ error: "[ibm_db] SQL_ERROR", sqlcode: -803, message: "[IBM][CLI Driver][DB2] SQL0803N One or more values in the INSERT statement, UPDATE statement, or foreign key update caused by a DELETE statement are not valid because the primary key, unique constraint or unique index identified by \"PRINCSG1\" constrains table \"0000004D02\" from having duplicate values for the index key. SQLSTATE=23505\n", state: "23505", resultset: [ ], }It looks like those errors are created in odbc.js between lines https://github.com/ibmdb/node-ibm_db/blob/master/lib/odbc.js#L531 and https://github.com/ibmdb/node-ibm_db/blob/master/lib/odbc.js#L631.
Connection errors created by the Node js lib itself use sqlstate, e.g.
Line 104 in 07c73da
| var connError = { |
var connError = { message: "Connection not open.", sqlstate: "08001", sqlcode: -30081 }; and
Line 649 in 07c73da
| sqlca = {sqlstate: "08001", sqlcode : -30081}; |
if (!self.connected) { sqlca = {sqlstate: "08001", sqlcode : -30081}; deferred ? deferred.reject(connError) : cb(connError, [], sqlca); return next(); } IMHO, given that the bulk of errors that are handled are probably ones returned by DB2 rather than the connection errors created by the library, I'd recommend standardizing on "state".
Thanks!