activeitem 0.0.24 → 0.0.25
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 +6 -0
- data/lib/active_item/relation.rb +8 -0
- data/lib/active_item/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b0d54a71884d6a3e6796d735d765c66811fdb607e2e87d9b79434d44f8f237f4
|
|
4
|
+
data.tar.gz: a655f7f62c60f2b436da2ab4b70e8e7096504879a468b32ee63f61dbefc34fa5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 380e6f8230e48a0945e0de9634bf2ebbbac50174e219837e256785fbcce538315f5ad99fb9e5325e6eb279f3b1c75a8039c9a4a01b83f4e10d715bc9bdb83ae6
|
|
7
|
+
data.tar.gz: 5999d960661a94ed2e3ae632323964cb5801050fe17b9cf96f83816107a54c7b7728e7dd2fa09139b4549c8b16d1be13ba559c1ee2e1ea9b921e59829cd36038
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.0.25
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- **`Relation#first` could return an unrelated record on a preloaded relation.** `where(id: [...])` takes the `batch_find` optimization and returns a Relation that is already loaded with the requested records but whose `conditions` hash is empty. `#first` routed through `limit(1)` → `spawn`, producing a fresh, condition-less relation that scanned the table and returned an arbitrary record — often one belonging to a different owner. `#each`, `#length`, `#to_a`, and `#last` were unaffected, so code that iterated to authorize and then read `relation.first.some_id` would silently pick up a stranger's value. `#first` now reads directly from the loaded records when the relation is already loaded.
|
|
8
|
+
|
|
3
9
|
## 0.0.24
|
|
4
10
|
|
|
5
11
|
### Added
|
data/lib/active_item/relation.rb
CHANGED
|
@@ -192,7 +192,15 @@ module ActiveItem
|
|
|
192
192
|
end
|
|
193
193
|
|
|
194
194
|
# Get first record
|
|
195
|
+
#
|
|
196
|
+
# When the relation is already loaded (e.g. built from batch_find via
|
|
197
|
+
# where(id: [...]), which stores preloaded_records and leaves conditions
|
|
198
|
+
# empty), read directly from the loaded records. Routing through
|
|
199
|
+
# limit(1).to_a would spawn a fresh, condition-less relation that ignores
|
|
200
|
+
# the preload and scans the table, returning an arbitrary unrelated record.
|
|
195
201
|
def first
|
|
202
|
+
return @records.first if @loaded
|
|
203
|
+
|
|
196
204
|
limit(1).to_a.first
|
|
197
205
|
end
|
|
198
206
|
|
data/lib/active_item/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: activeitem
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.25
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Andy Davis
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2026-
|
|
12
|
+
date: 2026-11-02 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: activemodel
|