pingcap / pingcap/tidb

case when with json_extract not compatible with mysql-connector-java driver 5.1

Open
#48,004 5 comments 0 reactions 1 assignee Claimed by @YangKeao View on GitHub
affects-6.5 affects-7.1 affects-7.5 affects-8.1 component/json may-affects-5.3 may-affects-5.4 may-affects-6.1 report/community severity/moderate sig/sql-infra type/bug
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Bug Report

Please answer these questions before submitting your issue. Thanks!

### 1. Minimal reproduce step (Required)
1. using mysql-connector-java driver 5.1.47 to execute the query
```sql
select
t.v,

CASE
WHEN t.v > 2 THEN 1
ELSE IFNULL(JSON_EXTRACT('{}', '$.KEY'), 0)
END AS a,

CASE
WHEN t.v > 2 THEN 1
ELSE IFNULL(CONVERT(JSON_EXTRACT('{}', '$.KEY'), unsigned ), 0)
END AS b,

CASE
WHEN 1 > 2 THEN 1
ELSE IFNULL(JSON_EXTRACT('{}', '$.KEY'), 0)
END AS c,

IFNULL(JSON_EXTRACT('{}', '$.KEY'), 0) AS d,

CASE
WHEN t.v > 2 THEN 1
ELSE JSON_EXTRACT('{"KEY": 0}', '$.KEY')
END AS e,

IF(t.v > 2, 1, JSON_EXTRACT('{"KEY": 0}', '$.KEY'))
AS f,

CASE
WHEN 1 > 2 THEN 1
ELSE JSON_EXTRACT('{"KEY": 0}', '$.KEY')
END AS g

from (select 1 as v) t
;
```

for detail, you can see https://asktug.com/t/topic/1014654/1

### 2. What did you expect to see? (Required)
![图片](https://github.com/pingcap/tidb/assets/10184437/1e32da32-342e-4091-b23f-5611fc457add)

### 3. What did you see instead (Required)
![图片](https://github.com/pingcap/tidb/assets/10184437/b193eff3-f0c4-45cc-92d1-977d2c53114d)

### 4. What is your TiDB version? (Required)
master
v6.5.x
v7.1.x

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.