bulk_dependency_eraser 1.4.1 → 1.4.2
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 734c542b83d1cf827cadf8a8a41c30d8a86ebe7f98e539e0bdce4777f917c2e9
|
4
|
+
data.tar.gz: fedb350237abe9898c2d54077db57c1c500b76c99c6913431c2445f5fd49293a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b69927dd186b6eac307ff85a5bd06783245c5173a6d890ff29a8abb42edbf8df105a3ed592cf3ae92f649c4547f32c289316b83ae7f02d19233a05d9a2a5d47
|
7
|
+
data.tar.gz: 9a4febdbdd779faf17bc332b8853c41bb727e722fea564ed45a8b871ee53f8e4677983c2459a4894a4304c90397a48fa927d41609e4558033ee24c43badbc4b7
|
@@ -37,17 +37,18 @@ module BulkDependencyEraser
|
|
37
37
|
|
38
38
|
protected
|
39
39
|
|
40
|
-
def
|
40
|
+
def custom_scope_for_query(query)
|
41
|
+
klass = query.klass
|
41
42
|
if opts_c.proc_scopes_per_class_name.key?(klass.name)
|
42
|
-
opts_c.proc_scopes_per_class_name[klass.name]
|
43
|
+
opts_c.proc_scopes_per_class_name[klass.name].call(query)
|
43
44
|
else
|
44
45
|
# See if non-class-mapped proc returns a value
|
45
|
-
non_class_name_mapped_query = opts_c.proc_scopes.call(
|
46
|
+
non_class_name_mapped_query = opts_c.proc_scopes.call(query)
|
46
47
|
if !non_class_name_mapped_query.nil?
|
47
|
-
return
|
48
|
+
return non_class_name_mapped_query
|
48
49
|
else
|
49
50
|
# No custom wrapper, return non-effect default
|
50
|
-
return self.class::DEFAULT_KLASS_MAPPED_SCOPE_WRAPPER
|
51
|
+
return self.class::DEFAULT_KLASS_MAPPED_SCOPE_WRAPPER.call(query)
|
51
52
|
end
|
52
53
|
end
|
53
54
|
end
|
@@ -163,11 +163,12 @@ module BulkDependencyEraser
|
|
163
163
|
attr_reader :table_names_to_parsed_klass_names
|
164
164
|
attr_reader :ignore_table_name_and_dependencies, :ignore_klass_name_and_dependencies
|
165
165
|
|
166
|
-
def
|
166
|
+
def custom_scope_for_query(query)
|
167
|
+
klass = query.klass
|
167
168
|
if opts_c.reading_proc_scopes_per_class_name.key?(klass.name)
|
168
|
-
opts_c.reading_proc_scopes_per_class_name[klass.name]
|
169
|
+
opts_c.reading_proc_scopes_per_class_name[klass.name].call(query)
|
169
170
|
else
|
170
|
-
super(
|
171
|
+
super(query)
|
171
172
|
end
|
172
173
|
end
|
173
174
|
|
@@ -175,7 +176,7 @@ module BulkDependencyEraser
|
|
175
176
|
# ordering shouldn't matter in these queries, and would slow it down
|
176
177
|
# - we're ignoring default_scope ordering, but assoc-defined ordering would still take effect
|
177
178
|
query = query.reorder('')
|
178
|
-
query =
|
179
|
+
query = custom_scope_for_query(query)
|
179
180
|
|
180
181
|
query_ids = []
|
181
182
|
read_from_db do
|
@@ -639,7 +640,7 @@ module BulkDependencyEraser
|
|
639
640
|
return
|
640
641
|
end
|
641
642
|
|
642
|
-
query =
|
643
|
+
query = custom_scope_for_query(query)
|
643
644
|
|
644
645
|
foreign_ids_by_type = read_from_db do
|
645
646
|
if batching_disabled? || !query.where({}).limit_value.nil?
|
@@ -77,11 +77,12 @@ module BulkDependencyEraser
|
|
77
77
|
|
78
78
|
attr_reader :class_names_and_ids
|
79
79
|
|
80
|
-
def
|
80
|
+
def custom_scope_for_query(query)
|
81
|
+
klass = query.klass
|
81
82
|
if opts_c.deletion_proc_scopes_per_class_name.key?(klass.name)
|
82
|
-
opts_c.deletion_proc_scopes_per_class_name[klass.name]
|
83
|
+
opts_c.deletion_proc_scopes_per_class_name[klass.name].call(query)
|
83
84
|
else
|
84
|
-
super(
|
85
|
+
super(query)
|
85
86
|
end
|
86
87
|
end
|
87
88
|
|
@@ -96,7 +97,7 @@ module BulkDependencyEraser
|
|
96
97
|
def delete_by_klass_and_ids klass, ids
|
97
98
|
puts "Deleting #{klass.name}'s IDs: #{ids}" if opts_c.verbose
|
98
99
|
query = klass.unscoped
|
99
|
-
query =
|
100
|
+
query = custom_scope_for_query(query)
|
100
101
|
|
101
102
|
if batching_disabled?
|
102
103
|
puts "Deleting without batching" if opts_c.verbose
|
@@ -135,11 +135,12 @@ module BulkDependencyEraser
|
|
135
135
|
|
136
136
|
attr_reader :class_names_columns_and_ids
|
137
137
|
|
138
|
-
def
|
138
|
+
def custom_scope_for_query(query)
|
139
|
+
klass = query.klass
|
139
140
|
if opts_c.nullification_proc_scopes_per_class_name.key?(klass.name)
|
140
|
-
opts_c.nullification_proc_scopes_per_class_name[klass.name]
|
141
|
+
opts_c.nullification_proc_scopes_per_class_name[klass.name].call(query)
|
141
142
|
else
|
142
|
-
super(
|
143
|
+
super(query)
|
143
144
|
end
|
144
145
|
end
|
145
146
|
|
@@ -153,7 +154,7 @@ module BulkDependencyEraser
|
|
153
154
|
|
154
155
|
def nullify_by_klass_column_and_ids klass, columns, ids
|
155
156
|
query = klass.unscoped
|
156
|
-
query =
|
157
|
+
query = custom_scope_for_query(query)
|
157
158
|
|
158
159
|
nullify_columns = {}
|
159
160
|
# supporting nullification of groups of columns simultaneously
|