Skip to content

Cannot convert JSON number to number #477

@andremarianiello

Description

@andremarianiello

With MySQL

mysql> select JSON_EXTRACT('{"id":234}', '$.id')-1;
+--------------------------------------+
| JSON_EXTRACT('{"id":234}', '$.id')-1 |
+--------------------------------------+
|                                  233 |
+--------------------------------------+
1 row in set (0.00 sec)

mysql> select JSON_EXTRACT('{"id":234}', '$.id') = 234;
+------------------------------------------+
| JSON_EXTRACT('{"id":234}', '$.id') = 234 |
+------------------------------------------+
|                                        1 |
+------------------------------------------+
1 row in set (0.00 sec)

With go-mysql-server

MySQL [(none)]> select JSON_EXTRACT('{"id":234}', '$.id')-1;
ERROR 1105 (HY000): unable to cast sql.JSONDocument{Val:234} of type sql.JSONDocument to float64
MySQL [(none)]> select JSON_EXTRACT('{"id":234}', '$.id') = 234;
+------------------------------------------+
| JSON_EXTRACT('{"id":234}', '$.id') = 234 |
+------------------------------------------+
|                                        0 |
+------------------------------------------+
1 row in set (0.002 sec)```

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions