From 26e840770c77d6db6fee799b9c5f8e03672c3c25 Mon Sep 17 00:00:00 2001 From: xywang Date: Sun, 3 Apr 2022 15:48:18 +0800 Subject: [PATCH] [TS-1381]: fixed a schemaless insert error --- src/client/src/tscUtil.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index 11cea41050..917c37525a 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -116,9 +116,26 @@ int32_t converToStr(char *str, int type, void *buf, int32_t bufSize, int32_t *le return TSDB_CODE_TSC_INVALID_VALUE; } - *str = '\''; + bool squote = false; + for (int32_t i = 0; i < bufSize; ++i) { + if (((char *)buf)[i] == '\'') { + squote = true; + break; + } + } + + if (squote) { + *str = '\"'; + } else { + *str = '\''; + } + memcpy(str + 1, buf, bufSize); - *(str + bufSize + 1) = '\''; + if (squote) { + *(str + bufSize + 1) = '\"'; + } else { + *(str + bufSize + 1) = '\''; + } n = bufSize + 2; break; -- GitLab