From 2a050dab076a394baa61f822cb55a67b12f09c64 Mon Sep 17 00:00:00 2001 From: Gal Salomon Date: Wed, 27 Mar 2024 00:59:17 +0200 Subject: [PATCH] a fix for the use-case of not-operator on a string (#153) Signed-off-by: Gal Salomon --- include/s3select_oper.h | 4 ++++ test/s3select_test.cpp | 1 + 2 files changed, 5 insertions(+) diff --git a/include/s3select_oper.h b/include/s3select_oper.h index 86c0d7cc..9fd67b8b 100644 --- a/include/s3select_oper.h +++ b/include/s3select_oper.h @@ -2260,6 +2260,10 @@ class negate_function_operation : public base_statement res = (bool)1; } } + else if(res.is_string()) + { + res = (bool)false; + } return res; } diff --git a/test/s3select_test.cpp b/test/s3select_test.cpp index 915f14d2..07952371 100644 --- a/test/s3select_test.cpp +++ b/test/s3select_test.cpp @@ -1726,6 +1726,7 @@ TEST(TestS3selectFunctions, truefalse) test_single_column_single_row("select (not 1 > 2) as a1,cast(a1 as int)*4 from s3object;","true,4\n"); test_single_column_single_row("select (1 > 2) from s3object;","false\n"); test_single_column_single_row("select case when (nullif(3,3) is null) = true then \"case-1-1\" else \"case-2-2\" end, case when (\"a\" in (\"a\",\"b\")) = true then \"case-3-3\" else \"case-4-4\" end, case when 1>3 then \"case_5_5\" else \"case-6-6\" end from s3object where (3*3 = 9);","case-1-1,case-3-3,case-6-6\n"); + test_single_column_single_row("select (not 'any_string') from s3object;","false\n"); } TEST(TestS3selectFunctions, boolcast)