From 563c36aa1ec56bfabc8e02f48e340d320bbd6424 Mon Sep 17 00:00:00 2001 From: lovewin99 Date: Fri, 19 Jul 2019 13:58:07 +0800 Subject: [PATCH] fix issue:#11102 Unexcepted result in `SELECT ... CASE WHEN ... ELSE NULL...` --- expression/integration_test.go | 13 +++++++++++++ session/session_test.go | 13 ------------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/expression/integration_test.go b/expression/integration_test.go index d1f7272f8eb68..febcd22bace4b 100644 --- a/expression/integration_test.go +++ b/expression/integration_test.go @@ -4460,3 +4460,16 @@ func (s *testIntegrationSuite) TestIssue10675(c *C) { testkit.Rows("1")) tk.MustQuery(`select * from t where a > 184467440737095516167.1;`).Check(testkit.Rows()) } + +func (s *testIntegrationSuite) TestFuncCaseWithLeftJoin(c *C) { + tk := testkit.NewTestKitWithInit(c, s.store) + + tk.MustExec("create table kankan1(id int, name text)") + tk.MustExec("insert into kankan1 values(1, 'a')") + tk.MustExec("insert into kankan1 values(2, 'a')") + + tk.MustExec("create table kankan2(id int, h1 text)") + tk.MustExec("insert into kankan2 values(2, 'z')") + + tk.MustQuery("select t1.id from kankan1 t1 left join kankan2 t2 on t1.id = t2.id where (case when t1.name='b' then 'case2' when t1.name='a' then 'case1' else NULL end) = 'case1' order by t1.id").Check(testkit.Rows("1", "2")) +} diff --git a/session/session_test.go b/session/session_test.go index c86ea96588fc7..e7c01d368c0ce 100644 --- a/session/session_test.go +++ b/session/session_test.go @@ -2796,16 +2796,3 @@ func (s *testSessionSuite) TestLoadClientInteractive(c *C) { tk.Se.GetSessionVars().ClientCapability = tk.Se.GetSessionVars().ClientCapability | mysql.ClientInteractive tk.MustQuery("select @@wait_timeout").Check(testkit.Rows("28800")) } - -func (s *testSessionSuite) TestFuncCaseWithLeftJoin(c *C) { - tk := testkit.NewTestKitWithInit(c, s.store) - - tk.MustExec("create table kankan1(id int, name text)") - tk.MustExec("insert into kankan1 values(1, 'a')") - tk.MustExec("insert into kankan1 values(2, 'a')") - - tk.MustExec("create table kankan2(id int, h1 text)") - tk.MustExec("insert into kankan2 values(2, 'z')") - - tk.MustQuery("select t1.id from kankan1 t1 left join kankan2 t2 on t1.id = t2.id where (case when t1.name='b' then 'case2' when t1.name='a' then 'case1' else NULL end) = 'case1' order by t1.id").Check(testkit.Rows("1", "2")) -}