activerecord_views 0.0.19 → 0.0.20
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/active_record_views.rb +11 -9
- data/lib/active_record_views/version.rb +1 -1
- data/spec/active_record_views_spec.rb +15 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b7bd9cd5324106a6834c7121d6dc674bb622a61866edcecd968a0ed87b2000c2
|
4
|
+
data.tar.gz: 850fcbff468562ace2ae45a4cf8a9f255ef0e9dcc26be6efba8191247731b4b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a87e872a8469f95873acf78c06ab136156514c70d0fecf63da7f0a6038ebd39cd75e0a79b52786abcff8f5b23fc443dd8393d0a6f96d57d23864c846fce1df28
|
7
|
+
data.tar.gz: 6bf70cae5bffa0791d9d5ad82ea931cb06b02e893d19fd801c33b5401f841e2b5cb01ed88574762a6448f2ec3e0d9e0e0310139ec25a1105b7cb6858b7cb2eeb
|
data/lib/active_record_views.rb
CHANGED
@@ -152,19 +152,21 @@ module ActiveRecordViews
|
|
152
152
|
end
|
153
153
|
end
|
154
154
|
|
155
|
-
def self.drop_all_views(
|
156
|
-
|
155
|
+
def self.drop_all_views(base_connection)
|
156
|
+
without_transaction base_connection do |connection|
|
157
|
+
names = Set.new connection.select_values('SELECT name FROM active_record_views;')
|
157
158
|
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
159
|
+
func = lambda do |name|
|
160
|
+
if view_exists?(connection, name)
|
161
|
+
get_view_dependants(connection, name).each do |dependant_name, _, _, _|
|
162
|
+
func.call(dependant_name)
|
163
|
+
end
|
164
|
+
drop_view connection, name
|
162
165
|
end
|
163
|
-
drop_view connection, name
|
164
166
|
end
|
165
|
-
end
|
166
167
|
|
167
|
-
|
168
|
+
names.each { |name| func.call(name) }
|
169
|
+
end
|
168
170
|
end
|
169
171
|
|
170
172
|
def self.execute_create_view(connection, name, sql, options)
|
@@ -120,6 +120,21 @@ describe ActiveRecordViews do
|
|
120
120
|
expect(view_names).to match_array %w[unmanaged]
|
121
121
|
end
|
122
122
|
|
123
|
+
it 'support being ran inside a transaction' do
|
124
|
+
expect(ActiveRecordViews).to receive(:without_transaction).at_least(:once).and_wrap_original do |original, *args, &block|
|
125
|
+
original.call(*args) do |new_connection|
|
126
|
+
new_connection.execute 'SET statement_timeout = 1000'
|
127
|
+
block.call(new_connection)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
connection.transaction requires_new: true do
|
132
|
+
expect {
|
133
|
+
ActiveRecordViews.drop_all_views connection
|
134
|
+
}.to change { view_names }
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
123
138
|
it 'errors if an unmanaged view depends on a managed view' do
|
124
139
|
connection.execute 'CREATE VIEW unmanaged AS SELECT * from dependant2a'
|
125
140
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord_views
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Weathered
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -154,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
154
154
|
version: '0'
|
155
155
|
requirements: []
|
156
156
|
rubyforge_project:
|
157
|
-
rubygems_version: 2.6
|
157
|
+
rubygems_version: 2.7.6
|
158
158
|
signing_key:
|
159
159
|
specification_version: 4
|
160
160
|
summary: Automatic database view creation for ActiveRecord
|