Description:
nullif(nullif(json_object(),"anything"),json_object())
should return null. it returns "{}"
select nullif(nullif(json_object(),json_array()),json_object());
mysql> select nullif(nullif(json_object(),"anything"),json_object()) as nested , nullif(json_object(),json_object()) as single;
+--------+--------+
| nested | single |
+--------+--------+
| {} | NULL |
+--------+--------+
1 row in set, 1 warning (0.00 sec)
mysql> show warnings;
+---------+------+-------------------------------------------------------------------------+
| Level | Code | Message |
+---------+------+-------------------------------------------------------------------------+
| Warning | 3156 | Invalid JSON value for CAST to INTEGER from column json_object at row 1 |
+---------+------+-------------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql>
(the problem is NOT the "anything". The same problem occurs if that value is clearly a json: for example:
mysql> select nullif(nullif(json_object(),json_array()),json_object());
+----------------------------------------------------------+
| nullif(nullif(json_object(),json_array()),json_object()) |
+----------------------------------------------------------+
| {} |
+----------------------------------------------------------+
1 row in set, 1 warning (0.00 sec)
mysql> show warnings;
+---------+------+-------------------------------------------------------------------------+
| Level | Code | Message |
+---------+------+-------------------------------------------------------------------------+
| Warning | 3156 | Invalid JSON value for CAST to INTEGER from column json_object at row 1 |
+---------+------+-------------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql>
How to repeat:
select nullif(nullif(json_object(),"anything"),json_object()) as nested , nullif(json_object(),json_object()) as single;
show warnings;
select nullif(nullif(json_object(),json_array()),json_object());
show warnings;