From 93585a0dd1ff7437fa03a4dce6634fe362dacaea Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Thu, 20 May 2021 01:26:44 +0300 Subject: [PATCH 1/2] Fix bad test for Enum hints --- src/DataTypes/EnumValues.cpp | 2 +- tests/queries/0_stateless/01852_hints_enum_name.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/DataTypes/EnumValues.cpp b/src/DataTypes/EnumValues.cpp index 39c24bf1122..6df899ba9a2 100644 --- a/src/DataTypes/EnumValues.cpp +++ b/src/DataTypes/EnumValues.cpp @@ -67,7 +67,7 @@ T EnumValues::getValue(StringRef field_name, bool try_treat_as_id) const return x; } auto hints = this->getHints(field_name.toString()); - auto hints_string = !hints.empty() ? ", may be you meant: " + toString(hints) : ""; + auto hints_string = !hints.empty() ? ", maybe you meant: " + toString(hints) : ""; throw Exception{"Unknown element '" + field_name.toString() + "' for enum" + hints_string, ErrorCodes::BAD_ARGUMENTS}; } return it->getMapped(); diff --git a/tests/queries/0_stateless/01852_hints_enum_name.sh b/tests/queries/0_stateless/01852_hints_enum_name.sh index bffde6e6c8c..1e7d09602e9 100755 --- a/tests/queries/0_stateless/01852_hints_enum_name.sh +++ b/tests/queries/0_stateless/01852_hints_enum_name.sh @@ -4,5 +4,5 @@ CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) # shellcheck source=../shell_config.sh . "$CURDIR"/../shell_config.sh -$CLICKHOUSE_CLIENT --query="SELECT CAST('Helo', 'Enum(\'Hello\' = 1, \'World\' = 2)')" 2>&1 | grep -q "may be you meant: \['Hello'\]" && echo 'OK' || echo 'FAIL' +$CLICKHOUSE_CLIENT --query="SELECT CAST('Helo' AS Enum('Hello' = 1, 'World' = 2))" 2>&1 | grep -q -F "maybe you meant: ['Hello']" && echo 'OK' || echo 'FAIL' From e686349fccb9e471bf0da343fac72bdb570f9256 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Thu, 20 May 2021 01:47:10 +0300 Subject: [PATCH 2/2] Fix wrong logic in hints about Enum names --- src/Common/NamePrompter.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Common/NamePrompter.h b/src/Common/NamePrompter.h index 5f7832c4423..bb17f860f29 100644 --- a/src/Common/NamePrompter.h +++ b/src/Common/NamePrompter.h @@ -90,17 +90,16 @@ private: } }; -template + +template class IHints { public: - virtual std::vector getAllRegisteredNames() const = 0; std::vector getHints(const String & name) const { - static const auto registered_names = getAllRegisteredNames(); - return prompter.getHints(name, registered_names); + return prompter.getHints(name, getAllRegisteredNames()); } virtual ~IHints() = default;