From f22779ad15c6be57a7d2ff2b9423b796f091725c Mon Sep 17 00:00:00 2001 From: hotid Date: Fri, 26 Oct 2018 20:14:43 +0300 Subject: [PATCH] stop generating empty WHERE () section in mysql queries --- dbms/src/Storages/transformQueryForExternalDatabase.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/dbms/src/Storages/transformQueryForExternalDatabase.cpp b/dbms/src/Storages/transformQueryForExternalDatabase.cpp index 2615e8d0d92..43d20d7a4c0 100644 --- a/dbms/src/Storages/transformQueryForExternalDatabase.cpp +++ b/dbms/src/Storages/transformQueryForExternalDatabase.cpp @@ -119,6 +119,7 @@ String transformQueryForExternalDatabase( { if (function->name == "and") { + bool compatibleFound = false; auto new_function_and = std::make_shared(); auto new_function_and_arguments = std::make_shared(); new_function_and->arguments = new_function_and_arguments; @@ -126,9 +127,13 @@ String transformQueryForExternalDatabase( for (const auto & elem : function->arguments->children) if (isCompatible(*elem)) + { new_function_and_arguments->children.push_back(elem); + compatibleFound = true; + } - select->where_expression = std::move(new_function_and); + if (compatibleFound) + select->where_expression = std::move(new_function_and); } } }