Skip to content

Commit

Permalink
[Fix] Clickhouse: Fix quoting
Browse files Browse the repository at this point in the history
Issue: #2928
  • Loading branch information
vstakhov committed Jun 17, 2019
1 parent e39008c commit 5c81f0c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lualib/lua_clickhouse.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ end

local function clickhouse_quote(str)
if str then
return str:gsub('[\'\\]', '\\%1'):lower()
return str:gsub('[\'\\\n\t]', {
['\''] = '\\\'',
['\\'] = '\\',
['\n'] = '\\n',
['\t'] = '\\t'
}):lower()
end

return ''
Expand All @@ -71,6 +76,8 @@ local function row_to_tsv(row)
row[i] = '[' .. array_to_string(elt) .. ']'
elseif type(elt) == 'number' then
row[i] = ch_number(elt)
else
row[i] = clickhouse_quote(elt)
end
end

Expand Down

0 comments on commit 5c81f0c

Please sign in to comment.