Skip to content

Commit a0ca8d5

Browse files
committed
fix spec for clickhouse 25
1 parent 88fbd18 commit a0ca8d5

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

spec/single/streaming_spec.rb

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,41 @@ class Model < ActiveRecord::Base
1414
it 'simple' do
1515
path = Model.connection.execute_streaming('SELECT count(*) AS count FROM sample')
1616
expect(path.is_a?(String)).to be_truthy
17-
expect(File.read(path)).to eq("[\"count\"]\n[\"UInt64\"]\n[\"0\"]\n")
17+
if Model.connection.server_version.to_f < 25
18+
expect(File.read(path)).to eq("[\"count\"]\n[\"UInt64\"]\n[\"0\"]\n")
19+
else
20+
expect(File.read(path)).to eq("[\"count\"]\n[\"UInt64\"]\n[0]\n")
21+
end
1822
end
1923

2024
it 'JSONCompact format' do
2125
path = Model.connection.execute_streaming('SELECT count(*) AS count FROM sample', format: 'JSONCompact')
2226
data = JSON.parse(File.read(path))
23-
expect(data['data'][0][0]).to eq('0')
27+
if Model.connection.server_version.to_f < 25
28+
expect(data['data'][0][0]).to eq('0')
29+
else
30+
expect(data['data'][0][0]).to eq(0)
31+
end
2432
end
2533

2634
it 'JSONEachRow format' do
2735
path = Model.connection.execute_streaming('SELECT count(*) AS count FROM sample', format: 'JSONEachRow')
2836
data = JSON.parse(File.read(path))
29-
expect(data['count']).to eq('0')
37+
if Model.connection.server_version.to_f < 25
38+
expect(data['count']).to eq('0')
39+
else
40+
expect(data['data'][0][0]).to eq(0)
41+
end
3042
end
3143

3244
it 'multiple rows JSONEachRow format' do
3345
path = Model.connection.execute_streaming('SELECT * FROM generate_series(1, 1000000)', format: 'JSONEachRow')
3446
lines = File.readlines(path)
35-
expect(JSON.parse(lines[0])).to eq('generate_series' => '1')
47+
if Model.connection.server_version.to_f < 25
48+
expect(JSON.parse(lines[0])).to eq('generate_series' => '1')
49+
else
50+
expect(JSON.parse(lines[0])).to eq('generate_series' => 1)
51+
end
3652
expect(lines.size).to eq(1000000)
3753
end
3854

0 commit comments

Comments
 (0)