Skip to content

Failed to excute redis_command when json filed's value include white space #3

@gettyying

Description

@gettyying

Like as below:

mysql> select @a := json_object(topic as topic) from test limit 1;
+-----------------------------------+
| @a := json_object(topic as topic) |
+-----------------------------------+
| {"topic":"你 我 他 她"}           |
+-----------------------------------+
1 row in set (0.00 sec)

mysql> set @b := concat("hset \"htest\" \"1\" \"", @a, "\"");
Query OK, 0 rows affected (0.00 sec)

mysql> select @b;
+------------------------------------------------+
| @b                                             |
+------------------------------------------------+
| hset "htest" "1" "{"topic":"你 我 他 她"}"     |
+------------------------------------------------+
1 row in set (0.00 sec)

mysql> select redis_command("127.0.0.1",6379, @b);
+-------------------------------------+
| redis_command("127.0.0.1",6379, @b) |
+-------------------------------------+
|                                   3 |
+-------------------------------------+
1 row in set (0.00 sec)

But it's succeed when wrap off white space.

mysql> select @a := json_object(replace(topic, " " , "") as topic) from test limit 1;
+------------------------------------------------------+
| @a := json_object(replace(topic, " " , "") as topic) |
+------------------------------------------------------+
| {"topic":"你我他她"}                                 |
+------------------------------------------------------+
1 row in set (0.00 sec)

mysql> set @b := concat("hset 'htest' '1' '", @a, "'");
Query OK, 0 rows affected (0.00 sec)

mysql> select redis_command("127.0.0.1",6379, @b);
+-------------------------------------+
| redis_command("127.0.0.1",6379, @b) |
+-------------------------------------+
|                                   0 |
+-------------------------------------+
1 row in set (0.00 sec)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions