jpie 4.1.0 → 4.1.1.pre.202609280317
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/CHANGELOG.md +13 -0
- data/lib/json_api/serialization/include_filter_cache.rb +18 -1
- data/lib/json_api/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 89f25c649293b22832412f92bcf29361b881deaf953d6b2db661736e226abd8d
|
|
4
|
+
data.tar.gz: 4256bc8778bf8968c852fb901f753fe433b3ed21776a02ea2445f86f179a05c2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5384c6655800b556886f7ba54510c982fb2432fdcdde2439c1ce90f5d77bd10de6094973e0f6bed8c01f22a32c064de5c255b133c87c2395cbc4c12f9948e9b4
|
|
7
|
+
data.tar.gz: 9b72004eb39131a37d9e289e9c0103f88f17ebffd48df26a5ff0ee93337af855e7932c1965468a2d8ca0a4300180dba6e37897964cc124e26d2076cfe2aff536
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,19 @@ at release time.
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- **Vet a partial where hash in the database, not in memory.**
|
|
13
|
+
`IncludeFilterCache#filter` matched sideloaded records against
|
|
14
|
+
`where_values_hash`. That hash holds only the conditions ActiveRecord
|
|
15
|
+
expresses as a hash, and drops `where.not`, raw SQL, joins and ranges. A
|
|
16
|
+
resource whose `records` scope mixed both kinds lost the half the hash could
|
|
17
|
+
not carry, so an `?include=` surfaced records the related endpoint hides. The
|
|
18
|
+
hash now stands in for the scope only when it reproduces the whole where
|
|
19
|
+
clause; otherwise `filter` and `warm` vet ids in the database against the
|
|
20
|
+
full scope. Regression spec:
|
|
21
|
+
`include_filter_partial_where_hash_bypass_spec.rb`.
|
|
22
|
+
|
|
10
23
|
## [4.1.0] - 2026-09-15
|
|
11
24
|
|
|
12
25
|
### Fixed
|
|
@@ -76,12 +76,29 @@ module JSONAPI
|
|
|
76
76
|
handler.call(controller: @authorization_context, scope:, action: :index, model_class: klass)
|
|
77
77
|
end
|
|
78
78
|
|
|
79
|
+
# The hash stands in for the scope only when it reproduces the whole where
|
|
80
|
+
# clause. `where_values_hash` keeps the conditions ActiveRecord expresses
|
|
81
|
+
# as a hash and drops the rest: `where.not`, raw SQL, joins and ranges. A
|
|
82
|
+
# scope that mixes both kinds would otherwise lose the half the hash
|
|
83
|
+
# cannot carry, and an include would surface records the related endpoint
|
|
84
|
+
# hides. Return {} for a partial hash, so #filter and #warm vet ids in the
|
|
85
|
+
# database against the full scope.
|
|
79
86
|
def where_hash_for(scope, klass)
|
|
80
|
-
scope.where_values_hash(klass.table_name)
|
|
87
|
+
hash = scope.where_values_hash(klass.table_name)
|
|
88
|
+
return {} if hash.blank?
|
|
89
|
+
|
|
90
|
+
whole_clause?(scope, hash) ? hash : {}
|
|
81
91
|
rescue StandardError
|
|
82
92
|
{}
|
|
83
93
|
end
|
|
84
94
|
|
|
95
|
+
# Rebuilds the clause from the hash on the same relation and compares the
|
|
96
|
+
# SQL. Rebuilding on `klass.unscoped` instead would repeat the condition
|
|
97
|
+
# an STI subclass already carries, and read every STI resource as partial.
|
|
98
|
+
def whole_clause?(scope, hash)
|
|
99
|
+
scope.unscope(:where).where(hash).only(:where).to_sql == scope.only(:where).to_sql
|
|
100
|
+
end
|
|
101
|
+
|
|
85
102
|
def matches_where_hash?(record, hash)
|
|
86
103
|
hash.all? do |attr, val|
|
|
87
104
|
r_val = record.read_attribute(attr)
|
data/lib/json_api/version.rb
CHANGED