From 4856586f68cf02f9f06b3793348ff7ec1530608f Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Tue, 21 Sep 2021 16:54:18 +0800 Subject: [PATCH] TD-6129 add json type check --- src/client/src/tscSQLParser.c | 4 ++-- tests/pytest/stable/json_tag.py | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 60fc6c2ef4..bd657c9c3c 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -6074,7 +6074,7 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) { } if(pItem->pVar.nType != TSDB_DATA_TYPE_BINARY){ tscError("json type error, should be string"); - return invalidOperationMsg(pMsg, "json type error, should be string"); + return invalidOperationMsg(pMsg, msg25); } code = parseJsontoTagData(pItem->pVar.pz, &kvRowBuilder, pMsg, pTagsSchema->colId); if (code != TSDB_CODE_SUCCESS) { @@ -7698,7 +7698,7 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) { tVariantListItem* pItem = taosArrayGet(pValList, 0); if(pItem->pVar.nType != TSDB_DATA_TYPE_BINARY){ tscError("json type error, should be string"); - return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), "json type error, should be string"); + return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg6); } ret = parseJsontoTagData(pItem->pVar.pz, &kvRowBuilder, tscGetErrorMsgPayload(pCmd), pTagSchema[0].colId); if (ret != TSDB_CODE_SUCCESS) { diff --git a/tests/pytest/stable/json_tag.py b/tests/pytest/stable/json_tag.py index edd6649f29..072d05b720 100644 --- a/tests/pytest/stable/json_tag.py +++ b/tests/pytest/stable/json_tag.py @@ -34,8 +34,12 @@ class TDTestCase: "create table if not exists db_json_tag_test.jsons1(ts timestamp, dataInt int, dataStr nchar(50)) tags(jtag json)") tdSql.execute( "CREATE TABLE if not exists db_json_tag_test.jsons1_1 using db_json_tag_test.jsons1 tags('{\"loc\":\"fff\",\"id\":5}')") + tdSql.execute( + "CREATE TABLE if not exists db_json_tag_test.jsons1_3 using db_json_tag_test.jsons1 tags(3333)") tdSql.execute( "insert into jsons1_2 using db_json_tag_test.jsons1 tags('{\"num\":5,\"location\":\"beijing\"}' values (now, 1, 'sss')") + tdSql.execute( + "insert into jsons1_4 using db_json_tag_test.jsons1 tags(3)") print("==============step2") tdLog.info("select table") -- GitLab