CTE's don't respond with JSON format
Closed this issue · 3 comments
mike-luabase commented
Queries with a CTE respond with the data as text without the normal JSON structure
let sql = `
with a1 as (select 1)
select * from a1
`
const d = await clickhouse.query(sql).toPromise();
console.log('clickhouse result: ', d)
result
clickhouse result: 1 2
Using clickhouse-client
lua-2 :) with a1 as (select 1 as a)
select a, 2 as b from a1
WITH a1 AS
(
SELECT 1 AS a
)
SELECT
a,
2 AS b
FROM a1
Query id: e5d31289-c52c-425a-90f1-d87786ac8298
┌─a─┬─b─┐
│ 1 │ 2 │
└───┴───┘
1 rows in set. Elapsed: 0.133 sec.
mike-luabase commented
ClickHouse client version 21.12.3.32 (official build).
Connected to ClickHouse server version 21.12.3 revision 54452.
mike-luabase commented
As mentioned here, adding with
to this regex appears to fix the issue
if (query.match(/^(select|with|show|exists)/i)) {
TimonKK commented
The fix has been released