clickhouse-activerecord 1.0.7 → 1.0.9

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: 17575531d9c1ae85c10c20230bb78014f9f0e07affe672b683b66651e37af812
4
- data.tar.gz: 14ac2cfb7e6cfa344cf2284a76082e5476e08cfe77a499695157e09c58cd7765
3
+ metadata.gz: f32d998cd41ae14becbea5f03a9b83b996a6622808c49c124d466771825163d7
4
+ data.tar.gz: 3f49b195d406ce1a7b5ec2f50bba2e12fc37d2c0f4d312998f3ce2a3173ec88d
5
5
  SHA512:
6
- metadata.gz: '09973aaa310292cfdef323b4c66b2088db297b243b90e6149e7f6998165a9208adf74cbeb2665f0230ee6ac8dacc1632e1562eaff085bf07d6689ccfbcc0d75c'
7
- data.tar.gz: 38b8ba94d466720ff860a62a2542d1cb2ec106c88ffd000979203e8c9403e0aa42d0f4ba3e83e822270888a11b07f3b96296785c0fdc7b1b39fa12e019b07e6e
6
+ metadata.gz: 99195548b29bdc67139eff0537099c4ee6384efec7eaa5733cd0edbe6b6998ade9c1fcce775b3f8e576ad63ca9dc62a5626cb6b1d9e8d5fb0410611e264d0121
7
+ data.tar.gz: f9d9fd7a8d3be305447f5612da41fa4dffdfac2536b7015a3b8404395f143feb28ca08ac132c3bfe0bab9b73302e9a7fd59067754410ab629f20fb5280209aba
data/CHANGELOG.md CHANGED
@@ -1,10 +1,11 @@
1
- ### Version 1.0.5 (Apr 26, 2024)
1
+ ### Version 1.0.7 (Apr 27, 2024)
2
2
 
3
3
  * Support table indexes
