effective_resources 1.8.33 → 1.8.34
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: 3a3ce02ada5c7878e2c6fab4642ba84c4ba7dbb7fb5986c7f8bc135ea8e3258c
|
|
4
|
+
data.tar.gz: 375b538d786b4730626c5b7fb64a522ec04c789b750b25b2d4235f4617398e46
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 65954757632e43d089f173c0e09e421c8c6528d4aa7da4fe70c7b2f24ce0f4ee90646ec8908a778e356846643cfe9d8b924dc7af2fb800a1b4040b8876a05889
|
|
7
|
+
data.tar.gz: a1c6e51cba33a5489746a1d0954d547f4065fc75c69a87adaae35faca338c51ba91b36788c34729af74394b5d29ceeb9532b1d6acd7b8ffae06bf1ff29374f2b
|
|
@@ -55,6 +55,8 @@ module Effective
|
|
|
55
55
|
input
|
|
56
56
|
when ActiveRecord::Relation
|
|
57
57
|
input.klass
|
|
58
|
+
when (ActiveRecord::Reflection::BelongsToReflection rescue :nil)
|
|
59
|
+
_klass_by_name(input.class_name)
|
|
58
60
|
when (ActiveRecord::Reflection::AbstractReflection rescue :nil)
|
|
59
61
|
((input.klass rescue nil).presence || _klass_by_name(input.class_name)) unless input.options[:polymorphic]
|
|
60
62
|
when ActiveRecord::Reflection::MacroReflection
|
|
@@ -91,9 +91,11 @@ module Effective
|
|
|
91
91
|
|
|
92
92
|
if term == 'nil'
|
|
93
93
|
relation.where(is_null("#{sql_column}_id")).where(is_null("#{sql_column}_type"))
|
|
94
|
-
elsif type.present? && id.present?
|
|
94
|
+
elsif type.present? && id.present? # This was from a polymorphic select
|
|
95
95
|
relation.where("#{sql_column}_id = ?", id).where("#{sql_column}_type = ?", type)
|
|
96
|
-
|
|
96
|
+
elsif name == :user # Polymorphic user
|
|
97
|
+
relation.where(search_by_associated_conditions(association, term, fuzzy: fuzzy))
|
|
98
|
+
else # Maybe from a string field
|
|
97
99
|
id ||= Effective::Attribute.new(:integer).parse(term)
|
|
98
100
|
relation.where("#{sql_column}_id = ? OR #{sql_column}_type = ?", id, (type || term))
|
|
99
101
|
end
|
|
@@ -213,8 +215,10 @@ module Effective
|
|
|
213
215
|
|
|
214
216
|
# key: the id, or associated_id on my table
|
|
215
217
|
# keys: the ids themselves as per the target table
|
|
216
|
-
|
|
217
|
-
|
|
218
|
+
if association.macro == :belongs_to && association.options[:polymorphic]
|
|
219
|
+
key = sql_column(association.foreign_key)
|
|
220
|
+
keys = relation.pluck((relation.klass.primary_key rescue nil))
|
|
221
|
+
elsif association.macro == :belongs_to
|
|
218
222
|
key = sql_column(association.foreign_key)
|
|
219
223
|
keys = relation.pluck(association.klass.primary_key)
|
|
220
224
|
elsif association.macro == :has_and_belongs_to_many
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: effective_resources
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.8.
|
|
4
|
+
version: 1.8.34
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Code and Effect
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2021-10-
|
|
11
|
+
date: 2021-10-07 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|