Skip to content
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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions lib/connections/snowflake.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,12 @@ connection.prototype.query = function(query, data, callback, skipTransactions){
var runner = self.connection.execute({
sqlText: query,
binds: data,
complete: function(err, stmt, rows) {

complete: function(err, stmt, rows) {
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')) {
//fix to avoid callback is already called error- We would want to continue the execution
return callback(null);
} 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');
Expand All @@ -169,8 +169,10 @@ connection.prototype.query = function(query, data, callback, skipTransactions){
self.book.logger.log('Exiting process due to Undefined Query Id ', 'error');
process.exit(1);
}
}
callback(err);
}

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');
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "empujar",
"version": "0.2.23",
"version": "0.2.24",
"description": "When you need to push data around, you push it. Push it real good. An ETL and Operations tool.",
"main": "index.js",
"engines": {
Expand Down