refine-rails 2.12.2 → 2.13.0
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 +4 -4
- data/app/models/refine/conditions/condition.rb +4 -1
- data/app/models/refine/conditions/has_through_id_relationship.rb +10 -0
- data/app/models/refine/conditions/uses_attributes.rb +23 -2
- data/app/models/refine/conditions/with_forced_index.rb +10 -0
- data/lib/refine/rails/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f89d05537180f0c65bab1c517d5a3063ff92339649ee1900285075cc24e3573a
|
4
|
+
data.tar.gz: 118ac4a2cb4616844d555bb13f1fe09cdb5bc4b17101f39cb0b2ed7278b335c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd219b511cb2d34007f96e84c5c2768b3547e4ef6b24e85ea4a4d69112f65a5583dfaeb1d04140f82a81ad6a60d2c4548fdb03ac60bb33c3d836bd6dac9320ea
|
7
|
+
data.tar.gz: cfa3ec1d60a35524087f52a754af043e0eb880ba9717444808b5d6ef173bb0860cb674c45fbc6c756964c4a8f2c17509d1b315dbf52929b167acfbdcbf450c11
|
@@ -10,6 +10,8 @@ module Refine::Conditions
|
|
10
10
|
include HasMeta
|
11
11
|
include UsesAttributes
|
12
12
|
include HasRefinements
|
13
|
+
include HasThroughIdRelationship
|
14
|
+
include WithForcedIndex
|
13
15
|
include HasIcon
|
14
16
|
|
15
17
|
attr_reader :ensurances, :before_validations, :clause, :filter
|
@@ -122,7 +124,7 @@ module Refine::Conditions
|
|
122
124
|
# @param [Arel::Table] table The arel_table the query is built on
|
123
125
|
# @param [ActiveRecord::Relation] initial_query The base query the query is built on
|
124
126
|
# @return [Arel::Node]
|
125
|
-
def apply(input, table, initial_query, inverse_clause=false)
|
127
|
+
def apply(input, table, initial_query, inverse_clause=false, through_attribute=nil)
|
126
128
|
table ||= filter.table
|
127
129
|
# Ensurance validations are checking the developer configured correctly
|
128
130
|
run_ensurance_validations
|
@@ -150,6 +152,7 @@ module Refine::Conditions
|
|
150
152
|
return
|
151
153
|
end
|
152
154
|
# No longer a relationship attribute, apply condition normally
|
155
|
+
self.attribute = through_attribute if through_attribute
|
153
156
|
nodes = apply_condition(input, table, inverse_clause)
|
154
157
|
if !is_refinement && has_any_refinements?
|
155
158
|
refined_node = apply_refinements(input)
|
@@ -123,9 +123,30 @@ module Refine::Conditions
|
|
123
123
|
relation_table_being_queried = instance.klass.arel_table
|
124
124
|
|
125
125
|
relation_class = instance.klass
|
126
|
-
|
127
|
-
node_to_apply = apply(input, relation_table_being_queried, relation_class, inverse_clause)
|
128
126
|
|
127
|
+
if self.through_id_relationship
|
128
|
+
if instance.is_a? ActiveRecord::Reflection::ThroughReflection
|
129
|
+
through_reflection = instance.through_reflection
|
130
|
+
parent_foreign_key = through_reflection.foreign_key
|
131
|
+
child_foreign_key = instance.source_reflection.foreign_key
|
132
|
+
relation_table_being_queried = through_reflection.klass.arel_table
|
133
|
+
relation_class = through_reflection.klass
|
134
|
+
subquery_path = through_reflection.klass.select(parent_foreign_key).arel
|
135
|
+
|
136
|
+
node_to_apply = apply(input, relation_table_being_queried, relation_class, inverse_clause, child_foreign_key)
|
137
|
+
else
|
138
|
+
raise "with_through_id must be used with a has_many :through relationship"
|
139
|
+
end
|
140
|
+
else
|
141
|
+
node_to_apply = apply(input, relation_table_being_queried, relation_class, inverse_clause)
|
142
|
+
end
|
143
|
+
|
144
|
+
if self.forced_index
|
145
|
+
mysql_from_segment = "`#{through_reflection.table_name}` FORCE INDEX(`#{self.forced_index}`)"
|
146
|
+
# Ensuring input is sanitized
|
147
|
+
subquery_path = subquery_path.from(Arel.sql(mysql_from_segment))
|
148
|
+
end
|
149
|
+
|
129
150
|
complete_subquery = subquery_path.where(node_to_apply)
|
130
151
|
subquery = filter.get_pending_relationship_subquery || complete_subquery
|
131
152
|
filter.add_pending_relationship_subquery(subquery: subquery, primary_key: key_1(instance), secondary_key: nil, inverse_clause: inverse_clause)
|
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.13.0
|
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: 2024-12-
|
12
|
+
date: 2024-12-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -97,10 +97,12 @@ files:
|
|
97
97
|
- app/models/refine/conditions/has_icon.rb
|
98
98
|
- app/models/refine/conditions/has_meta.rb
|
99
99
|
- app/models/refine/conditions/has_refinements.rb
|
100
|
+
- app/models/refine/conditions/has_through_id_relationship.rb
|
100
101
|
- app/models/refine/conditions/numeric_condition.rb
|
101
102
|
- app/models/refine/conditions/option_condition.rb
|
102
103
|
- app/models/refine/conditions/text_condition.rb
|
103
104
|
- app/models/refine/conditions/uses_attributes.rb
|
105
|
+
- app/models/refine/conditions/with_forced_index.rb
|
104
106
|
- app/models/refine/filter.rb
|
105
107
|
- app/models/refine/filter/internationalized.rb
|
106
108
|
- app/models/refine/filters/blueprint_editor.rb
|