From e110d0789fed9a16a2f39a422d2b8d827663b90c Mon Sep 17 00:00:00 2001 From: Ivan Blinkov Date: Wed, 5 Dec 2018 19:59:35 +0300 Subject: [PATCH] Add lcase/ucase + make lower/upper case-insensitive #3715 --- dbms/src/Functions/lower.cpp | 3 ++- dbms/src/Functions/upper.cpp | 3 ++- .../0_stateless/00765_sql_compatibility_aliases.reference | 4 ++++ .../queries/0_stateless/00765_sql_compatibility_aliases.sql | 6 ++++++ 4 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 dbms/tests/queries/0_stateless/00765_sql_compatibility_aliases.reference create mode 100644 dbms/tests/queries/0_stateless/00765_sql_compatibility_aliases.sql diff --git a/dbms/src/Functions/lower.cpp b/dbms/src/Functions/lower.cpp index 38379fa10cd..4f9dec14602 100644 --- a/dbms/src/Functions/lower.cpp +++ b/dbms/src/Functions/lower.cpp @@ -15,7 +15,8 @@ using FunctionLower = FunctionStringToString, NameLower void registerFunctionLower(FunctionFactory & factory) { - factory.registerFunction(); + factory.registerFunction(FunctionFactory::CaseInsensitive); + factory.registerAlias("lcase", "lower", FunctionFactory::CaseInsensitive); } } diff --git a/dbms/src/Functions/upper.cpp b/dbms/src/Functions/upper.cpp index 9a884ccedd8..35300b61c93 100644 --- a/dbms/src/Functions/upper.cpp +++ b/dbms/src/Functions/upper.cpp @@ -15,7 +15,8 @@ using FunctionUpper = FunctionStringToString, NameUpper void registerFunctionUpper(FunctionFactory & factory) { - factory.registerFunction(); + factory.registerFunction(FunctionFactory::CaseInsensitive); + factory.registerAlias("ucase", "upper", FunctionFactory::CaseInsensitive); } } diff --git a/dbms/tests/queries/0_stateless/00765_sql_compatibility_aliases.reference b/dbms/tests/queries/0_stateless/00765_sql_compatibility_aliases.reference new file mode 100644 index 00000000000..da7e45c0ca0 --- /dev/null +++ b/dbms/tests/queries/0_stateless/00765_sql_compatibility_aliases.reference @@ -0,0 +1,4 @@ +foo +FOO +foo +FOO diff --git a/dbms/tests/queries/0_stateless/00765_sql_compatibility_aliases.sql b/dbms/tests/queries/0_stateless/00765_sql_compatibility_aliases.sql new file mode 100644 index 00000000000..63ab4eb56d0 --- /dev/null +++ b/dbms/tests/queries/0_stateless/00765_sql_compatibility_aliases.sql @@ -0,0 +1,6 @@ +SET send_logs_level = 'none'; + +select lcase('FOO'); +select ucase('foo'); +select LOWER('Foo'); +select UPPER('Foo');