bugfix: json_set order & JsonBaseCmp bugfix
This commit is contained in:
@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -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