jeremydaly / serverless-mysql

A module for managing MySQL connections at SERVERLESS scale
MIT License
1.21k stars 83 forks source link

Exception when BIT is NULL #149

Closed adlabac closed 1 year ago

adlabac commented 1 year ago

An exception is raised when executing the query() method, if the results contains records with bit(1) columns with NULL values:

Exception
{ "errorType": "TypeError", "errorMessage": "Cannot read properties of null (reading '0')", "stack": [ "TypeError: Cannot read properties of null (reading '0')", " at Connection.castField (/var/task/rest.js:30:52)", " at RowDataPacket.parse (/var/task/node_modules/mysql/lib/protocol/packets/RowDataPacket.js:33:24)", " at Query.RowDataPacket (/var/task/node_modules/mysql/lib/protocol/sequences/Query.js:153:10)", " at Protocol._parsePacket (/var/task/node_modules/mysql/lib/protocol/Protocol.js:260:14)", " at Parser._parsePacket (/var/task/node_modules/mysql/lib/protocol/Parser.js:433:10)", " at Parser.write (/var/task/node_modules/mysql/lib/protocol/Parser.js:43:10)", " at Protocol.write (/var/task/node_modules/mysql/lib/protocol/Protocol.js:38:16)", " at Socket. (/var/task/node_modules/mysql/lib/Connection.js:88:28)", " at Socket. (/var/task/node_modules/mysql/lib/Connection.js:526:10)", " at Socket.emit (node:events:513:28)" ] }

adlabac commented 1 year ago

My bad. The issue was actually caused by the custom typeCast() function which caused the exception.

Please delete or close the issue.