clickhouse-activerecord 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/active_record/connection_adapters/clickhouse/schema_creation.rb +1 -5
- data/lib/active_record/connection_adapters/clickhouse/schema_statements.rb +7 -7
- data/lib/active_record/connection_adapters/clickhouse_adapter.rb +3 -18
- data/lib/arel/visitors/clickhouse.rb +11 -0
- data/lib/clickhouse-activerecord/version.rb +1 -1
- data/lib/tasks/clickhouse.rake +2 -2
- 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: d56a19e32a58184c6c70b4cc56f30f4e7f742255a9f63441ce8c9b94ec63eebf
|
4
|
+
data.tar.gz: 2bd423580e61443e1b334e2182e4a05a7e712d79141ae6431730edcdc5dee7e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17a5a009eb6ece2d6835f5c37598891bde51fb4cf6c6e7ccb8fdc02cf9b1345d822e39d0f3d825b593606180db020357f4828e89f0c9c4cdf8352349ad6f4104
|
7
|
+
data.tar.gz: edc694713807b818d8f2e9c0b6a0592e0a3862a6b064d4110d12d82ebc1cb40133f7495e9e665007f91f0da5223d129ed110387f4922bf4de710729f462d4509
|
@@ -125,11 +125,7 @@ module ActiveRecord
|
|
125
125
|
end
|
126
126
|
|
127
127
|
def current_database
|
128
|
-
|
129
|
-
ActiveRecord::Base.connection_db_config.database
|
130
|
-
else
|
131
|
-
ActiveRecord::Base.connection_config[:database]
|
132
|
-
end
|
128
|
+
ActiveRecord::Base.connection_db_config.database
|
133
129
|
end
|
134
130
|
end
|
135
131
|
end
|
@@ -30,12 +30,16 @@ module ActiveRecord
|
|
30
30
|
true
|
31
31
|
end
|
32
32
|
|
33
|
+
# @link https://clickhouse.com/docs/en/sql-reference/statements/alter/update
|
33
34
|
def exec_update(_sql, _name = nil, _binds = [])
|
34
|
-
|
35
|
+
do_execute(_sql, _name, format: nil)
|
36
|
+
true
|
35
37
|
end
|
36
38
|
|
39
|
+
# @link https://clickhouse.com/docs/en/sql-reference/statements/delete
|
37
40
|
def exec_delete(_sql, _name = nil, _binds = [])
|
38
|
-
|
41
|
+
do_execute(_sql, _name, format: nil)
|
42
|
+
true
|
39
43
|
end
|
40
44
|
|
41
45
|
def tables(name = nil)
|
@@ -143,11 +147,7 @@ module ActiveRecord
|
|
143
147
|
default = field[3]
|
144
148
|
default_value = extract_value_from_default(default)
|
145
149
|
default_function = extract_default_function(default_value, default)
|
146
|
-
|
147
|
-
ClickhouseColumn.new(field[0], default_value, type_metadata, field[1].include?('Nullable'), default_function)
|
148
|
-
else
|
149
|
-
ClickhouseColumn.new(field[0], default_value, type_metadata, field[1].include?('Nullable'), table_name, default_function)
|
150
|
-
end
|
150
|
+
ClickhouseColumn.new(field[0], default_value, type_metadata, field[1].include?('Nullable'), default_function)
|
151
151
|
end
|
152
152
|
|
153
153
|
protected
|
@@ -127,9 +127,6 @@ module ActiveRecord
|
|
127
127
|
@full_config = full_config
|
128
128
|
|
129
129
|
@prepared_statements = false
|
130
|
-
if ActiveRecord::version == Gem::Version.new('6.0.0')
|
131
|
-
@prepared_statement_status = Concurrent::ThreadLocalVar.new(false)
|
132
|
-
end
|
133
130
|
|
134
131
|
connect
|
135
132
|
end
|
@@ -238,30 +235,18 @@ module ActiveRecord
|
|
238
235
|
# Quoting time without microseconds
|
239
236
|
def quoted_date(value)
|
240
237
|
if value.acts_like?(:time)
|
241
|
-
|
242
|
-
zone_conversion_method = ActiveRecord.default_timezone == :utc ? :getutc : :getlocal
|
243
|
-
else
|
244
|
-
zone_conversion_method = ActiveRecord::Base.default_timezone == :utc ? :getutc : :getlocal
|
245
|
-
end
|
238
|
+
zone_conversion_method = ActiveRecord.default_timezone == :utc ? :getutc : :getlocal
|
246
239
|
|
247
240
|
if value.respond_to?(zone_conversion_method)
|
248
241
|
value = value.send(zone_conversion_method)
|
249
242
|
end
|
250
243
|
end
|
251
244
|
|
252
|
-
|
253
|
-
value.to_fs(:db)
|
254
|
-
else
|
255
|
-
value.to_s(:db)
|
256
|
-
end
|
245
|
+
value.to_fs(:db)
|
257
246
|
end
|
258
247
|
|
259
248
|
def column_name_for_operation(operation, node) # :nodoc:
|
260
|
-
|
261
|
-
visitor.compile(node)
|
262
|
-
else
|
263
|
-
column_name_from_arel_node(node)
|
264
|
-
end
|
249
|
+
visitor.compile(node)
|
265
250
|
end
|
266
251
|
|
267
252
|
# Executes insert +sql+ statement in the context of this connection using
|
@@ -23,6 +23,17 @@ module Arel
|
|
23
23
|
maybe_visit o.settings, super
|
24
24
|
end
|
25
25
|
|
26
|
+
def visit_Arel_Nodes_UpdateStatement(o, collector)
|
27
|
+
o = prepare_update_statement(o)
|
28
|
+
|
29
|
+
collector << 'ALTER TABLE '
|
30
|
+
collector = visit o.relation, collector
|
31
|
+
collect_nodes_for o.values, collector, ' UPDATE '
|
32
|
+
collect_nodes_for o.wheres, collector, ' WHERE ', ' AND '
|
33
|
+
collect_nodes_for o.orders, collector, ' ORDER BY '
|
34
|
+
maybe_visit o.limit, collector
|
35
|
+
end
|
36
|
+
|
26
37
|
def visit_Arel_Nodes_Settings(o, collector)
|
27
38
|
return collector if o.expr.empty?
|
28
39
|
|
data/lib/tasks/clickhouse.rake
CHANGED
@@ -72,7 +72,7 @@ namespace :clickhouse do
|
|
72
72
|
desc 'Migrate the clickhouse database'
|
73
73
|
task migrate: %i[prepare_schema_migration_table prepare_internal_metadata_table] do
|
74
74
|
Rake::Task['db:migrate:clickhouse'].execute
|
75
|
-
if File.
|
75
|
+
if File.exist? "#{Rails.root}/db/clickhouse_schema_simple.rb"
|
76
76
|
Rake::Task['clickhouse:schema:dump'].execute(simple: true)
|
77
77
|
end
|
78
78
|
end
|
@@ -80,7 +80,7 @@ namespace :clickhouse do
|
|
80
80
|
desc 'Rollback the clickhouse database'
|
81
81
|
task rollback: %i[prepare_schema_migration_table prepare_internal_metadata_table] do
|
82
82
|
Rake::Task['db:rollback:clickhouse'].execute
|
83
|
-
if File.
|
83
|
+
if File.exist? "#{Rails.root}/db/clickhouse_schema_simple.rb"
|
84
84
|
Rake::Task['clickhouse:schema:dump'].execute(simple: true)
|
85
85
|
end
|
86
86
|
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.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergey Odintsov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|