-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mysql/json: json_merge #1951
mysql/json: json_merge #1951
Conversation
Json::Array(array) | ||
} | ||
}; | ||
let mut left_num = suffixes.len(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
normally lhs & rhs will be a good name.
left_num
is ambiguous
let mut left_num = suffixes.len(); | ||
for suffix in suffixes { | ||
data = match (data, suffix) { | ||
(Json::Array(mut array), Json::Array(mut sub_array)) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will ref mut
works?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems not @andelf
} | ||
(obj, suffix) => { | ||
// rule 3, 4 | ||
let mut array = Vec::with_capacity(left_num + 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
? why left_num +1
} | ||
}; | ||
let mut left_num = suffixes.len(); | ||
for suffix in suffixes { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a Iterator::fold
pattern
#[test] | ||
fn test_merge() { | ||
let test_cases = vec![ | ||
(r#"{"a": 1}"#,r#"{"b": 2}"#, r#"{"a": 1, "b": 2}"#), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spaces
LGTM. |
LGTM |
Hi,
This PR implement
JSON_MERGE
for document, related PR intidb
is pingcap/tidb#3374, and the relate source file intidb
ishttps://github.com/pingcap/tidb/blob/master/util/types/json/functions.go#L208
@hhkbp2 @hicqu @andelf @lishihai9017 PTAL