bugfix: json_set order & JsonBaseCmp bugfix
This commit is contained in:
10
deps/oblib/src/lib/json_type/ob_json_base.cpp
vendored
10
deps/oblib/src/lib/json_type/ob_json_base.cpp
vendored
@ -29,15 +29,15 @@ namespace common {
|
||||
|
||||
struct ObJsonBaseCmp {
|
||||
bool operator()(const ObIJsonBase *a, const ObIJsonBase *b) {
|
||||
bool is_eq = false;
|
||||
bool is_less = false;
|
||||
if (a->is_tree() && b->is_tree()) {
|
||||
is_eq = (a == b);
|
||||
is_less = (a < b);
|
||||
} else if (a->is_bin() && b->is_bin()) {
|
||||
is_eq = (a->get_data() == b->get_data());
|
||||
is_less = (a->get_data() < b->get_data());
|
||||
} else {
|
||||
LOG_WARN_RET(OB_ERR_UNEXPECTED, "unexpected type", K(OB_ERR_UNEXPECTED), K(*a), K(*b));
|
||||
}
|
||||
return is_eq;
|
||||
return is_less;
|
||||
}
|
||||
};
|
||||
|
||||
@ -620,7 +620,7 @@ int ObIJsonBase::find_array_child(ObIAllocator* allocator, ObSeekParentInfo &par
|
||||
if (is_lax) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("should be mysql mode!", K(ret), K(only_need_one));
|
||||
}else if (cur_json_type == ObJsonNodeType::J_ARRAY) {
|
||||
} else if (cur_json_type == ObJsonNodeType::J_ARRAY) {
|
||||
if (OB_FAIL(find_array_range(allocator, parent_info, cur_node, last_node, path_node,
|
||||
is_auto_wrap, only_need_one, is_lax, dup, res, sql_var))) {
|
||||
LOG_WARN("fail in find array range.", K(ret));
|
||||
|
||||
@ -95,8 +95,12 @@ int ObExprJsonSet::set_value(ObJsonBaseVector &hit, ObIJsonBase *&json_doc, ObIJ
|
||||
} else {
|
||||
ObJsonArray* json_array = (ObJsonArray*)new(array_buf)ObJsonArray(allocator);
|
||||
ObJsonNode *j_parent = static_cast<ObJsonNode *>(pos_node)->get_parent();
|
||||
if (OB_FAIL(json_array->array_append(pos_node))
|
||||
|| OB_FAIL(json_array->array_append(json_val))) {
|
||||
bool is_idx_from_end = path_last->node_content_.array_cell_.is_index_from_end_;
|
||||
if (!is_idx_from_end && (OB_FAIL(json_array->array_append(pos_node))
|
||||
|| OB_FAIL(json_array->array_append(json_val)))) {
|
||||
LOG_WARN("error, array append node failed", K(ret));
|
||||
} else if (is_idx_from_end && (OB_FAIL(json_array->array_append(json_val))
|
||||
|| OB_FAIL(json_array->array_append(pos_node)))) {
|
||||
LOG_WARN("error, array append node failed", K(ret));
|
||||
} else if (OB_ISNULL(j_parent)){
|
||||
json_doc = json_array;
|
||||
|
||||
Reference in New Issue
Block a user