clickhouse-activerecord 0.4.11 → 0.4.12
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: ad0ad1c7545498f275ff975d35ee9dde7d2f644516932ee33ab65796360426a0
|
4
|
+
data.tar.gz: 15b32b155c596c8cdd9e187681a128a4806ca7e2c457e0f833ffc66ba9c994af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f80ffc1c70dbbdd489ea59627e85a72f538276c80adc0fe5ee4319c222a61da2acd1680ea42bd8c4c4b713fb354f7498a3469cc3cfd17f9003c8dbd607719b2
|
7
|
+
data.tar.gz: 9c91108f18bb9b133708a682ee3dfec238cc54afac480fcada95e876bb051843a7269e3d81c6298299b1bbffbc5a8a47975add7919144d220845fd87c710122b
|
data/README.md
CHANGED
@@ -35,6 +35,21 @@ default: &default
|
|
35
35
|
replica_name: '{replica}' # replica macros name, optional for creating replicated tables
|
36
36
|
```
|
37
37
|
|
38
|
+
Alternatively if you wish to pass a custom `Net::HTTP` transport (or any other
|
39
|
+
object which supports a `.post()` function with the same parameters as
|
40
|
+
`Net::HTTP`'s), you can do this directly instead of specifying
|
41
|
+
`host`/`port`/`ssl`:
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
class ActionView < ActiveRecord::Base
|
45
|
+
establish_connection(
|
46
|
+
adapter: 'clickhouse',
|
47
|
+
database: 'database',
|
48
|
+
connection: Net::HTTP.start('http://example.org', 8123)
|
49
|
+
)
|
50
|
+
end
|
51
|
+
```
|
52
|
+
|
38
53
|
## Usage in Rails 5
|
39
54
|
|
40
55
|
Add your `database.yml` connection information with postfix `_clickhouse` for you environment:
|
@@ -17,8 +17,10 @@ module ActiveRecord
|
|
17
17
|
def exec_query(sql, name = nil, binds = [], prepare: false)
|
18
18
|
result = do_execute(sql, name)
|
19
19
|
ActiveRecord::Result.new(result['meta'].map { |m| m['name'] }, result['data'])
|
20
|
-
rescue
|
21
|
-
raise
|
20
|
+
rescue ActiveRecord::ActiveRecordError => e
|
21
|
+
raise e
|
22
|
+
rescue StandardError => e
|
23
|
+
raise ActiveRecord::ActiveRecordError, "Response: #{e.message}"
|
22
24
|
end
|
23
25
|
|
24
26
|
def exec_update(_sql, _name = nil, _binds = [])
|
@@ -17,9 +17,18 @@ module ActiveRecord
|
|
17
17
|
# Establishes a connection to the database that's used by all Active Record objects
|
18
18
|
def clickhouse_connection(config)
|
19
19
|
config = config.symbolize_keys
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
if config[:connection]
|
21
|
+
connection = {
|
22
|
+
connection: config[:connection]
|
23
|
+
}
|
24
|
+
else
|
25
|
+
port = config[:port] || 8123
|
26
|
+
connection = {
|
27
|
+
host: config[:host] || 'localhost',
|
28
|
+
port: port,
|
29
|
+
ssl: config[:ssl].present? ? config[:ssl] : port == 443,
|
30
|
+
}
|
31
|
+
end
|
23
32
|
|
24
33
|
if config.key?(:database)
|
25
34
|
database = config[:database]
|
@@ -27,7 +36,7 @@ module ActiveRecord
|
|
27
36
|
raise ArgumentError, 'No database specified. Missing argument: database.'
|
28
37
|
end
|
29
38
|
|
30
|
-
ConnectionAdapters::ClickhouseAdapter.new(logger,
|
39
|
+
ConnectionAdapters::ClickhouseAdapter.new(logger, connection, { user: config[:username], password: config[:password], database: database }.compact, config)
|
31
40
|
end
|
32
41
|
end
|
33
42
|
end
|
@@ -325,7 +334,7 @@ module ActiveRecord
|
|
325
334
|
private
|
326
335
|
|
327
336
|
def connect
|
328
|
-
@connection = Net::HTTP.start(@connection_parameters[
|
337
|
+
@connection = @connection_parameters[:connection] || Net::HTTP.start(@connection_parameters[:host], @connection_parameters[:port], use_ssl: @connection_parameters[:ssl], verify_mode: OpenSSL::SSL::VERIFY_NONE)
|
329
338
|
end
|
330
339
|
|
331
340
|
def apply_replica(table, options)
|
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: 0.4.
|
4
|
+
version: 0.4.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergey Odintsov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-04-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|