click_house 1.2.2 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4819eadc5f15e518ec76343f471e7e792e07323e1a390fdc9cea34f15fbd329c
4
- data.tar.gz: 80849b1ae3da0359031a0e0d7e2e4d31071c03a7f48142e8c236e4a440534c05
3
+ metadata.gz: cbc27532a4abd9eab176f4c1816bae63d4b4d379bbd0f2ab24c4e6fd1d3a7178
4
+ data.tar.gz: ff239f24529edda890282222c8aa58e93c0d9d65f1376a1ee38a9371d770e893
5
5
  SHA512:
6
- metadata.gz: c785b30094baab0ba6a465eea9e02e0540b36b76b743dd456f2ed26b93510b38fde5b0a986e6e98880dc1527146c525d4de7a907404cbe6149f69c47f993fab3
7
- data.tar.gz: f89cdef75b3bdf93b90359f170d55e143710d9797db9138b99ff943af5a0e0718c6858c49210fccbd044b825875d7fec4dc3540aa70db8ab0939bfd95c80a814
6
+ metadata.gz: d4eb18c92e8489be5b0cc63cd578ef7359619ec0972ec96f9efccc0b145a9347a8de320a34a88eaec366f99c0c2c19733d59bcd2acd3104f80e02149db6f2d2f
7
+ data.tar.gz: 59ce90b17994fb5bd334dbfb8181faf6a16d8514f302e89b673f45164ebd3a493e71fb96b02de510b70ca8cadefc232d13bb2d9d15b1cb2b2530efef43e4587d
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- click_house (1.2.2)
4
+ click_house (1.2.3)
5
5
  faraday
6
6
  faraday_middleware
7
7
 
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ COPYRIGHT (C) 2019 ALIAKSANDR SHYLAU
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -73,7 +73,8 @@ Now you are able to communicate with ClickHouse:
73
73
  ```ruby
74
74
  ClickHouse.connection.ping #=> true
75
75
  ```
76
- You can easily build a new raw connection
76
+ You can easily build a new raw connection and override any configuration parameter
77
+ (such as database name, connection address)
77
78
 
78
79
  ```ruby
79
80
  @connection = ClickHouse::Connection.new(ClickHouse::Config.new(logger: Rails.logger))
@@ -175,6 +176,8 @@ response.body #=> "\u0002\u0000\u0000\u0000\u0000\u0000\u0000\u0000"
175
176
 
176
177
  ## Insert
177
178
 
179
+ When column names and values are transferred separately
180
+
178
181
  ```ruby
179
182
  ClickHouse.connection.insert('table', columns: %i[id name]) do |buffer|
180
183
  buffer << [1, 'Mercury']
@@ -185,6 +188,19 @@ ClickHouse.connection.insert('table', columns: %i[id name], values: [[1, 'Mercur
185
188
  #=> true
186
189
  ```
187
190
 
191
+ When rows are passed as a hash
192
+
193
+
194
+ ```ruby
195
+ ClickHouse.connection.insert('table', values: [{ name: 'Sun', id: 1 }, { name: 'Moon', id: 2 }])
196
+
197
+ ClickHouse.connection.insert('table') do |buffer|
198
+ buffer << { name: 'Sun', id: 1 }
199
+ buffer << { name: 'Moon', id: 2 }
200
+ end
201
+ #=> true
202
+ ```
203
+
188
204
  ## Create a table
189
205
  ### Create table using DSL
190
206
 
@@ -442,14 +458,14 @@ You can clear the data table before each test with RSpec
442
458
 
443
459
  ```ruby
444
460
  RSpec.configure do |config|
445
- config.before(:each, clean_click_house: true) do
461
+ config.before(:each, truncate_click_house: true) do
446
462
  ClickHouse.connection.truncate_tables
447
463
  end
448
464
  end
449
465
  ```
450
466
 
451
467
  ```ruby
452
- RSpec.describe Api::MetricsCountroller, clean_click_house: true do
468
+ RSpec.describe Api::MetricsCountroller, truncate_click_house: true do
453
469
  it { }
454
470
  it { }
455
471
  end
@@ -3,11 +3,13 @@
3
3
  module ClickHouse
4
4
  module Extend
5
5
  module ConnectionInserting
6
- def insert(table, columns:, values: [])
6
+ def insert(table, columns: [], values: [])
7
7
  yield(values) if block_given?
8
8
 
9
- body = values.map do |value_row|
10
- columns.zip(value_row).to_h.to_json
9
+ body = if columns.empty?
10
+ values.map(&:to_json)
11
+ else
12
+ values.map { |value_row| columns.zip(value_row).to_h.to_json }
11
13
  end
12
14
 
13
15
  execute("INSERT INTO #{table} FORMAT JSONEachRow", body.join("\n")).success?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ClickHouse
4
- VERSION = '1.2.2'
4
+ VERSION = '1.2.3'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: click_house
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aliaksandr Shylau
@@ -135,6 +135,7 @@ files:
135
135
  - ".travis.yml"
136
136
  - Gemfile
137
137
  - Gemfile.lock
138
+ - LICENCE.txt
138
139
  - Makefile
139
140
  - README.md
140
141
  - Rakefile