Skip to content

Commit

Permalink
fix: rebiew comments
Browse files Browse the repository at this point in the history
Signed-off-by: Samarpan Bhattacharya <this.is.samy@gmail.com>
  • Loading branch information
samarpanB authored and dhmlau committed Sep 22, 2022
1 parent 7a02f12 commit 28dec15
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/sql.js
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ SQLConnector.prototype.buildInsertAll = function(model, data, options) {
return null;
}
const fieldsArray = this.buildFieldsFromArray(model, data);
if (fieldsArray.length === 0) {
if (Array.isArray(fieldsArray) && fieldsArray.length === 0) {
debug('no fields found for insert query');
// return immediately if no fields found
return null;
Expand Down Expand Up @@ -1269,7 +1269,7 @@ SQLConnector.prototype.buildFields = function(model, data, excludeIds) {
*/
SQLConnector.prototype.buildFieldsFromArray = function(model, data, excludeIds) {
const fields = [];
if (data.length > 0) {
if (Array.isArray(data) && data.length > 0) {
const keys = Object.keys(data[0]);
for (let i = 0; i < data.length; i++) {
fields.push(this._buildFieldsForKeys(model, data[i], keys, excludeIds));
Expand Down

0 comments on commit 28dec15

Please sign in to comment.