4
4
  * Fix non-canonical UUID by [@PauloMiranda98](https://github.com/PauloMiranda98) in (#117)
5
5
  * Fix precision loss due to JSON float parsing by [@jenskdsgn](https://github.com/jenskdsgn) in (#129)
6
6
  * Support functions by [@felix-dumit](https://github.com/felix-dumit) in (#120)
7
7
  * Hotfix/rails71 change column by [@trumenov](https://github.com/trumenov) in (#132)
8
+ * Fix DB tasks
8
9
 
9
10
  ### Version 1.0.5 (Mar 14, 2024)
10
11
 
data/README.md CHANGED
@@ -202,7 +202,7 @@ false`. The default integer is `UInt32`
202
202
 
203
203
  Example:
204
204
 
205
- ``` ruby
205
+ ```ruby
206
206
  class CreateDataItems < ActiveRecord::Migration[7.1]
207
207
  def change
208
208
  create_table "data_items", id: false, options: "VersionedCollapsingMergeTree(sign, version) PARTITION BY toYYYYMM(day) ORDER BY category", force: :cascade do |t|
@@ -230,8 +230,8 @@ end
230
230
 
231
231
  Create table with custom column structure:
232
232
 
233
- ``` ruby
234
- class CreateDataItems < ActiveRecord::Migration
233
+ ```ruby
234
+ class CreateDataItems < ActiveRecord::Migration[7.1]
235
235
  def change
236
236
  create_table "data_items", id: false, options: "MergeTree PARTITION BY toYYYYMM(timestamp) ORDER BY timestamp", force: :cascade do |t|
237
237
  t.column "timestamp", "DateTime('UTC') CODEC(DoubleDelta, LZ4)"
@@ -240,6 +240,16 @@ class CreateDataItems < ActiveRecord::Migration
240
240
  end
241
241
  ```
242
242
 
243
+ Create Buffer table with connection database name:
244
+
245
+ ```ruby
246
+ class CreateDataItems < ActiveRecord::Migration[7.1]
247
+ def change
248
+ create_table :some_buffers, as: :some, options: "Buffer(#{connection.database}, some, 1, 10, 60, 100, 10000, 10000000, 100000000)"
249
+ end
250
+ end
251
+ ```
252
+
243
253
 
244
254
  ### Using replica and cluster params in connection parameters
245
255
 
@@ -88,6 +88,7 @@ module ActiveRecord
88
88
  create_sql = +"CREATE#{table_modifier_in_create(o)} #{o.view ? "VIEW" : "TABLE"} "
89
89
  create_sql << "IF NOT EXISTS " if o.if_not_exists
90
90
  create_sql << "#{quote_table_name(o.name)} "
91
+ add_as_clause!(create_sql, o) if o.as && !o.view
91
92
  add_to_clause!(create_sql, o) if o.materialized
92
93
 
93
94
  statements = o.columns.map { |c| accept c }
@@ -103,7 +104,7 @@ module ActiveRecord
103
104
  create_sql << "(#{statements.join(', ')})" if statements.present?
104
105
  # Attach options for only table or materialized view without TO section
105
106
  add_table_options!(create_sql, o) if !o.view || o.view && o.materialized && !o.to
106
- add_as_clause!(create_sql, o)
107
+ add_as_clause!(create_sql, o) if o.as && o.view
107
108
  create_sql
108
109
  end
109
110
 
@@ -293,7 +293,7 @@ module ActiveRecord
293
293
  options = apply_replica(table_name, options)
294
294
  td = create_table_definition(apply_cluster(table_name), **options)
295
295
  block.call td if block_given?
296
- td.column(:id, options[:id], null: false) if options[:id].present? && td[:id].blank?
296
+ td.column(:id, options[:id], null: false) if options[:id].present? && td[:id].blank? && options[:as].blank?
297
297
 
298
298
  if options[:force]
299
299
  drop_table(table_name, options.merge(if_exists: true))
@@ -431,6 +431,10 @@ module ActiveRecord
431
431
  @config[:replica_name]
432
432
  end
433
433
 
434
+ def database
435
+ @config[:database]
436
+ end
437
+
434
438
  def use_default_replicated_merge_tree_params?
435
439
  database_engine_atomic? && @config[:use_default_replicated_merge_tree_params]
436
440
  end
@@ -90,7 +90,9 @@ HEADER
90
90
  unless simple
91
91
  table_options = @connection.table_options(table)
92
92
  if table_options.present?
93
- tbl.print ", #{format_options(table_options)}"
93
+ table_options = format_options(table_options)
94
+ table_options.gsub!(/Buffer\('[^']+'/, 'Buffer(\'#{connection.database}\'')
95
+ tbl.print ", #{table_options}"
94
96
  end
95
97
  end
96
98
 
@@ -138,7 +140,7 @@ HEADER
138
140
 
139
141
  def format_options(options)
140
142
  if options && options[:options]
141
- options[:options] = options[:options].gsub(/^Replicated(.*?)\('[^']+',\s*'[^']+',?\s?([^\)]*)?\)/, "\\1(\\2)")
143
+ options[:options].gsub!(/^Replicated(.*?)\('[^']+',\s*'[^']+',?\s?([^\)]*)?\)/, "\\1(\\2)")
142
144
  end
143
145
  super
144
146
  end
@@ -1,3 +1,3 @@
1
1
  module ClickhouseActiverecord
2
- VERSION = '1.0.7'
2
+ VERSION = '1.0.9'
3
3
  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.0.7
4
+ version: 1.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergey Odintsov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-04-27 00:00:00.000000000 Z
11
+ date: 2024-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -154,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
154
154
  - !ruby/object:Gem::Version
155
155
  version: '0'
156
156
  requirements: []
157
- rubygems_version: 3.3.7
157
+ rubygems_version: 3.5.9
158
158
  signing_key:
159
159
  specification_version: 4
160
160
  summary: ClickHouse ActiveRecord