clickhouse-activerecord 1.6.0 → 1.6.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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3e606a08261b2238dab5e6fbd6fb826fb40631ea063d9dcfc25d99aab052d619
|
|
4
|
+
data.tar.gz: ad9281c124450ad0784c8442c4b20b3c8603f7028ca94f7aa1dbd73d8b0483d3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 70e11a39c963dedc824a9b5b54b805902691f9ed335a33796524ffd50c2f1a3bdea65709accc9847239123973c1b3f77fd675ca0ac40022195c54f5c9410ce96
|
|
7
|
+
data.tar.gz: 768f6a409b98b66a80a6455d97fe4053f97dc60c35ee64d9a9a0310d64a6dbc00fe4b65bba90e7433114d536ed666f6716f2c1c05f13f34287f3e7f0905ebcb1
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Clickhouse::Activerecord
|
|
2
2
|
|
|
3
3
|
A Ruby database ActiveRecord driver for ClickHouse. Support Rails >= 7.1.
|
|
4
|
-
Support ClickHouse version from 22.0 LTS.
|
|
4
|
+
Support ClickHouse version from 22.0 LTS (Testing on 24.6).
|
|
5
5
|
|
|
6
6
|
## Installation
|
|
7
7
|
|
|
@@ -202,6 +202,39 @@ User.window('x', order: 'date', partition: 'name', rows: 'UNBOUNDED PRECEDING').
|
|
|
202
202
|
#=> #<ActiveRecord::Relation [#<User *** >]>
|
|
203
203
|
```
|
|
204
204
|
|
|
205
|
+
### CTE and CSE examples
|
|
206
|
+
|
|
207
|
+
For activation CSE ([Common Scalar Expressions](https://clickhouse.com/docs/sql-reference/statements/select/with#common-scalar-expressions)) in ClickHouse `value` in hash must be a `Symbol` class.
|
|
208
|
+
`key` in a hash must be converting to:
|
|
209
|
+
|
|
210
|
+
* `String` -> quoted string
|
|
211
|
+
* `Symbol` -> raw data
|
|
212
|
+
* `Relation` -> sql query
|
|
213
|
+
|
|
214
|
+
See in examples:
|
|
215
|
+
|
|
216
|
+
```ruby
|
|
217
|
+
# CTE
|
|
218
|
+
Action.with(t: ActionView.where(event_name: 'test')).where(event_name: Action.from('t').select('event_name'))
|
|
219
|
+
# Clickhouse (10.3ms) WITH t AS (SELECT action_view.* FROM action_view WHERE action_view.event_name = \'test\') SELECT actions.* FROM actions WHERE actions.event_name IN (SELECT event_name FROM t)
|
|
220
|
+
#=> #<ActiveRecord::Relation [#<Action *** >]>
|
|
221
|
+
|
|
222
|
+
# CSE with string key
|
|
223
|
+
Action.with('2026-01-01 15:23:00' => :t).where(Arel.sql('date = toDate(t)'))
|
|
224
|
+
# Clickhouse (10.3ms) WITH '2026-01-01 15:23:00' AS t SELECT actions.* FROM actions WHERE (date = toDate(t))
|
|
225
|
+
#=> #<ActiveRecord::Relation [#<Action *** >]>
|
|
226
|
+
|
|
227
|
+
# CSE with symbol key
|
|
228
|
+
Action.with('(id, extension) -> concat(lower(id), extension)': :t).where(Arel.sql('date = toDate(t)'))
|
|
229
|
+
# Clickhouse (10.3ms) WITH (id, extension) -> concat(lower(id), extension) AS t SELECT actions.* FROM actions WHERE (date = toDate(t))
|
|
230
|
+
#=> #<ActiveRecord::Relation [#<Action *** >]>
|
|
231
|
+
|
|
232
|
+
# CSE with ActiveRecord relation key
|
|
233
|
+
Action.with(ActionView.select(Arel.sql('min(date)')) => :min_date).where(Arel.sql('date = min_date'))
|
|
234
|
+
# Clickhouse (10.3ms) WITH (SELECT min(date) FROM action_view) AS min_date SELECT actions.* FROM actions WHERE (date = min_date)
|
|
235
|
+
#=> #<ActiveRecord::Relation [#<Action *** >]>
|
|
236
|
+
```
|
|
237
|
+
|
|
205
238
|
|
|
206
239
|
### Migration Data Types
|
|
207
240
|
|
|
@@ -197,7 +197,7 @@ module ActiveRecord
|
|
|
197
197
|
if (duplicate = inserting.detect { |v| inserting.count(v) > 1 })
|
|
198
198
|
raise "Duplicate migration #{duplicate}. Please renumber your migrations to resolve the conflict."
|
|
199
199
|
end
|
|
200
|
-
execute(insert_versions_sql(inserting), nil, settings: {max_partitions_per_insert_block: [100, inserting.size].max})
|
|
200
|
+
execute(insert_versions_sql(inserting), nil, format: nil, settings: {max_partitions_per_insert_block: [100, inserting.size].max})
|
|
201
201
|
end
|
|
202
202
|
end
|
|
203
203
|
|
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.6.
|
|
4
|
+
version: 1.6.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: 2026-01-
|
|
11
|
+
date: 2026-01-20 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -169,7 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
169
169
|
- !ruby/object:Gem::Version
|
|
170
170
|
version: '0'
|
|
171
171
|
requirements: []
|
|
172
|
-
rubygems_version: 3.
|
|
172
|
+
rubygems_version: 3.3.7
|
|
173
173
|
signing_key:
|
|
174
174
|
specification_version: 4
|
|
175
175
|
summary: ClickHouse ActiveRecord
|