diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 60001099c88373a422dc311a14348351b0b05992..915bb113816310f7fb0fe6e8349e8f2dc1a097e6 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -4464,7 +4464,9 @@ static int32_t validateMatchExpr(tSqlExpr* pExpr, STableMeta* pTableMeta, int32_ } SSchema* pSchema = tscGetTableSchema(pTableMeta); - if ((pLeft->tokenId != TK_ARROW) && (!isTablenameToken(&pLeft->columnName)) && (pSchema[index].type != TSDB_DATA_TYPE_BINARY)) { + if ((pLeft->tokenId != TK_ARROW) && (!isTablenameToken(&pLeft->columnName)) + && (pSchema[index].type != TSDB_DATA_TYPE_BINARY) + && (pSchema[index].type == TSDB_DATA_TYPE_JSON && !JSON_TYPE_BINARY)) { return invalidOperationMsg(msgBuf, msg2); } diff --git a/tests/pytest/stable/json_tag.py b/tests/pytest/stable/json_tag.py index ae57819b2709ed43a581812a327f055bb93015ea..3d239c62de8ea32d1166709bf351ff78d3e1ecea 100644 --- a/tests/pytest/stable/json_tag.py +++ b/tests/pytest/stable/json_tag.py @@ -94,6 +94,20 @@ class TDTestCase: tdSql.query("select *,tbname from db_json_tag_test.jsons1 where jtag->'num'=5 or jtag?'sex'") tdSql.checkRows(2) + # test with tbname + tdSql.query("select * from db_json_tag_test.jsons1 where tbname = 'jsons1_1'") + tdSql.checkRows(1) + + tdSql.query("select * from db_json_tag_test.jsons1 where tbname = 'jsons1_1' or jtag?'num'") + tdSql.checkRows(3) + + tdSql.query("select * from db_json_tag_test.jsons1 where tbname = 'jsons1_1' and jtag?'num'") + tdSql.checkRows(0) + + tdSql.query("select * from db_json_tag_test.jsons1 where tbname = 'jsons1_1' or jtag->'num'=5") + tdSql.checkRows(2) + + def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__)