clickhouse-activerecord 1.6.2 → 1.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a31a5e1d3ea2e5d069ce7167a472e1eb001e9a9dbae0245a3adbc82a1155436d
|
|
4
|
+
data.tar.gz: 6e690df8b5088073777b46098ff77659da3c7b1fa7c9593305a07e7f61df2d31
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 89075c98153b99021ba858ae4de186beff0ab537780f141d974480f8ac1d44a71dd751d15693c6b605a4fc956a537cb8026ddf5d5bd1d4eaaedd8d7863369ec3
|
|
7
|
+
data.tar.gz: c498273b5fd00c0acdd174315783d62220b52e4aa99ffb08f491c61fe5f7a76b3c0fd63bc5ea78c385f53c2947fee4c87f37317c868e0b9d38ece66eb6d92c5a
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
### Version 1.6.4 (Feb 13, 2026)
|
|
2
|
+
|
|
3
|
+
* Fix error: EOFError (end of file reached)
|
|
4
|
+
|
|
5
|
+
### Version 1.6.3 (Feb 04, 2026)
|
|
6
|
+
|
|
7
|
+
* Rename method `execute_streaming` to `execute_to_file`
|
|
8
|
+
|
|
1
9
|
### Version 1.6.2 (Jan 30, 2026)
|
|
2
10
|
|
|
3
11
|
* Add streaming request and save response to tmp file
|
data/README.md
CHANGED
|
@@ -238,7 +238,7 @@ Action.with(ActionView.select(Arel.sql('min(date)')) => :min_date).where(Arel.sq
|
|
|
238
238
|
### Streaming request
|
|
239
239
|
|
|
240
240
|
```ruby
|
|
241
|
-
path = Action.connection.
|
|
241
|
+
path = Action.connection.execute_to_file(Action.where(date: Date.current), format: 'CSVWithNames')
|
|
242
242
|
# Clickhouse Stream (10.3ms) SELECT actions.* FROM actions WHERE actions.date = '2017-11-29'
|
|
243
243
|
file = File.open(path)
|
|
244
244
|
```
|
|
@@ -53,14 +53,12 @@ module ActiveRecord
|
|
|
53
53
|
end
|
|
54
54
|
end
|
|
55
55
|
|
|
56
|
-
#
|
|
57
|
-
|
|
56
|
+
# Execute an SQL query and save the result to a file in stream mode
|
|
57
|
+
# @return [String]
|
|
58
|
+
def execute_to_file(sql, name = nil, format: @response_format, settings: {})
|
|
58
59
|
with_response_format(format) do
|
|
59
60
|
log(sql, [adapter_name, 'Stream', name].compact.join(' ')) do
|
|
60
|
-
|
|
61
|
-
request(statement, settings: settings) do |response|
|
|
62
|
-
return statement.streaming_response(response)
|
|
63
|
-
end
|
|
61
|
+
request(sql, settings: settings, streaming: true)
|
|
64
62
|
end
|
|
65
63
|
end
|
|
66
64
|
end
|
|
@@ -101,8 +99,7 @@ module ActiveRecord
|
|
|
101
99
|
# @link https://clickhouse.com/docs/en/sql-reference/statements/delete
|
|
102
100
|
def exec_delete(sql, name = nil, _binds = [])
|
|
103
101
|
log(sql, "#{adapter_name} #{name}") do
|
|
104
|
-
|
|
105
|
-
res = request(statement)
|
|
102
|
+
res = request(sql, raw_response: true)
|
|
106
103
|
begin
|
|
107
104
|
data = JSON.parse(res.header['x-clickhouse-summary'])
|
|
108
105
|
data['result_rows'].to_i
|
|
@@ -279,23 +276,30 @@ module ActiveRecord
|
|
|
279
276
|
end
|
|
280
277
|
|
|
281
278
|
def raw_execute(sql, settings: {}, except_params: [])
|
|
282
|
-
|
|
283
|
-
response = request(statement, settings: settings, except_params: except_params)
|
|
284
|
-
statement.processed_response(response)
|
|
279
|
+
request(sql, settings: settings, except_params: except_params)
|
|
285
280
|
end
|
|
286
281
|
|
|
287
282
|
# Make HTTP request to ClickHouse server
|
|
288
|
-
# @param [
|
|
283
|
+
# @param [String] sql
|
|
289
284
|
# @param [Hash] settings
|
|
290
285
|
# @param [Array] except_params
|
|
291
286
|
# @return [Net::HTTPResponse]
|
|
292
|
-
def request(
|
|
287
|
+
def request(sql, settings: {}, except_params: [], raw_response: false, streaming: false)
|
|
293
288
|
@lock.synchronize do
|
|
294
289
|
req = Net::HTTP::Post.new("/?#{settings_params(settings, except: except_params)}", {
|
|
295
290
|
'Content-Type' => 'application/x-www-form-urlencoded',
|
|
296
291
|
'User-Agent' => ClickhouseAdapter::USER_AGENT,
|
|
297
292
|
})
|
|
298
|
-
|
|
293
|
+
statement = Statement.new(sql, format: @response_format)
|
|
294
|
+
if streaming
|
|
295
|
+
@connection.request(req, statement.formatted_sql) do |response|
|
|
296
|
+
return statement.streaming_response(response)
|
|
297
|
+
end
|
|
298
|
+
else
|
|
299
|
+
response = @connection.request(req, statement.formatted_sql)
|
|
300
|
+
return response if raw_response
|
|
301
|
+
statement.processed_response(response)
|
|
302
|
+
end
|
|
299
303
|
end
|
|
300
304
|
end
|
|
301
305
|
|
|
@@ -85,10 +85,16 @@ module ClickhouseActiverecord
|
|
|
85
85
|
columns.each do |column|
|
|
86
86
|
raise StandardError, "Unknown type '#{column.sql_type}' for column '#{column.name}'" unless @connection.valid_type?(column.type)
|
|
87
87
|
next if column.name == pk && column.name == "id"
|
|
88
|
-
type, colspec = column_spec(column)
|
|
89
88
|
name = column.name =~ (/\./) ? "\"`#{column.name}`\"" : column.name.inspect
|
|
90
|
-
|
|
91
|
-
|
|
89
|
+
if column.sql_type.match?(/^(Simple)?AggregateFunction/)
|
|
90
|
+
tbl.print " t.column #{name}, #{column.sql_type.inspect}"
|
|
91
|
+
colspec = prepare_column_options(column)
|
|
92
|
+
tbl.print ", #{format_colspec(colspec)}" if colspec.present?
|
|
93
|
+
else
|
|
94
|
+
type, colspec = column_spec(column)
|
|
95
|
+
tbl.print " t.#{type} #{name}"
|
|
96
|
+
tbl.print ", #{format_colspec(colspec)}" if colspec.present?
|
|
97
|
+
end
|
|
92
98
|
tbl.puts
|
|
93
99
|
end
|
|
94
100
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: clickhouse-activerecord
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.6.
|
|
4
|
+
version: 1.6.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sergey Odintsov
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-02-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|