effective_resources 1.8.33 → 1.8.34

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: 60cb47028d5031c44e6a833fd1750d6e9435ace75de88ffec3756378079ba13c
4
- data.tar.gz: 9ceb601f1fdf5ab0784abe83b6f7d8071f66e079d7c5a3c7352dee0dda9b1abb
3
+ metadata.gz: 3a3ce02ada5c7878e2c6fab4642ba84c4ba7dbb7fb5986c7f8bc135ea8e3258c
4
+ data.tar.gz: 375b538d786b4730626c5b7fb64a522ec04c789b750b25b2d4235f4617398e46
5
5
  SHA512:
6
- metadata.gz: 9fe4309ff79c01a66217aee696f3bfa45d11d429d7a3dad84977351be8e0f9efd1091b6bc8398fcc46d131cc69a57d2251a2b365ddbd7fd4f0a4576c51ba6a5f
7
- data.tar.gz: a88750936ed0d46ee4a8faa8a591fbd04dd9eef2eeedaa7f36c01a80bbeaff72690eed324974cdbaf12ed68b2f156ea91058c5250d5b415e80040f4edf0d9060
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
- else
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
- if association.macro == :belongs_to
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
@@ -1,3 +1,3 @@
1
1
  module EffectiveResources
2
- VERSION = '1.8.33'.freeze
2
+ VERSION = '1.8.34'.freeze
3
3
  end
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.33
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-01 00:00:00.000000000 Z
11
+ date: 2021-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails