gpt4 book ai didi

mysql - array.array 的 JSON_REMOVE 导致 "path expressions may not contain the * and ** tokens"错误

转载 作者:行者123 更新时间:2023-11-29 03:24:17 25 4
gpt4 key购买 nike

如果我这样做:SELECT JSON_REMOVE(@I, '$.friends[*].name');SELECT JSON_REMOVE(@I, '$.friends[*]. friends'); 在下面的 JSON 中,我得到了这个错误:

ERROR 3149 (42000): In this situation, path expressions may not contain the * and ** tokens.

JSON:

SET @I = '{
"name": "Alice",
"friends": [
{
"name": "Bob",
"friends": [
{
"name": "Carl",
"friends": []
},
{
"name": "Danny",
"friends": []
}
]
},
{
"name": "Edward",
"friends": [
{
"name": "Frank",
"friends": []
},
{
"name": "Gary",
"friends": []
}
]
}
]
}';

但是如果我执行 SELECT JSON_EXTRACT(@I, '$.friends[*].friends') 它返回结果很好.

[[{"friends": [], "name": "Carl"}, {"friends": [], "name": "Danny"}], [{"name": "Frank", "friends": []}, {"name": "Gary", "friends": []}]]

基本上我想返回一个字符串,其中删除了所有 friends.name,甚至可能删除了 friends.friends

最佳答案

json_removejson_set等函数好像MySQL不支持通配符

bool Item_func_json_remove::val_json(Json_wrapper *wr)
{
//bla-bla-bla
if (m_path_cache.parse_and_cache_path(args, path_idx + 1, true))
}

bool Json_path_cache::parse_and_cache_path(Item ** args, uint arg_idx,
bool forbid_wildcards)

https://github.com/mysql/mysql-server/blob/5.7/sql/item_json_func.cc#L3227 https://github.com/mysql/mysql-server/blob/5.7/sql/item_json_func.cc#L2563 https://github.com/mysql/mysql-server/blob/5.7/sql/item_json_func.cc#L534

关于mysql - array.array 的 JSON_REMOVE 导致 "path expressions may not contain the * and ** tokens"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38890938/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com