-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix empty sql statement error #64
base: master
Are you sure you want to change the base?
Changes from 2 commits
59198e5
d2f6465
24646cb
6f0e2ea
f09bf3e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -153,11 +153,15 @@ connection.prototype.query = function(query, data, callback, skipTransactions){ | |
sqlText: query, | ||
binds: data, | ||
complete: function(err, stmt, rows) { | ||
|
||
isEmptySQLStatementError=false; | ||
if (err) { | ||
//In SQL Queries if there are empty lines between sql queries , snowflake throws a exception. This statement provides a workaround to not get that error. | ||
if(String(err.message).includes('Empty SQL statement')) { | ||
callback(null); | ||
if(String(err.message).includes('Empty SQL statement')) { | ||
self.book.logger.log('Error in : ' + String(query), 'error'); | ||
self.book.logger.log('Error message : ' + err.message, 'error'); | ||
self.book.logger.log('Stack Trace : ' + err.stack, 'error'); | ||
// set the flag so that callback will be called only once | ||
isEmptySQLStatementError=true; | ||
} else if(!(String(query).startsWith('SHOW COLUMNS') && String(query).endsWith('_TMP'))){ | ||
self.book.logger.log('Error in : ' + String(query), 'error'); | ||
self.book.logger.log('Error message : ' + err.message, 'error'); | ||
|
@@ -170,7 +174,13 @@ connection.prototype.query = function(query, data, callback, skipTransactions){ | |
process.exit(1); | ||
} | ||
} | ||
callback(err); | ||
if(isEmptySQLStatementError){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For statements where we get "Empty SQL statement" , the "isEmptySQLStatementError=true;" will always be correct , then it would never go into the "else" part , right ? Am I missing anything here ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @rajpalparyani I had added the logging statements so that we have the information about the error in the logs, removed it now. Also, you are correct, this was missed, the flag would've always remained true. I have reset the flag back to false after the condition is met. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i still don't understand how this change will help us in this case. In both this PR and current master , we are just calling "callback(null)" in both cases .. The only addition is the flag , which I don't understand how it will help us not get this error. let's talk more in the scrum as a breakout tomorrow about this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @rajpalparyani : I did some more investigation on this today, adding the if-else flag ensures that the remaining block of code doesnt execute after a callback is executed. The same can be achieved by the above changes, we want to "callback(null)" and "return" once the error condition of "empty SQL statement" is met and not continue execution till the "callback(err)" line. fs.fstat(fd, function(er, st) { buffer = new Buffer(size); We can discuss more on this in the breakout. |
||
callback(null); | ||
} | ||
else{ | ||
callback(err); | ||
} | ||
|
||
} else { | ||
if(String(query).includes('INSERT INTO EMPUJAR') ) { | ||
self.book.logger.log('Empujar insert , Query Id ' + stmt.getStatementId() + ' Payload Info : ' + String(data), 'debug'); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@manasibarate - I remember adding this statement because there were already some comments in some sql files because of which we get this error, and we should technically not make this as a failure.
Why are we then printing Stack trace for these things ?