click_house-client 0.2.4 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitlab-ci.yml +1 -1
- data/.rubocop.yml +1 -1
- data/Gemfile.lock +41 -9
- data/click_house-client.gemspec +3 -2
- data/lib/click_house/client/arel_engine.rb +19 -0
- data/lib/click_house/client/database.rb +1 -1
- data/lib/click_house/client/query_builder.rb +156 -0
- data/lib/click_house/client/quoting.rb +9 -2
- data/lib/click_house/client/redactor.rb +69 -0
- data/lib/click_house/client/version.rb +1 -1
- data/lib/click_house/client.rb +7 -2
- metadata +24 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 979e02193855b98f131e5474d0dc16d84463740699425b5f10914bade2759a60
|
4
|
+
data.tar.gz: 172eb393746096c11d76b06a5dbcc59fd396a555f0186192e8b077e3ec08f687
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e41352d705398e565ee0e828286e440da6c99893bb88598b2fd0f9cb0138a6f5f26a664e5f3998d9f7c0ee64ad3f68da55a26c040dc3f9c9fcfc6318d88b90f
|
7
|
+
data.tar.gz: 2839955caa8847c180b9286f3daf4477a8ab1e972329ebb7c6868001bebfcb673f36cc174fff38d8cc6c0aa3c30f579995c8abcfbec2b94231094aa978fdc9d6
|
data/.gitlab-ci.yml
CHANGED
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,24 +1,43 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
click_house-client (0.
|
5
|
-
|
4
|
+
click_house-client (0.3.0)
|
5
|
+
activerecord (~> 7.0)
|
6
|
+
activesupport (~> 7.0)
|
6
7
|
addressable (~> 2.8)
|
7
8
|
json (~> 2.7)
|
8
9
|
|
9
10
|
GEM
|
10
11
|
remote: https://rubygems.org/
|
11
12
|
specs:
|
12
|
-
|
13
|
-
|
13
|
+
activemodel (7.2.2.1)
|
14
|
+
activesupport (= 7.2.2.1)
|
15
|
+
activerecord (7.2.2.1)
|
16
|
+
activemodel (= 7.2.2.1)
|
17
|
+
activesupport (= 7.2.2.1)
|
18
|
+
timeout (>= 0.4.0)
|
19
|
+
activesupport (7.2.2.1)
|
20
|
+
base64
|
21
|
+
benchmark (>= 0.3)
|
22
|
+
bigdecimal
|
23
|
+
concurrent-ruby (~> 1.0, >= 1.3.1)
|
24
|
+
connection_pool (>= 2.2.5)
|
25
|
+
drb
|
14
26
|
i18n (>= 1.6, < 2)
|
27
|
+
logger (>= 1.4.2)
|
15
28
|
minitest (>= 5.1)
|
16
|
-
|
29
|
+
securerandom (>= 0.3)
|
30
|
+
tzinfo (~> 2.0, >= 2.0.5)
|
17
31
|
addressable (2.8.4)
|
18
32
|
public_suffix (>= 2.0.2, < 6.0)
|
19
33
|
ast (2.4.2)
|
20
|
-
|
34
|
+
base64 (0.3.0)
|
35
|
+
benchmark (0.4.1)
|
36
|
+
bigdecimal (3.2.2)
|
37
|
+
concurrent-ruby (1.3.5)
|
38
|
+
connection_pool (2.5.3)
|
21
39
|
diff-lcs (1.5.0)
|
40
|
+
drb (2.2.3)
|
22
41
|
gitlab-styles (12.0.1)
|
23
42
|
rubocop (~> 1.62.1)
|
24
43
|
rubocop-factory_bot (~> 2.25.1)
|
@@ -30,6 +49,7 @@ GEM
|
|
30
49
|
concurrent-ruby (~> 1.0)
|
31
50
|
json (2.10.1)
|
32
51
|
language_server-protocol (3.17.0.3)
|
52
|
+
logger (1.7.0)
|
33
53
|
minitest (5.18.1)
|
34
54
|
parallel (1.23.0)
|
35
55
|
parser (3.3.3.0)
|
@@ -87,6 +107,8 @@ GEM
|
|
87
107
|
rubocop-capybara (~> 2.17)
|
88
108
|
rubocop-factory_bot (~> 2.22)
|
89
109
|
ruby-progressbar (1.13.0)
|
110
|
+
securerandom (0.4.1)
|
111
|
+
timeout (0.4.3)
|
90
112
|
tzinfo (2.0.6)
|
91
113
|
concurrent-ruby (~> 1.0)
|
92
114
|
unicode-display_width (2.4.2)
|
@@ -103,16 +125,24 @@ DEPENDENCIES
|
|
103
125
|
rubocop-rspec
|
104
126
|
|
105
127
|
CHECKSUMS
|
106
|
-
|
128
|
+
activemodel (7.2.2.1) sha256=8398861f9ee2c4671a8357ab39e9b38a045fd656f6685a3dd5890c2419dbfdaf
|
129
|
+
activerecord (7.2.2.1) sha256=79a31f71c32d5138717c2104e0ff105f5d82922247c85bdca144f2720e67fab9
|
130
|
+
activesupport (7.2.2.1) sha256=842bcbf8a92977f80fb4750661a237cf5dd4fdd442066b3c35e88afb488647f5
|
107
131
|
addressable (2.8.4) sha256=40a88af5285625b7fb14070e550e667d5b0cc91f748068701b4d897cacda4897
|
108
132
|
ast (2.4.2) sha256=1e280232e6a33754cde542bc5ef85520b74db2aac73ec14acef453784447cc12
|
109
|
-
|
110
|
-
|
133
|
+
base64 (0.3.0) sha256=27337aeabad6ffae05c265c450490628ef3ebd4b67be58257393227588f5a97b
|
134
|
+
benchmark (0.4.1) sha256=d4ef40037bba27f03b28013e219b950b82bace296549ec15a78016552f8d2cce
|
135
|
+
bigdecimal (3.2.2) sha256=39085f76b495eb39a79ce07af716f3a6829bc35eb44f2195e2753749f2fa5adc
|
136
|
+
click_house-client (0.3.0)
|
137
|
+
concurrent-ruby (1.3.5) sha256=813b3e37aca6df2a21a3b9f1d497f8cbab24a2b94cab325bffe65ee0f6cbebc6
|
138
|
+
connection_pool (2.5.3) sha256=cfd74a82b9b094d1ce30c4f1a346da23ee19dc8a062a16a85f58eab1ced4305b
|
111
139
|
diff-lcs (1.5.0) sha256=49b934001c8c6aedb37ba19daec5c634da27b318a7a3c654ae979d6ba1929b67
|
140
|
+
drb (2.2.3) sha256=0b00d6fdb50995fe4a45dea13663493c841112e4068656854646f418fda13373
|
112
141
|
gitlab-styles (12.0.1) sha256=d8a302b0ab0e1f18e2d11501760f1b85c5e70b5e5ca628828a0786c7984ed133
|
113
142
|
i18n (1.14.1) sha256=9d03698903547c060928e70a9bc8b6b87fda674453cda918fc7ab80235ae4a61
|
114
143
|
json (2.10.1) sha256=ddc88ad91a1baf3f0038c174f253af3b086d30dc74db17ca4259bbde982f94dc
|
115
144
|
language_server-protocol (3.17.0.3) sha256=3d5c58c02f44a20d972957a9febe386d7e7468ab3900ce6bd2b563dd910c6b3f
|
145
|
+
logger (1.7.0) sha256=196edec7cc44b66cfb40f9755ce11b392f21f7967696af15d274dde7edff0203
|
116
146
|
minitest (5.18.1) sha256=ab5ee381871aaddc3a6aa2a6abcab5c4590fec9affc20947d63f312a0fe4e9cd
|
117
147
|
parallel (1.23.0) sha256=27154713ad6ef32fa3dcb7788a721d6c07bca77e72443b4c6080a14145288c49
|
118
148
|
parser (3.3.3.0) sha256=a2e23c90918d9b7e866b18dca2b6835f227769dd2fa8e59c5841f3389cf53eeb
|
@@ -137,6 +167,8 @@ CHECKSUMS
|
|
137
167
|
rubocop-rails (2.24.1) sha256=03edf766954947468f3686cedb69142fae4f10e2007287f89cc0ea7072eeac19
|
138
168
|
rubocop-rspec (2.27.1) sha256=2f27ce04700be75db65afe83d7993a36e0fafd07ec062222f4b3cc10137a7a9e
|
139
169
|
ruby-progressbar (1.13.0) sha256=80fc9c47a9b640d6834e0dc7b3c94c9df37f08cb072b7761e4a71e22cff29b33
|
170
|
+
securerandom (0.4.1) sha256=cc5193d414a4341b6e225f0cb4446aceca8e50d5e1888743fac16987638ea0b1
|
171
|
+
timeout (0.4.3) sha256=9509f079b2b55fe4236d79633bd75e34c1c1e7e3fb4b56cb5fda61f80a0fe30e
|
140
172
|
tzinfo (2.0.6) sha256=8daf828cc77bcf7d63b0e3bdb6caa47e2272dcfaf4fbfe46f8c3a9df087a829b
|
141
173
|
unicode-display_width (2.4.2) sha256=6a10205d1a19ca790c4e53064ba93f09d9eb234bf6bd135d9deb6001c21428be
|
142
174
|
|
data/click_house-client.gemspec
CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.description = "This Gem provides a simple way to query ClickHouse databases using the HTTP interface."
|
13
13
|
spec.homepage = "https://gitlab.com/gitlab-org/ruby/gems/clickhouse-client"
|
14
14
|
spec.license = "MIT"
|
15
|
-
spec.required_ruby_version = ">= 3.
|
15
|
+
spec.required_ruby_version = ">= 3.1"
|
16
16
|
|
17
17
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
18
18
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
@@ -20,7 +20,8 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.require_paths = ["lib"]
|
22
22
|
|
23
|
-
spec.add_runtime_dependency "
|
23
|
+
spec.add_runtime_dependency "activerecord", "~> 7.0"
|
24
|
+
spec.add_runtime_dependency "activesupport", "~> 7.0"
|
24
25
|
spec.add_runtime_dependency "addressable", "~> 2.8"
|
25
26
|
spec.add_runtime_dependency 'json', '~> 2.7'
|
26
27
|
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ClickHouse
|
4
|
+
module Client
|
5
|
+
class ArelEngine
|
6
|
+
def quote_table_name(name)
|
7
|
+
"`#{name}`" # Safest approach for ClickHouse
|
8
|
+
end
|
9
|
+
|
10
|
+
def quote_column_name(name)
|
11
|
+
quote_table_name(name)
|
12
|
+
end
|
13
|
+
|
14
|
+
def quote(value)
|
15
|
+
ClickHouse::Client::Quoting.quote(value)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,156 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_record'
|
4
|
+
|
5
|
+
module ClickHouse
|
6
|
+
module Client
|
7
|
+
class QueryBuilder < QueryLike
|
8
|
+
attr_reader :table
|
9
|
+
attr_accessor :conditions, :manager
|
10
|
+
|
11
|
+
VALID_NODES = [
|
12
|
+
Arel::Nodes::In,
|
13
|
+
Arel::Nodes::Equality,
|
14
|
+
Arel::Nodes::LessThan,
|
15
|
+
Arel::Nodes::LessThanOrEqual,
|
16
|
+
Arel::Nodes::GreaterThan,
|
17
|
+
Arel::Nodes::GreaterThanOrEqual,
|
18
|
+
Arel::Nodes::NamedFunction
|
19
|
+
].freeze
|
20
|
+
|
21
|
+
def initialize(table_name)
|
22
|
+
@table = Arel::Table.new(table_name)
|
23
|
+
@manager = Arel::SelectManager.new(Arel::Table.engine).from(@table).project(Arel.star)
|
24
|
+
@conditions = []
|
25
|
+
end
|
26
|
+
|
27
|
+
# The `where` method currently only supports IN and equal to queries along
|
28
|
+
# with above listed VALID_NODES.
|
29
|
+
# For example, using a range (start_date..end_date) will result in incorrect SQL.
|
30
|
+
# If you need to query a range, use greater than and less than conditions with Arel.
|
31
|
+
#
|
32
|
+
# Correct usage:
|
33
|
+
# query.where(query.table[:created_at].lteq(Date.today)).to_sql
|
34
|
+
# "SELECT * FROM \"table\" WHERE \"table\".\"created_at\" <= '2023-08-01'"
|
35
|
+
#
|
36
|
+
# This also supports array conditions which will result in an IN query.
|
37
|
+
# query.where(entity_id: [1,2,3]).to_sql
|
38
|
+
# "SELECT * FROM \"table\" WHERE \"table\".\"entity_id\" IN (1, 2, 3)"
|
39
|
+
#
|
40
|
+
# Range support and more `Arel::Nodes` could be considered for future iterations.
|
41
|
+
# @return [ClickHouse::QueryBuilder] New instance of query builder.
|
42
|
+
def where(conditions)
|
43
|
+
validate_condition_type!(conditions)
|
44
|
+
|
45
|
+
deep_clone.tap do |new_instance|
|
46
|
+
if conditions.is_a?(Arel::Nodes::Node)
|
47
|
+
new_instance.conditions << conditions
|
48
|
+
else
|
49
|
+
add_conditions_to(new_instance, conditions)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def select(*fields)
|
55
|
+
deep_clone.tap do |new_instance|
|
56
|
+
existing_fields = new_instance.manager.projections.filter_map do |projection|
|
57
|
+
if projection.is_a?(Arel::Attributes::Attribute)
|
58
|
+
projection.name.to_s
|
59
|
+
elsif projection.to_s == '*'
|
60
|
+
nil
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
new_projections = (existing_fields + fields).map do |field|
|
65
|
+
if field.is_a?(Symbol)
|
66
|
+
field.to_s
|
67
|
+
else
|
68
|
+
field
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
new_instance.manager.projections = new_projections.uniq.map do |field|
|
73
|
+
if field.is_a?(Arel::Expressions)
|
74
|
+
field
|
75
|
+
else
|
76
|
+
new_instance.table[field.to_s]
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def order(field, direction = :asc)
|
83
|
+
validate_order_direction!(direction)
|
84
|
+
|
85
|
+
deep_clone.tap do |new_instance|
|
86
|
+
table_field = new_instance.table[field]
|
87
|
+
new_order = direction.to_s.casecmp('desc').zero? ? table_field.desc : table_field.asc
|
88
|
+
new_instance.manager.order(new_order)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def group(*columns)
|
93
|
+
deep_clone.tap do |new_instance|
|
94
|
+
new_instance.manager.group(*columns)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def limit(count)
|
99
|
+
manager.take(count)
|
100
|
+
self
|
101
|
+
end
|
102
|
+
|
103
|
+
def offset(count)
|
104
|
+
manager.skip(count)
|
105
|
+
self
|
106
|
+
end
|
107
|
+
|
108
|
+
def to_sql
|
109
|
+
apply_conditions!
|
110
|
+
|
111
|
+
visitor = Arel::Visitors::ToSql.new(ClickHouse::Client::ArelEngine.new)
|
112
|
+
visitor.accept(manager.ast, Arel::Collectors::SQLString.new).value
|
113
|
+
end
|
114
|
+
|
115
|
+
def to_redacted_sql(bind_index_manager = ClickHouse::Client::BindIndexManager.new)
|
116
|
+
ClickHouse::Client::Redactor.redact(self, bind_index_manager)
|
117
|
+
end
|
118
|
+
|
119
|
+
private
|
120
|
+
|
121
|
+
def validate_condition_type!(condition)
|
122
|
+
return unless condition.is_a?(Arel::Nodes::Node) && VALID_NODES.exclude?(condition.class)
|
123
|
+
|
124
|
+
raise ArgumentError, "Unsupported Arel node type for QueryBuilder: #{condition.class.name}"
|
125
|
+
end
|
126
|
+
|
127
|
+
def add_conditions_to(instance, conditions)
|
128
|
+
conditions.each do |key, value|
|
129
|
+
instance.conditions << if value.is_a?(Array)
|
130
|
+
instance.table[key].in(value)
|
131
|
+
else
|
132
|
+
instance.table[key].eq(value)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
def deep_clone
|
138
|
+
self.class.new(table.name).tap do |new_instance|
|
139
|
+
new_instance.manager = manager.clone
|
140
|
+
new_instance.conditions = conditions.map(&:clone)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
def apply_conditions!
|
145
|
+
manager.constraints.clear
|
146
|
+
conditions.each { |condition| manager.where(condition) }
|
147
|
+
end
|
148
|
+
|
149
|
+
def validate_order_direction!(direction)
|
150
|
+
return if %w[asc desc].include?(direction.to_s.downcase)
|
151
|
+
|
152
|
+
raise ArgumentError, "Invalid order direction '#{direction}'. Must be :asc or :desc"
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
@@ -6,12 +6,19 @@ module ClickHouse
|
|
6
6
|
class << self
|
7
7
|
def quote(value)
|
8
8
|
case value
|
9
|
-
when
|
9
|
+
when Numeric then value.to_s
|
10
|
+
when String, Symbol then "'#{value.to_s.gsub('\\', '\&\&').gsub("'", "''")}'"
|
10
11
|
when Array then "[#{value.map { |v| quote(v) }.join(',')}]"
|
11
12
|
when nil then "NULL"
|
12
|
-
else value
|
13
|
+
else quote_str(value.to_s)
|
13
14
|
end
|
14
15
|
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def quote_str(value)
|
20
|
+
"'#{value.gsub("'", "''")}'"
|
21
|
+
end
|
15
22
|
end
|
16
23
|
end
|
17
24
|
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ClickHouse
|
4
|
+
module Client
|
5
|
+
module Redactor
|
6
|
+
# Redacts the SQL query represented by the query builder.
|
7
|
+
#
|
8
|
+
# @param query_builder [::ClickHouse::Querybuilder] The query builder object to be redacted.
|
9
|
+
# @return [String] The redacted SQL query as a string.
|
10
|
+
# @raise [ArgumentError] when the condition in the query is of an unsupported type.
|
11
|
+
#
|
12
|
+
# Example:
|
13
|
+
# query_builder = ClickHouse::QueryBuilder.new('users').where(name: 'John Doe')
|
14
|
+
# redacted_query = ClickHouse::Redactor.redact(query_builder)
|
15
|
+
# # The redacted_query will contain the SQL query with values replaced by placeholders.
|
16
|
+
# output: "SELECT * FROM \"users\" WHERE \"users\".\"name\" = $1"
|
17
|
+
def self.redact(query_builder, bind_manager = ClickHouse::Client::BindIndexManager.new)
|
18
|
+
cloned_query_builder = query_builder.clone
|
19
|
+
|
20
|
+
cloned_query_builder.conditions = cloned_query_builder.conditions.map do |condition|
|
21
|
+
redact_condition(condition, bind_manager)
|
22
|
+
end
|
23
|
+
|
24
|
+
cloned_query_builder.manager.constraints.clear
|
25
|
+
cloned_query_builder.conditions.each do |condition|
|
26
|
+
cloned_query_builder.manager.where(condition)
|
27
|
+
end
|
28
|
+
|
29
|
+
visitor = Arel::Visitors::ToSql.new(ClickHouse::Client::ArelEngine.new)
|
30
|
+
visitor.accept(cloned_query_builder.manager.ast, Arel::Collectors::SQLString.new).value
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.redact_condition(condition, bind_manager)
|
34
|
+
case condition
|
35
|
+
when Arel::Nodes::In
|
36
|
+
condition.left.in(Array.new(condition.right.size) { Arel.sql(bind_manager.next_bind_str) })
|
37
|
+
when Arel::Nodes::Equality
|
38
|
+
condition.left.eq(Arel.sql(bind_manager.next_bind_str))
|
39
|
+
when Arel::Nodes::LessThan
|
40
|
+
condition.left.lt(Arel.sql(bind_manager.next_bind_str))
|
41
|
+
when Arel::Nodes::LessThanOrEqual
|
42
|
+
condition.left.lteq(Arel.sql(bind_manager.next_bind_str))
|
43
|
+
when Arel::Nodes::GreaterThan
|
44
|
+
condition.left.gt(Arel.sql(bind_manager.next_bind_str))
|
45
|
+
when Arel::Nodes::GreaterThanOrEqual
|
46
|
+
condition.left.gteq(Arel.sql(bind_manager.next_bind_str))
|
47
|
+
when Arel::Nodes::NamedFunction
|
48
|
+
redact_named_function(condition, bind_manager)
|
49
|
+
else
|
50
|
+
raise ArgumentError, "Unsupported Arel node type for Redactor: #{condition.class}"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.redact_named_function(condition, bind_manager)
|
55
|
+
redacted_condition =
|
56
|
+
Arel::Nodes::NamedFunction.new(condition.name, condition.expressions.dup)
|
57
|
+
|
58
|
+
case redacted_condition.name
|
59
|
+
when 'startsWith'
|
60
|
+
redacted_condition.expressions[1] = Arel.sql(bind_manager.next_bind_str)
|
61
|
+
else
|
62
|
+
redacted_condition.expressions = redacted_condition.expressions.map { Arel.sql(bind_manager.next_bind_str) }
|
63
|
+
end
|
64
|
+
|
65
|
+
redacted_condition
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
data/lib/click_house/client.rb
CHANGED
@@ -2,16 +2,21 @@
|
|
2
2
|
|
3
3
|
require 'addressable'
|
4
4
|
require 'json'
|
5
|
+
require 'active_support/deprecation'
|
5
6
|
require 'active_support/time'
|
6
7
|
require 'active_support/notifications'
|
8
|
+
require 'active_support/core_ext/string'
|
7
9
|
require 'active_support/core_ext/object/blank'
|
8
10
|
require_relative "client/version"
|
9
11
|
require_relative "client/database"
|
10
12
|
require_relative "client/configuration"
|
11
13
|
require_relative "client/bind_index_manager"
|
12
14
|
require_relative "client/quoting"
|
15
|
+
require_relative "client/arel_engine"
|
13
16
|
require_relative "client/query_like"
|
14
17
|
require_relative "client/query"
|
18
|
+
require_relative "client/redactor"
|
19
|
+
require_relative "client/query_builder"
|
15
20
|
require_relative "client/formatter"
|
16
21
|
require_relative "client/response"
|
17
22
|
|
@@ -76,7 +81,7 @@ module ClickHouse
|
|
76
81
|
)
|
77
82
|
|
78
83
|
query = ClickHouse::Client::Query.build(query)
|
79
|
-
ActiveSupport::Notifications.instrument('sql.click_house', { query
|
84
|
+
ActiveSupport::Notifications.instrument('sql.click_house', { query:, database: }) do |instrument|
|
80
85
|
response = configuration.http_post_proc.call(
|
81
86
|
db.build_custom_uri(extra_variables: { query: query.to_sql }).to_s,
|
82
87
|
headers,
|
@@ -111,7 +116,7 @@ module ClickHouse
|
|
111
116
|
log_contents = configuration.log_proc.call(query)
|
112
117
|
configuration.logger.info(log_contents)
|
113
118
|
|
114
|
-
ActiveSupport::Notifications.instrument('sql.click_house', { query
|
119
|
+
ActiveSupport::Notifications.instrument('sql.click_house', { query:, database: }) do |instrument|
|
115
120
|
# Use a multipart POST request where the placeholders are sent with the param_ prefix
|
116
121
|
# See: https://github.com/ClickHouse/ClickHouse/issues/8842
|
117
122
|
query_with_params = query.prepared_placeholders.transform_keys { |key| "param_#{key}" }
|
metadata
CHANGED
@@ -1,29 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: click_house-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- group::optimize
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-07-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activerecord
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '7.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '7.0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: activesupport
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
16
30
|
requirements:
|
17
|
-
- - "
|
31
|
+
- - "~>"
|
18
32
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
33
|
+
version: '7.0'
|
20
34
|
type: :runtime
|
21
35
|
prerelease: false
|
22
36
|
version_requirements: !ruby/object:Gem::Requirement
|
23
37
|
requirements:
|
24
|
-
- - "
|
38
|
+
- - "~>"
|
25
39
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
40
|
+
version: '7.0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: addressable
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -141,13 +155,16 @@ files:
|
|
141
155
|
- README.md
|
142
156
|
- click_house-client.gemspec
|
143
157
|
- lib/click_house/client.rb
|
158
|
+
- lib/click_house/client/arel_engine.rb
|
144
159
|
- lib/click_house/client/bind_index_manager.rb
|
145
160
|
- lib/click_house/client/configuration.rb
|
146
161
|
- lib/click_house/client/database.rb
|
147
162
|
- lib/click_house/client/formatter.rb
|
148
163
|
- lib/click_house/client/query.rb
|
164
|
+
- lib/click_house/client/query_builder.rb
|
149
165
|
- lib/click_house/client/query_like.rb
|
150
166
|
- lib/click_house/client/quoting.rb
|
167
|
+
- lib/click_house/client/redactor.rb
|
151
168
|
- lib/click_house/client/response.rb
|
152
169
|
- lib/click_house/client/version.rb
|
153
170
|
homepage: https://gitlab.com/gitlab-org/ruby/gems/clickhouse-client
|
@@ -162,7 +179,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
162
179
|
requirements:
|
163
180
|
- - ">="
|
164
181
|
- !ruby/object:Gem::Version
|
165
|
-
version: '3.
|
182
|
+
version: '3.1'
|
166
183
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
167
184
|
requirements:
|
168
185
|
- - ">="
|