clickhouse-activerecord 0.5.11 → 0.5.13

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: c4828cf36787dd2532b1522cdafc1f221b6088fca1bc394d0b86703355676ebc
4
- data.tar.gz: 8d0cf197f79787754461990e8f06599497b4ae9e6eea6419bf30bf83986ad9ac
3
+ metadata.gz: d0d11fee214ec195a5ccb8569e2f0302c7273a74bacc012069837a7f5fd5bec6
4
+ data.tar.gz: 32d98a8051a6246d567d5ef9278b4a6795b385d4290203c6d6742c961a6490d3
5
5
  SHA512:
6
- metadata.gz: 217a21b7456784206a97bd75ed20f337c247973f0d839dec05ef84a60059be43f71b3f7a7a87834be92991262a9272927955cbd0c767adf1d3452496cf511602
7
- data.tar.gz: 593dd36a333c07fa7c81a9b011577381cc38a2bad2975a39b9f80c57bc56fab9662501ea25d4e510c06028e62fa46d517942b63e5de902acbabfecb36a6b6bb5
6
+ metadata.gz: 0bfb1e29754b50d7c33033dd0be37d1a4205dbb9ff12671fc27f217572d493f2a01c3a28c98e0bfaa968564ca8f714c5abefecf6d14638fa4f767aa00ea13fdf
7
+ data.tar.gz: eebb37d468dbf8695b50b60ee47e3641517778ee06dc82df767e126bc8f7cd94e9de8c690622777c849ba0ce8adec65d9ff55d30ea0a0b25981f6e41afcbe1dd
@@ -23,6 +23,42 @@ module ActiveRecord
23
23
  @subtype
24
24
  end
25
25
 
26
+ def deserialize(value)
27
+ if value.is_a?(::Array)
28
+ value.map { |item| deserialize(item) }
29
+ else
30
+ return value if value.nil?
31
+ case @subtype
32
+ when :integer
33
+ value.to_i
34
+ when :datetime
35
+ ::DateTime.parse(value)
36
+ when :date
37
+ ::Date.parse(value)
38
+ else
39
+ super
40
+ end
41
+ end
42
+ end
43
+
44
+ def serialize(value)
45
+ if value.is_a?(::Array)
46
+ value.map { |item| serialize(item) }
47
+ else
48
+ return value if value.nil?
49
+ case @subtype
50
+ when :integer
51
+ value.to_i
52
+ when :datetime
53
+ DateTime.new.serialize(value)
54
+ when :date
55
+ Date.new.serialize(value)
56
+ else
57
+ super
58
+ end
59
+ end
60
+ end
61
+
26
62
  end
27
63
  end
28
64
  end
@@ -125,7 +125,11 @@ module ActiveRecord
125
125
  end
126
126
 
127
127
  def current_database
128
- ActiveRecord::Base.connection_db_config.database
128
+ if ActiveRecord::version >= Gem::Version.new('6')
129
+ ActiveRecord::Base.connection_db_config.database
130
+ else
131
+ ActiveRecord::Base.connection_config[:database]
132
+ end
129
133
  end
130
134
  end
131
135
  end
@@ -6,8 +6,8 @@ module ActiveRecord
6
6
  module ConnectionAdapters
7
7
  module Clickhouse
8
8
  module SchemaStatements
9
- def execute(sql, name = nil)
10
- do_execute(sql, name)
9
+ def execute(sql, name = nil, settings: {})
10
+ do_execute(sql, name, settings: settings)
11
11
  end
12
12
 
13
13
  def exec_insert(sql, name, _binds, _pk = nil, _sequence_name = nil)
@@ -11,6 +11,7 @@ require 'active_record/connection_adapters/clickhouse/schema_definitions'
11
11
  require 'active_record/connection_adapters/clickhouse/schema_creation'
12
12
  require 'active_record/connection_adapters/clickhouse/schema_statements'
13
13
  require 'net/http'
14
+ require 'openssl'
14
15
 
15
16
  module ActiveRecord
16
17
  class Base
@@ -224,6 +225,15 @@ module ActiveRecord
224
225
  end
225
226
  end
226
227
 
228
+ def _quote(value)
229
+ case value
230
+ when Array
231
+ '[' + value.map { |v| _quote(v) }.join(', ') + ']'
232
+ else
233
+ super
234
+ end
235
+ end
236
+
227
237
  # Quoting time without microseconds
228
238
  def quoted_date(value)
229
239
  if value.acts_like?(:time)
@@ -301,6 +311,7 @@ module ActiveRecord
301
311
  options = apply_replica(table_name, options)
302
312
  td = create_table_definition(apply_cluster(table_name), **options)
303
313
  block.call td if block_given?
314
+ td.column(:id, options[:id], null: false) if options[:id].present? && td[:id].blank?
304
315
 
305
316
  if options[:force]
306
317
  drop_table(table_name, options.merge(if_exists: true))
@@ -10,7 +10,7 @@ module ClickhouseActiverecord
10
10
 
11
11
  version_options = connection.internal_string_options_for_primary_key
12
12
  table_options = {
13
- id: false, options: 'ReplacingMergeTree(ver) PARTITION BY version ORDER BY (version)', if_not_exists: true
13
+ id: false, options: 'ReplacingMergeTree(ver) ORDER BY (version)', if_not_exists: true
14
14
  }
15
15
  full_config = connection.instance_variable_get(:@full_config) || {}
16
16
 
@@ -1,3 +1,3 @@
1
1
  module ClickhouseActiverecord
2
- VERSION = '0.5.11'
2
+ VERSION = '0.5.13'
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: 0.5.11
4
+ version: 0.5.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergey Odintsov
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-08-16 00:00:00.000000000 Z
11
+ date: 2023-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -136,7 +136,7 @@ homepage: https://github.com/pnixx/clickhouse-activerecord
136
136
  licenses:
137
137
  - MIT
138
138
  metadata: {}
139
- post_install_message:
139
+ post_install_message:
140
140
  rdoc_options: []
141
141
  require_paths:
142
142
  - lib
@@ -151,8 +151,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
153
  requirements: []
154
- rubygems_version: 3.0.3
155
- signing_key:
154
+ rubygems_version: 3.0.4
155
+ signing_key:
156
156
  specification_version: 4
157
157
  summary: ClickHouse ActiveRecord
158
158
  test_files: []