Closed satyam9798 closed 2 months ago
anyFirst method returning error if we have multiple columns
Should return first column values if we have multiple columns in our table.
Throws error if we have number of column not equals to zero (even if it is greater than 1)
Incorrect implementation:
const firstRow = rows[0]; const keys = Object.keys(firstRow); if (keys.length !== 1) { log.error({ queryId, }, 'result row has no columns'); throw new errors_1.DataIntegrityError(query); }
correct implementation: if (keys.length === 0) { log.error({ queryId, }, 'result row has no columns'); throw new errors_1.DataIntegrityError(query); }
DataIntegrityError: Query returned an unexpected result. at anyFirst (...\node_modules\slonik\dist\connectionMethods\anyFirst.js:19:15)
anyFirst method returning error if we have multiple columns
Expected Behavior
Should return first column values if we have multiple columns in our table.
Current Behavior
Throws error if we have number of column not equals to zero (even if it is greater than 1)
Possible Solution
Incorrect implementation:
const firstRow = rows[0]; const keys = Object.keys(firstRow); if (keys.length !== 1) { log.error({ queryId, }, 'result row has no columns'); throw new errors_1.DataIntegrityError(query); }
Steps to Reproduce
Logs
DataIntegrityError: Query returned an unexpected result. at anyFirst (...\node_modules\slonik\dist\connectionMethods\anyFirst.js:19:15)