diff --git a/src/worker/executors/select/join.ts b/src/worker/executors/select/join.ts index 6a31a315..f377c476 100644 --- a/src/worker/executors/select/join.ts +++ b/src/worker/executors/select/join.ts @@ -188,6 +188,7 @@ class Join { } } catch (ex) { + console.error(ex); return promiseReject( new LogHelper(ERROR_TYPE.InvalidJoinQuery, ex.message) ); @@ -214,6 +215,7 @@ class Join { }); } catch (ex) { + console.error(ex); return promiseReject( new LogHelper(ERROR_TYPE.InvalidJoinQuery, ex.message) ); @@ -351,10 +353,13 @@ class Join { const table2 = jointblInfo.table2; const tableSchemaOf1stTable = this.getTable(table1.table); const tableSchemaOf2ndTable = this.getTable(table2.table); - if (tableSchemaOf1stTable == null || tableSchemaOf2ndTable == null) { - return new LogHelper(ERROR_TYPE.InvalidJoinQuery, - `The 'on' condition references tables or columns ('${table1.table}.${table1.column}', '${table2.table}.${table2.column}') that do not exist or are not part of the join. Ensure that the tables and columns used in the 'on' condition match those specified in the 'from' and 'with' clauses.` - ); + + if (process.env.NODE_ENV !== 'production') { + if (tableSchemaOf1stTable == null || tableSchemaOf2ndTable == null) { + return new LogHelper(ERROR_TYPE.InvalidJoinQuery, + `The 'on' condition references tables or columns ('${table1.table}.${table1.column}', '${table2.table}.${table2.column}') that do not exist or are not part of the join. Ensure that the tables and columns used in the 'on' condition match those specified in the 'from' and 'with' clauses.` + ); + } } let err: LogHelper; diff --git a/test/cases/select/join.js b/test/cases/select/join.js index 41061dca..3da43af1 100644 --- a/test/cases/select/join.js +++ b/test/cases/select/join.js @@ -924,12 +924,17 @@ describe('Test join', function () { on: "Orders_invalid.customerId=Customers.customerId" } }).catch(function (err) { - const error = { - "message": "The 'on' condition references tables or columns ('Orders_invalid.customerId', 'Customers.customerId') that do not exist or are not part of the join. Ensure that the tables and columns used in the 'on' condition match those specified in the 'from' and 'with' clauses.", - "type": "invalid_join_query" - }; - expect(err).to.eql(error); - done(); + if (isRuningForProd() || isRuningForSauce()) { + done(); + } + else { + const error = { + "message": "The 'on' condition references tables or columns ('Orders_invalid.customerId', 'Customers.customerId') that do not exist or are not part of the join. Ensure that the tables and columns used in the 'on' condition match those specified in the 'from' and 'with' clauses.", + "type": "invalid_join_query" + }; + expect(err).to.eql(error); + done(); + } }) }); @@ -942,12 +947,17 @@ describe('Test join', function () { on: "Orders.customerId=Customers_invalid.customerId" } }).catch(function (err) { - const error = { - "message": "The 'on' condition references tables or columns ('Orders.customerId', 'Customers_invalid.customerId') that do not exist or are not part of the join. Ensure that the tables and columns used in the 'on' condition match those specified in the 'from' and 'with' clauses.", - "type": "invalid_join_query" - }; - expect(err).to.eql(error); - done(); + if (isRuningForProd() || isRuningForSauce()) { + done(); + } + else { + const error = { + "message": "The 'on' condition references tables or columns ('Orders.customerId', 'Customers_invalid.customerId') that do not exist or are not part of the join. Ensure that the tables and columns used in the 'on' condition match those specified in the 'from' and 'with' clauses.", + "type": "invalid_join_query" + }; + expect(err).to.eql(error); + done(); + } }) });