Skip to content

Commit 5f2fbf4

Browse files
committed
request with synchronize, update testing workflow
1 parent 545c1ac commit 5f2fbf4

4 files changed

Lines changed: 19 additions & 11 deletions

File tree

.github/workflows/testing.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ jobs:
3030
rails: 7.2.1
3131
- ruby: 3.2
3232
rails: 8.0.1
33-
clickhouse: [ '22.1', '24.6' ]
33+
clickhouse: [ '22.1', '24.9' ]
3434

3535
steps:
3636
- uses: actions/checkout@v4
3737

3838
- name: Start ClickHouse ${{ matrix.clickhouse }}
39-
uses: isbang/compose-action@v1.5.1
39+
uses: hoverkraft-tech/compose-action@v2.1.0
4040
env:
4141
CLICKHOUSE_VERSION: ${{ matrix.clickhouse }}
4242
with:
@@ -74,14 +74,16 @@ jobs:
7474
- ruby: 3.2
7575
rails: 7.1.3
7676
- ruby: 3.2
77-
rails: 7.2.0
78-
clickhouse: [ '22.1', '24.6' ]
77+
rails: 7.2.1
78+
- ruby: 3.2
79+
rails: 8.0.1
80+
clickhouse: [ '22.1', '24.9' ]
7981

8082
steps:
8183
- uses: actions/checkout@v4
8284

8385
- name: Start ClickHouse Cluster ${{ matrix.clickhouse }}
84-
uses: isbang/compose-action@v1.5.1
86+
uses: hoverkraft-tech/compose-action@v2.1.0
8587
env:
8688
CLICKHOUSE_VERSION: ${{ matrix.clickhouse }}
8789
with:

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,11 @@ Action.settings(optimize_read_in_order: 1).where(date: Date.current).limit(10)
184184

185185
User.joins(:actions).using(:group_id)
186186
# Clickhouse User Load (10.3ms) SELECT users.* FROM users INNER JOIN actions USING group_id
187-
#=> #<ActiveRecord::Relation [#<Action *** >]>
187+
#=> #<ActiveRecord::Relation [#<User *** >]>
188+
189+
User.window('x', order: 'date', partition: 'name', rows: 'UNBOUNDED PRECEDING').select('sum(value) OVER x')
190+
# SELECT sum(value) OVER x FROM users WINDOW x AS (PARTITION BY name ORDER BY date ROWS UNBOUNDED PRECEDING)
191+
#=> #<ActiveRecord::Relation [#<User *** >]>
188192
```
189193

190194

lib/active_record/connection_adapters/clickhouse/schema_statements.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,12 @@ def with_yaml_fallback(value) # :nodoc:
178178
def request(sql, format = nil, settings = {})
179179
formatted_sql = apply_format(sql, format)
180180
request_params = @connection_config || {}
181-
@connection.post("/?#{request_params.merge(settings).to_param}", formatted_sql, {
182-
'User-Agent' => "Clickhouse ActiveRecord #{ClickhouseActiverecord::VERSION}",
183-
'Content-Type' => 'application/x-www-form-urlencoded',
184-
})
181+
@lock.synchronize do
182+
@connection.post("/?#{request_params.merge(settings).to_param}", formatted_sql, {
183+
'User-Agent' => "Clickhouse ActiveRecord #{ClickhouseActiverecord::VERSION}",
184+
'Content-Type' => 'application/x-www-form-urlencoded',
185+
})
186+
end
185187
end
186188

187189
def apply_format(sql, format)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module ClickhouseActiverecord
2-
VERSION = '1.2.1'
2+
VERSION = '1.3.0'
33
end

0 commit comments

Comments
 (0)