refine-rails 2.13.8 → 2.14.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: 521418c5dea81f6f37f39181a4685c08208efe9f649b32709224cbfa37e60d05
|
4
|
+
data.tar.gz: 0a48b500cc68e8a798e257d2e24c33679b6bd691c2e3b0cb4f984b5c85846a87
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8fc6d6ea27e7c7052e1d2d798770636f8b847b932c8d3b32d562a2adfa553919e53f78bc45e7e889258a4a65fea5ded9c2b377363b6a6163fc21ce5810cab708
|
7
|
+
data.tar.gz: 42df46f4edc1fe7093514369fc3cfc9b0a31a6e6800c04832fa7cc572981948c886038aedaf65e17d7b4129fa10a2ba9fad04ff7c44f4fe2acdf91bb410a7437
|
@@ -90,7 +90,7 @@ module Refine::Conditions
|
|
90
90
|
|
91
91
|
end # End of while loop
|
92
92
|
|
93
|
-
if condition_joins.any?
|
93
|
+
if condition_joins.any? && !condition_uses_different_database?(model_class, query.model)
|
94
94
|
add_pending_joins_if_needed(input: input, joins_array: condition_joins)
|
95
95
|
end
|
96
96
|
|
@@ -147,10 +147,11 @@ module Refine::Conditions
|
|
147
147
|
# the records matching the condition that will then be passed into the primary query.
|
148
148
|
def handle_flat_cross_database_condition(root_model:, input:, relation_class:, relation_table_being_queried:, inverse_clause:, key_1:, key_2:)
|
149
149
|
table = root_model.arel_table
|
150
|
-
relational_query = relation_class.select(key_2).arel
|
150
|
+
relational_query = relation_class.select(key_2).distinct.arel
|
151
151
|
node = apply(input, relation_table_being_queried, relation_class, inverse_clause)
|
152
152
|
relational_query = relational_query.where(node)
|
153
|
-
|
153
|
+
results = relation_class.find_by_sql(relational_query.to_sql)
|
154
|
+
array_of_ids = results.map { |result| result.send(key_2) }
|
154
155
|
if array_of_ids.length == 1
|
155
156
|
nodes = table[:"#{key_1}"].eq(array_of_ids.first)
|
156
157
|
else
|
data/app/models/refine/filter.rb
CHANGED
@@ -6,7 +6,6 @@ module Refine
|
|
6
6
|
include Stabilize
|
7
7
|
include Internationalized
|
8
8
|
include Inspector
|
9
|
-
include FlatQueryTools
|
10
9
|
# This validation structure sents `initial_query` as the method to validate against
|
11
10
|
define_model_callbacks :initialize, only: [:after]
|
12
11
|
after_initialize :valid?
|
@@ -92,10 +91,10 @@ module Refine
|
|
92
91
|
|
93
92
|
def get_query
|
94
93
|
raise "Initial query must exist" if initial_query.nil?
|
95
|
-
if
|
96
|
-
|
94
|
+
if self.class.included_modules.include?(Refine::FlatQueryTools) && can_use_flat_query?
|
95
|
+
get_flat_query
|
97
96
|
else
|
98
|
-
|
97
|
+
get_complex_query
|
99
98
|
end
|
100
99
|
end
|
101
100
|
|
@@ -105,6 +104,14 @@ module Refine
|
|
105
104
|
result
|
106
105
|
end
|
107
106
|
|
107
|
+
def get_complex_query
|
108
|
+
if blueprint.present?
|
109
|
+
@relation.where(group(make_sub_query(blueprint)))
|
110
|
+
else
|
111
|
+
@relation
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
108
115
|
def add_nodes_to_query(subquery:, nodes:, query_method:)
|
109
116
|
# Apply existing nodes to existing subquery
|
110
117
|
if subquery.present? && nodes.present?
|
@@ -213,6 +220,7 @@ module Refine
|
|
213
220
|
|
214
221
|
def apply_condition(criterion)
|
215
222
|
begin
|
223
|
+
condition = get_condition_for_criterion(criterion)
|
216
224
|
get_condition_for_criterion(criterion)&.apply(criterion[:input], table, initial_query, false, nil)
|
217
225
|
rescue Refine::Conditions::Errors::ConditionClauseError => e
|
218
226
|
e.errors.each do |error|
|
@@ -47,7 +47,16 @@ module Refine
|
|
47
47
|
else
|
48
48
|
unless condition_already_applied?(criteria_or_conjunction)
|
49
49
|
node = apply_flat_condition(criteria_or_conjunction)
|
50
|
-
|
50
|
+
if node.is_a?(Arel::Nodes::Grouping)
|
51
|
+
@relation = @relation.where(node)
|
52
|
+
elsif node.is_a?(Array)
|
53
|
+
error = node.filter{ |n| n.is_a?(ActiveModel::Error) }.first
|
54
|
+
if error
|
55
|
+
filter.errors.add(:base, error.full_message)
|
56
|
+
end
|
57
|
+
else
|
58
|
+
@relation = @relation.where(Arel::Nodes::Grouping.new(node))
|
59
|
+
end
|
51
60
|
track_condition_applied(criteria_or_conjunction)
|
52
61
|
end
|
53
62
|
end
|
@@ -84,7 +93,6 @@ module Refine
|
|
84
93
|
end
|
85
94
|
join_count += 1
|
86
95
|
end
|
87
|
-
|
88
96
|
end
|
89
97
|
end
|
90
98
|
|
@@ -100,5 +108,10 @@ module Refine
|
|
100
108
|
applied_conditions[criterion[:condition_id]] &&
|
101
109
|
applied_conditions[criterion[:condition_id]].include?(criterion[:input])
|
102
110
|
end
|
111
|
+
|
112
|
+
# Meant to be overridden by Filter classes to add or replace with custom logic
|
113
|
+
def can_use_flat_query?
|
114
|
+
!uses_or? && !uses_negative_clause? && !has_duplicate_conditions?
|
115
|
+
end
|
103
116
|
end
|
104
117
|
end
|
data/lib/refine/rails/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: refine-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.14.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Colleen Schnettler
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2025-03
|
12
|
+
date: 2025-06-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|