commit 8cc76b5: [Minor] Clickhouse: one more text related fix

Vsevolod Stakhov vsevolod at highsecure.ru
Thu Nov 26 14:42:06 UTC 2020


Author: Vsevolod Stakhov
Date: 2020-11-26 14:39:05 +0000
URL: https://github.com/rspamd/rspamd/commit/8cc76b5f2fde9e664221832ab414c23ac9af3dfd (HEAD -> master)

[Minor] Clickhouse: one more text related fix

---
 lualib/lua_clickhouse.lua | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/lualib/lua_clickhouse.lua b/lualib/lua_clickhouse.lua
index 4e20229b0..42dba7dc8 100644
--- a/lualib/lua_clickhouse.lua
+++ b/lualib/lua_clickhouse.lua
@@ -60,9 +60,12 @@ end
 -- Converts an array to a string suitable for clickhouse
 local function array_to_string(ar)
   for i,elt in ipairs(ar) do
-    if type(elt) == 'string' then
-      ar[i] = '\'' .. clickhouse_quote(elt) .. '\''
-    elseif type(elt) == 'number' then
+    local t = type(elt)
+    if t == 'string' then
+      ar[i] = string.format('\'%s\'', clickhouse_quote(elt))
+    elseif t == 'userdata' then
+      ar[i] = string.format('\'%s\'', clickhouse_quote(tostring(elt)))
+    elseif t == 'number' then
       ar[i] = ch_number(elt)
     end
   end


More information about the Commits mailing list