clickhouse-activerecord 1.0.8 → 1.0.10

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: 77b149946e335300ac60c931d1318dd2d3a460127b27f3af8722397177e6153e
4
- data.tar.gz: cd77dd40f7b9edf5e052d2f87c918e25d882616b48a69558dfb4f92761009edb
3
+ metadata.gz: fcb4b8401a210b2fafb35c9947df32c772b83740102b95b982146c573ae76f12
4
+ data.tar.gz: 41e059ab9a032725874117f4d7f18e6e0c22e568aaec142002b2f9bf5400ddac
5
5
  SHA512:
6
- metadata.gz: af2eee6764e9c6de36c96cf1d830ddbb6c263f86e3a0e28bb79cb5a7e786c476fd100c8be38cc9226f6c7e6f9f8c4c0d5c73c039411096ddaddd160f72146b5f
7
- data.tar.gz: 39c38cf9dbd66f4b7bb27447ebded7a54d999299ab5688bba51fbc6ac8a3ef5a4af29d0f0ec4c44461f300a19d7dde6d3bb5ca890453d42485758cc5740c9389
6
+ metadata.gz: f6242025f4207c68d8ac1e9a7cb87ede0fcbcbf4f7937b44d9b9e8faff43a121af2cb8c58bbdb2fac0d1959d197efb95e1718968c054ef9e213641fe2da6641a
7
+ data.tar.gz: 4a007e48f1f7f3866d90cf5080847d0e6af9dba41e525bdd78890419f9edc0f8484dbd3d83d01529185477210d1878527d85506a65a927970c864e9f7d6a60f4
@@ -93,6 +93,12 @@ module ActiveRecord
93
93
 
94
94
  args.each { |name| column(name, kind, **options.except(:limit)) }
95
95
  end
96
+
97
+ private
98
+
99
+ def valid_column_definition_options
100
+ super + [:array, :low_cardinality, :fixed_string, :value, :type]
101
+ end
96
102
  end
97
103
 
98
104
  class IndexDefinition
@@ -143,7 +143,10 @@ module ActiveRecord
143
143
  def request(sql, format = nil, settings = {})
144
144
  formatted_sql = apply_format(sql, format)
145
145
  request_params = @connection_config || {}
146
- @connection.post("/?#{request_params.merge(settings).to_param}", formatted_sql, 'User-Agent' => "Clickhouse ActiveRecord #{ClickhouseActiverecord::VERSION}")
146
+ @connection.post("/?#{request_params.merge(settings).to_param}", formatted_sql, {
147
+ 'User-Agent' => "Clickhouse ActiveRecord #{ClickhouseActiverecord::VERSION}",
148
+ 'Content-Type' => 'application/x-www-form-urlencoded',
149
+ })
147
150
  end
148
151
 
149
152
  def apply_format(sql, format)
@@ -293,7 +293,11 @@ 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? && options[:as].blank?
296
+ # support old migration version: in 5.0 options id: :integer, but 7.1 options empty
297
+ # todo remove auto add id column in future
298
+ if (!options.key?(:id) || options[:id].present? && options[:id] != false) && td[:id].blank? && options[:as].blank?
299
+ td.column(:id, options[:id] || :integer, null: false)
300
+ end
297
301
 
298
302
  if options[:force]
299
303
  drop_table(table_name, options.merge(if_exists: true))
@@ -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.8'
2
+ VERSION = '1.0.10'
3
3
  end
@@ -37,6 +37,8 @@ namespace :clickhouse do
37
37
  end
38
38
 
39
39
  namespace :structure do
40
+ config = ActiveRecord::Base.configurations.configs_for(env_name: Rails.env, name: 'clickhouse')
41
+
40
42
  desc 'Load database structure'
41
43
  task load: ['db:check_protected_environments'] do
42
44
  ClickhouseActiverecord::Tasks.new(config).structure_load(Rails.root.join('db/clickhouse_structure.sql'))
@@ -85,8 +87,4 @@ namespace :clickhouse do
85
87
  Rake::Task['clickhouse:schema:dump'].execute(simple: true)
86
88
  end
87
89
  end
88
-
89
- def config
90
- ActiveRecord::Base.configurations.configs_for(env_name: Rails.env, name: 'clickhouse')
91
- end
92
90
  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.8
4
+ version: 1.0.10
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-05-03 00:00:00.000000000 Z
11
+ date: 2024-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler