From d388b2d1d3809aa2b693833f02ff77d6f27567b3 Mon Sep 17 00:00:00 2001 From: wshwsh12 <793703860@qq.com> Date: Wed, 17 May 2023 15:34:47 +0800 Subject: [PATCH] add ut --- expression/integration_test.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/expression/integration_test.go b/expression/integration_test.go index 2e0277ff0763f..ea12765fcf567 100644 --- a/expression/integration_test.go +++ b/expression/integration_test.go @@ -7910,3 +7910,16 @@ func TestAesDecryptionVecEvalWithZeroChunk(t *testing.T) { tk.MustExec("insert into test values(aes_encrypt('a', 'x'), aes_encrypt('b', 'x'))") tk.MustQuery("SELECT * FROM test WHERE CAST(AES_DECRYPT(name1, 'x') AS CHAR) = '00' AND CAST(AES_DECRYPT(name2, 'x') AS CHAR) = '1'").Check(testkit.Rows()) } + +func TestIfFunctionWithNull(t *testing.T) { + // issue 43805 + store := testkit.CreateMockStore(t) + + tk := testkit.NewTestKit(t, store) + tk.MustExec("use test") + tk.MustExec("drop table if exists ordres;") + tk.MustExec("CREATE TABLE orders (id bigint(20) unsigned NOT NULL ,account_id bigint(20) unsigned NOT NULL DEFAULT '0' ,loan bigint(20) unsigned NOT NULL DEFAULT '0' ,stage_num int(20) unsigned NOT NULL DEFAULT '0' ,apply_time bigint(20) unsigned NOT NULL DEFAULT '0' ,PRIMARY KEY (id) /*T![clustered_index] CLUSTERED */,KEY idx_orders_account_id (account_id),KEY idx_orders_apply_time (apply_time));") + tk.MustExec("insert into orders values (20, 210802010000721168, 20000 , 2 , 1682484268727), (22, 210802010000721168, 35100 , 4 , 1650885615002);") + tk.MustQuery("select min(if(apply_to_now_days <= 30,loan,null)) as min, max(if(apply_to_now_days <= 720,loan,null)) as max from (select loan, datediff(from_unixtime(unix_timestamp() + 18000), from_unixtime(apply_time/1000 + 18000)) as apply_to_now_days from orders) t1;").Sort().Check( + testkit.Rows("20000 35100")) +}