[Improve](json-array) Support json array with nereids bool (#20248)

Support json array with nereids bool
now : 

```
set enable_nereids_planner=true;
mysql> SELECT json_array(1, "abc", NULL, TRUE, '10:00:00');
+----------------------------------------------+
| json_array(1, 'abc', NULL, TRUE, '10:00:00') |
+----------------------------------------------+
| [1,"abc",null,false,"10:00:00"]              |
+----------------------------------------------+
1 row in set (0.02 sec)
```
 
nereids boolean is "true"/"false" is not '0' /'1' , so we always get false
This commit is contained in:
amory
2023-06-02 14:47:24 +08:00
committed by GitHub
parent 098c735064
commit 06e7c14320

View File

@ -547,7 +547,9 @@ struct JsonParser<'1'> {
// bool
static void update_value(StringParser::ParseResult& result, rapidjson::Value& value,
StringRef data, rapidjson::Document::AllocatorType& allocator) {
value.SetBool((*data.data == '1') ? true : false);
DCHECK(data.size == 1 || strncmp(data.data, "true", 4) == 0 ||
strncmp(data.data, "false", 5) == 0);
value.SetBool((*data.data == '1' || *data.data == 't') ? true : false);
}
};