clickhouse-activerecord 0.5.12 → 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: 324c3a376214e1c201b3f5dd052c971a1eb7330033960db2eb10a2671f13d187
4
- data.tar.gz: 36f71acd4ef651b78d23771f1620b488e0f963576af8ef11890b7c0d83d8c1c2
3
+ metadata.gz: d0d11fee214ec195a5ccb8569e2f0302c7273a74bacc012069837a7f5fd5bec6
4
+ data.tar.gz: 32d98a8051a6246d567d5ef9278b4a6795b385d4290203c6d6742c961a6490d3
5
5
  SHA512:
6
- metadata.gz: a1f13b9879af1ca6ef2d6a8dcce1ceb09a4b342659ae4cf7389d47ec41e7b608000f2d1810503996dafa38a3ff84bee901d8d0ec8c413e3086ac99d71c8f5618
7
- data.tar.gz: 43ccc8f02a079bf62569bf0977f1ff45306166a61d30feaa817ddd253732a0426728e9926adeb36c31fcae807ff4b26e969de8b2fe8154952cbd8656e29f3f8d
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
@@ -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))
@@ -1,3 +1,3 @@
1
1
  module ClickhouseActiverecord
2
- VERSION = '0.5.12'
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.12
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: 2023-01-17 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.1
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: []