jpie 3.1.6 → 3.5.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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c54015e01586dd3a4a6f14430928d231e1e6ce8f1e46a9cefa54ab7c93d45226
|
|
4
|
+
data.tar.gz: 90f24a271244366daf7ff47dd7a20a79740baf72c037b4f9ff428bd7a69bde33
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bd1e8f0ce88654ca8c594f9b58cb4320ecfeba576d5f21062e0136737c0bbabd24a3aef94f899ad0732a7f363f9115e1e602c9079b930aa7159187b90e834a61
|
|
7
|
+
data.tar.gz: ba4d97f2a60f0b73ca1480de68cdfb05c992e2434bff55ee6569da74447788c7f1c51e7ac2047126976adca6ba1a88a9b8c4fd6e9e60a7b1cddd7aa26ac379e7
|
data/Gemfile.lock
CHANGED
|
@@ -22,7 +22,11 @@ module JSONAPI
|
|
|
22
22
|
return scope if scope.is_a?(Array)
|
|
23
23
|
|
|
24
24
|
inc_hash = includes_to_hash(includes)
|
|
25
|
-
|
|
25
|
+
# `includes` may resolve to a JOIN when the base scope already references an
|
|
26
|
+
# associated table (e.g. a `records` override that sorts by one). Rails cannot
|
|
27
|
+
# eager-load polymorphic or instance-dependent associations in a JOIN, so those
|
|
28
|
+
# must go through `preload` (a separate query), which loads them without raising.
|
|
29
|
+
preload_required?(inc_hash, model_class) ? scope.preload(inc_hash) : scope.includes(inc_hash)
|
|
26
30
|
end
|
|
27
31
|
|
|
28
32
|
def filter_includable(hash, klass)
|
|
@@ -34,6 +38,24 @@ module JSONAPI
|
|
|
34
38
|
end
|
|
35
39
|
end
|
|
36
40
|
|
|
41
|
+
def preload_required?(hash, klass)
|
|
42
|
+
hash.any? do |key, value|
|
|
43
|
+
assoc = klass.reflect_on_association(key)
|
|
44
|
+
next false unless assoc
|
|
45
|
+
|
|
46
|
+
assoc.polymorphic? || instance_dependent_scope?(assoc) ||
|
|
47
|
+
(value.present? && preload_required?(value, assoc.klass))
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# Rails refuses to eager-load (JOIN) an association whose scope takes the owner
|
|
52
|
+
# instance (`->(owner) { ... }`), raising "instance dependent scopes are not
|
|
53
|
+
# supported". Its arity is non-zero; such associations must be preloaded instead.
|
|
54
|
+
def instance_dependent_scope?(assoc)
|
|
55
|
+
scope = assoc.scope
|
|
56
|
+
!scope.nil? && scope.arity != 0
|
|
57
|
+
end
|
|
58
|
+
|
|
37
59
|
def hash_contains_polymorphic?(hash, klass)
|
|
38
60
|
hash.any? { |key, value| polymorphic_in_hash_entry?(key, value, klass) }
|
|
39
61
|
end
|
|
@@ -35,7 +35,7 @@ module JSONAPI
|
|
|
35
35
|
parts = n1_details.split("Call stack:")
|
|
36
36
|
return nil if parts.size < 2
|
|
37
37
|
|
|
38
|
-
query_section = parts[0].sub(/\AN\+1 queries detected
|
|
38
|
+
query_section = parts[0].sub(/\AN\+1 queries detected(?: \([\d.]+ms\))?:\n?/, "")
|
|
39
39
|
first_line = query_section.each_line.map(&:strip).reject(&:empty?).first
|
|
40
40
|
first_line.presence
|
|
41
41
|
end
|
data/lib/json_api/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: jpie
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.
|
|
4
|
+
version: 3.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Emil Kampp
|
|
@@ -219,7 +219,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
219
219
|
- !ruby/object:Gem::Version
|
|
220
220
|
version: '0'
|
|
221
221
|
requirements: []
|
|
222
|
-
rubygems_version: 3.
|
|
222
|
+
rubygems_version: 3.6.9
|
|
223
223
|
specification_version: 4
|
|
224
224
|
summary: JSON:API compliant Rails gem for producing and consuming JSON:API resources
|
|
225
225
|
test_files: []
|