Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update JSON type column from JSON 'null' to database NULL dost not work #37852

Closed
Mini256 opened this issue Sep 15, 2022 · 0 comments · Fixed by #37866
Closed

Update JSON type column from JSON 'null' to database NULL dost not work #37852

Mini256 opened this issue Sep 15, 2022 · 0 comments · Fixed by #37866
Assignees
Labels
severity/major sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.

Comments

@Mini256
Copy link
Member

Mini256 commented Sep 15, 2022

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

CREATE TABLE `t1` (
  `id` int(11) NOT NULL,
  `json` json DEFAULT NULL,
  PRIMARY KEY (`id`) /*T![clustered_index] CLUSTERED */
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
mysql> INSERT INTO t1 VALUES(1, 'null');
Query OK, 1 row affected (0.01 sec)

mysql> SELECT IFNULL(json, 'it is db null') FROM t1;
+-------------------------------+
| IFNULL(json, 'it is db null') |
+-------------------------------+
| null                          |
+-------------------------------+
1 row in set (0.01 sec)

mysql> UPDATE `t1` SET json = null WHERE id = 1;
Query OK, 0 rows affected (0.01 sec)
Rows matched: 1  Changed: 0  Warnings: 0

mysql> SELECT IFNULL(json, 'it is db null') FROM t1;
+-------------------------------+
| IFNULL(json, 'it is db null') |
+-------------------------------+
| null                          |
+-------------------------------+
1 row in set (0.00 sec)

If you change from other values to NULL, it works.

mysql> UPDATE `t1` SET json = '{}' WHERE id = 1;
Query OK, 1 row affected (0.02 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> UPDATE `t1` SET json = null WHERE id = 1;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> SELECT IFNULL(json, 'it is db null') FROM t1;
+-------------------------------+
| IFNULL(json, 'it is db null') |
+-------------------------------+
| it is db null                 |
+-------------------------------+
1 row in set (0.00 sec)

2. What did you expect to see? (Required)

Should work when updating NULL value for the JSON type column with 'null' value.

3. What did you see instead (Required)

Update JSON type column from JSON 'null' to database NULL does not work, as the result Changed: 0.

4. What is your TiDB version? (Required)

mysql> SELECT tidb_version()\G
*************************** 1. row ***************************
tidb_version(): Release Version: v6.2.0
Edition: Community
Git Commit Hash: daf2b17cdfe30c02ce282361009fb5bdb05f2b0e
Git Branch: heads/refs/tags/v6.2.0
UTC Build Time: 2022-08-22 13:38:40
GoVersion: go1.18.5
Race Enabled: false
TiKV Min Version: 6.2.0-alpha
Check Table Before Drop: false
Store: tikv
1 row in set (0.00 sec)
@Mini256 Mini256 added the type/bug The issue is confirmed as a bug. label Sep 15, 2022
@Mini256 Mini256 changed the title Update JSON type column from json 'null' to database NULL dost not work Update JSON type column from JSON 'null' to database NULL dost not work Sep 15, 2022
@YangKeao YangKeao self-assigned this Sep 15, 2022
@ti-chi-bot ti-chi-bot added may-affects-4.0 This bug maybe affects 4.0.x versions. may-affects-5.0 This bug maybe affects 5.0.x versions. may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.0 may-affects-6.1 may-affects-6.2 may-affects-6.3 labels Sep 16, 2022
@jebter jebter added the sig/sql-infra SIG: SQL Infra label Sep 16, 2022
@xiongjiwei xiongjiwei removed may-affects-4.0 This bug maybe affects 4.0.x versions. may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-5.0 This bug maybe affects 5.0.x versions. may-affects-6.0 may-affects-6.1 may-affects-6.2 may-affects-6.3 labels Sep 16, 2022
ti-chi-bot pushed a commit that referenced this issue Sep 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity/major sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants