提交 fd7f1268 编写于 作者: wmmhello's avatar wmmhello

TD-6129<feature> fix error if json key not the same type

上级 bb82a7aa
...@@ -2322,7 +2322,10 @@ int32_t addProjectionExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, t ...@@ -2322,7 +2322,10 @@ int32_t addProjectionExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, t
if (tokenId == TK_ARROW && pSchema->type != TSDB_DATA_TYPE_JSON) { if (tokenId == TK_ARROW && pSchema->type != TSDB_DATA_TYPE_JSON) {
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg4); return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg4);
} }
if(pSchema->type == TSDB_DATA_TYPE_JSON && tokenId == TK_ARROW){
pItem->aliasName = calloc(1, pItem->pNode->exprToken.n + 1);
memcpy(pItem->aliasName, pItem->pNode->exprToken.z, pItem->pNode->exprToken.n);
}
addProjectQueryCol(pQueryInfo, startPos, &index, pItem, getNewResColId(pCmd)); addProjectQueryCol(pQueryInfo, startPos, &index, pItem, getNewResColId(pCmd));
pQueryInfo->type |= TSDB_QUERY_TYPE_PROJECTION_QUERY; pQueryInfo->type |= TSDB_QUERY_TYPE_PROJECTION_QUERY;
} }
......
...@@ -235,7 +235,13 @@ class TDTestCase: ...@@ -235,7 +235,13 @@ class TDTestCase:
tdSql.checkRows(3) tdSql.checkRows(3)
# test chinese # test chinese
tdSql.execute("CREATE TABLE if not exists db_json_tag_test.jsons1_11 using db_json_tag_test.jsons1 tags('{\"k1\":\"中国\",\"k2\":\"是是是\"}')") tdSql.execute("CREATE TABLE if not exists db_json_tag_test.jsons1_11 using db_json_tag_test.jsons1 tags('{\"k1\":\"中国\",\"k5\":\"是是是\"}')")
tdSql.query("select tbname,jtag from db_json_tag_test.jsons1 where jtag->'k1' match '中'")
tdSql.checkRows(1)
tdSql.query("select tbname,jtag from db_json_tag_test.jsons1 where jtag->'k1'='中国'")
tdSql.checkRows(1)
def stop(self): def stop(self):
tdSql.close() tdSql.close()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册