clickhouse-rails 0.1.3 → 0.1.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 +4 -4
 - data/Gemfile.lock +3 -3
 - data/lib/clickhouse/rails/version.rb +1 -1
 - data/lib/clickhouse/table.rb +13 -2
 - data/spec/table_spec.rb +11 -0
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: eb6df85b3e7c3c3a379067d3cb22e31afaa164f7277defa24362a06e71fea7b3
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 57f2f1aa8cf5a3a125341944a3eb7d8a2765111a2a2a9bde15dc7766644fda1c
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 387f1a3dfd4822e1a83cad4994429b1a2f0d0716de68c623ddc52b5785b469c50a1e0f0bc602a234ef865bedd4e2c1d99979bb6ee05927522ce9e30ea9c2c5e6
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 224d2b0a199ddf8ad88a948926c343fe6b66b9f2aa3013b7613259f4222187a3a8a07709bdcc5caccdd4c12423352f89d6426bb96706bf3d2a909ae638313262
         
     | 
    
        data/Gemfile.lock
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            PATH
         
     | 
| 
       2 
2 
     | 
    
         
             
              remote: .
         
     | 
| 
       3 
3 
     | 
    
         
             
              specs:
         
     | 
| 
       4 
     | 
    
         
            -
                clickhouse-rails (0.1. 
     | 
| 
      
 4 
     | 
    
         
            +
                clickhouse-rails (0.1.3)
         
     | 
| 
       5 
5 
     | 
    
         
             
                  clickhouse
         
     | 
| 
       6 
6 
     | 
    
         
             
                  railties
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
         @@ -68,7 +68,7 @@ GEM 
     | 
|
| 
       68 
68 
     | 
    
         
             
                method_source (0.9.2)
         
     | 
| 
       69 
69 
     | 
    
         
             
                mini_portile2 (2.4.0)
         
     | 
| 
       70 
70 
     | 
    
         
             
                minitest (5.11.3)
         
     | 
| 
       71 
     | 
    
         
            -
                multipart-post (2. 
     | 
| 
      
 71 
     | 
    
         
            +
                multipart-post (2.1.1)
         
     | 
| 
       72 
72 
     | 
    
         
             
                mustermann (1.0.3)
         
     | 
| 
       73 
73 
     | 
    
         
             
                nokogiri (1.10.2)
         
     | 
| 
       74 
74 
     | 
    
         
             
                  mini_portile2 (~> 2.4.0)
         
     | 
| 
         @@ -80,7 +80,7 @@ GEM 
     | 
|
| 
       80 
80 
     | 
    
         
             
                  coderay (~> 1.1.0)
         
     | 
| 
       81 
81 
     | 
    
         
             
                  method_source (~> 0.9.0)
         
     | 
| 
       82 
82 
     | 
    
         
             
                psych (3.1.0)
         
     | 
| 
       83 
     | 
    
         
            -
                public_suffix (3.0 
     | 
| 
      
 83 
     | 
    
         
            +
                public_suffix (3.1.0)
         
     | 
| 
       84 
84 
     | 
    
         
             
                rack (2.0.7)
         
     | 
| 
       85 
85 
     | 
    
         
             
                rack-protection (2.0.5)
         
     | 
| 
       86 
86 
     | 
    
         
             
                  rack
         
     | 
    
        data/lib/clickhouse/table.rb
    CHANGED
    
    | 
         @@ -11,9 +11,20 @@ module Clickhouse 
     | 
|
| 
       11 
11 
     | 
    
         
             
                    @table_name ||= to_s.tableize
         
     | 
| 
       12 
12 
     | 
    
         
             
                  end
         
     | 
| 
       13 
13 
     | 
    
         | 
| 
       14 
     | 
    
         
            -
                  def  
     | 
| 
      
 14 
     | 
    
         
            +
                  def insert_row(row)
         
     | 
| 
      
 15 
     | 
    
         
            +
                    return if row.nil?
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                    connection.insert_rows(table_name) do
         
     | 
| 
      
 18 
     | 
    
         
            +
                      complete_row = prepare_row(block_given? ? yield(row) : row)
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                      [complete_row]
         
     | 
| 
      
 21 
     | 
    
         
            +
                    end
         
     | 
| 
      
 22 
     | 
    
         
            +
                  end
         
     | 
| 
      
 23 
     | 
    
         
            +
                  alias :create :insert_row
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                  def insert_rows(batch_rows)
         
     | 
| 
       15 
26 
     | 
    
         
             
                    connection.insert_rows(table_name) do |table_rows|
         
     | 
| 
       16 
     | 
    
         
            -
                       
     | 
| 
      
 27 
     | 
    
         
            +
                      batch_rows.each do |row|
         
     | 
| 
       17 
28 
     | 
    
         
             
                        next if row.nil?
         
     | 
| 
       18 
29 
     | 
    
         | 
| 
       19 
30 
     | 
    
         
             
                        complete_row = prepare_row(block_given? ? yield(row) : row)
         
     | 
    
        data/spec/table_spec.rb
    CHANGED
    
    | 
         @@ -21,6 +21,17 @@ describe Clickhouse::Table do 
     | 
|
| 
       21 
21 
     | 
    
         
             
                end
         
     | 
| 
       22 
22 
     | 
    
         
             
              end
         
     | 
| 
       23 
23 
     | 
    
         | 
| 
      
 24 
     | 
    
         
            +
              describe '#insert_row' do
         
     | 
| 
      
 25 
     | 
    
         
            +
                let(:inserted_rows) { CustomTable.rows.to_a }
         
     | 
| 
      
 26 
     | 
    
         
            +
                let(:row) { { 'field' => 'a' } }
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                it 'add the row' do
         
     | 
| 
      
 29 
     | 
    
         
            +
                  CustomTable.insert_row(row)
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                  expect(inserted_rows).to eq([['a']])
         
     | 
| 
      
 32 
     | 
    
         
            +
                end
         
     | 
| 
      
 33 
     | 
    
         
            +
              end
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
       24 
35 
     | 
    
         
             
              describe '#insert_rows' do
         
     | 
| 
       25 
36 
     | 
    
         
             
                let(:inserted_rows) { CustomTable.rows.to_a }
         
     | 
| 
       26 
37 
     | 
    
         | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: clickhouse-rails
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.1. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.1.4
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Vsevolod Avramov
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2019- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2019-06-12 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: clickhouse
         
     |