P粉5417963222023-09-04 00:14:38
BOOLEAN is not a built-in data type in MySQL. It is an alias and implemented as TINYINT(1).
Seehttps://dev.mysql.com/doc/refman/8.0/en/numeric-type-syntax.html
Use implicit data type conversion:
DECLARE p_array_only BOOL DEFAULT IFNULL(0 + JSON_EXTRACT(in_parameter, '$.array_only'), FALSE);
Fails if the corresponding value is of type string or null
.
https://dbfiddle.uk/?rdbms=mysql_8.0&fiddle=9c5fac2c7533d9e365a449ce00c06f1b
PS. The short form DEFAULT IFNULL(0 in_parameter->'$.array_only', FALSE);
is also useful.
PPS. Of course, explicit CAST() can also be used.