clickhouse-activerecord 1.0.12 → 1.0.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: bb1844d5c04115646e36f7914b9d3e46872f28d87e941354eb01313df6228df9
4
- data.tar.gz: b7ec986391a326ac03d910dfbd40820f339c8f6d49ee937a863c5ea0fffc336f
3
+ metadata.gz: 71882da78e208681ad3f28c05bfad0ca4746f8e6b046a4b8cd14c2fa26a007b6
4
+ data.tar.gz: b0daa57171963e98a6d0aa4284b7728731009960a07cbdd45a0cc104fcb14213
5
5
  SHA512:
6
- metadata.gz: 188bfb4db6343255fb738658d44133380e31806257af0fc3a1077f7483033e47dca2d7f460ac8070859624c1cb77ec208a953d441dae83af39199279e1341a6b
7
- data.tar.gz: 9cd536b970e75d0a2ecaf2a1651216dcefbab1ff85cbdfacb5437b57ddf54b56ad8866ee905cfbf9f7c105a771ead6e783de6e5819362c36944d23993e519bf2
6
+ metadata.gz: aea7e2146f23b6183e4583a1b5cc7e4a38131fabff83574415a1e6c8bd607089305265c53ddb54dcbe2c476144d21b4b97795123cd7bfa038ef7a975de7bde9d
7
+ data.tar.gz: 2228a7f2a7e71005f2d2bb910c721373671bdbb7a6ea15e370ecd923a8fb47fa7cebaa548b50ed7ca9bf8d6d6c2ac27a95cca8c680604ba95934866b6488a8b9
data/README.md CHANGED
@@ -149,7 +149,15 @@ Structure load from `db/clickhouse_structure.sql` file:
149
149
  $ rake db:schema:dump
150
150
  $ rake db:schema:load
151
151
  $ rake db:structure:dump
152
- $ rake db:structure:load
152
+ $ rake db:structure:load
153
+
154
+ ### RSpec
155
+
156
+ For auto truncate tables before each test add to `spec/rails_helper.rb` file:
157
+
158
+ ```
159
+ require 'clickhouse-activerecord/rspec'
160
+ ```
153
161
 
154
162
  ### Insert and select data
155
163
 
@@ -133,6 +133,16 @@ module ActiveRecord
133
133
  connect
134
134
  end
135
135
 
136
+ # Savepoints are not supported, noop
137
+ def create_savepoint(name)
138
+ end
139
+
140
+ def exec_rollback_to_savepoint(name)
141
+ end
142
+
143
+ def release_savepoint(name)
144
+ end
145
+
136
146
  def migrations_paths
137
147
  @config[:migrations_paths] || 'db/migrate_clickhouse'
138
148
  end
@@ -264,7 +274,7 @@ module ActiveRecord
264
274
  # @param [String] table
265
275
  # @return [String]
266
276
  def show_create_table(table)
267
- do_system_execute("SHOW CREATE TABLE `#{table}`")['data'].try(:first).try(:first).gsub(/[\n\s]+/m, ' ')
277
+ do_system_execute("SHOW CREATE TABLE `#{table}`")['data'].try(:first).try(:first).gsub(/[\n\s]+/m, ' ').gsub("#{@config[:database]}.", "")
268
278
  end
269
279
 
270
280
  # Create a new ClickHouse database.
@@ -16,8 +16,12 @@ module Arel
16
16
  # https://clickhouse.com/docs/en/sql-reference/statements/delete
17
17
  # DELETE and UPDATE in ClickHouse working only without table name
18
18
  def visit_Arel_Attributes_Attribute(o, collector)
19
- collector << quote_table_name(o.relation.table_alias || o.relation.name) << '.' unless collector.value.start_with?('DELETE FROM ') || collector.value.include?(' UPDATE ')
20
- collector << quote_column_name(o.name)
19
+ if collector.value.is_a?(String)
20
+ collector << quote_table_name(o.relation.table_alias || o.relation.name) << '.' unless collector.value.start_with?('DELETE FROM ') || collector.value.include?(' UPDATE ')
21
+ collector << quote_column_name(o.name)
22
+ else
23
+ super
24
+ end
21
25
  end
22
26
 
23
27
  def visit_Arel_Nodes_SelectOptions(o, collector)
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.configure do |config|
4
+ config.before do
5
+ ActiveRecord::Base.configurations.configurations.select { |x| x.env_name == Rails.env && x.adapter == 'clickhouse' }.each do |config|
6
+ ActiveRecord::Base.establish_connection(config)
7
+ ActiveRecord::Base.connection.tables.each do |table|
8
+ ActiveRecord::Base.connection.execute("TRUNCATE TABLE #{table}")
9
+ end
10
+ end
11
+ end
12
+ end
@@ -1,3 +1,3 @@
1
1
  module ClickhouseActiverecord
2
- VERSION = '1.0.12'
2
+ VERSION = '1.0.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: 1.0.12
4
+ version: 1.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergey Odintsov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-07-22 00:00:00.000000000 Z
11
+ date: 2024-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -121,6 +121,7 @@ files:
121
121
  - lib/arel/visitors/clickhouse.rb
122
122
  - lib/clickhouse-activerecord.rb
123
123
  - lib/clickhouse-activerecord/railtie.rb
124
+ - lib/clickhouse-activerecord/rspec.rb
124
125
  - lib/clickhouse-activerecord/schema.rb
125
126
  - lib/clickhouse-activerecord/schema_dumper.rb
126
127
  - lib/clickhouse-activerecord/tasks.rb