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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 296b80f6ec0f16823c99df6d3a041fe16d55eab4ce59118d95081566f13e01d4
4
- data.tar.gz: 8ec0e73b20698346c67f96075c0ccc3070f2f6232c1e1b3607a61424c1a19f8b
3
+ metadata.gz: b0d54a71884d6a3e6796d735d765c66811fdb607e2e87d9b79434d44f8f237f4
4
+ data.tar.gz: a655f7f62c60f2b436da2ab4b70e8e7096504879a468b32ee63f61dbefc34fa5
5
5
  SHA512:
6
- metadata.gz: 8b5d8087d0cffede8296535868978d6dd24cddc70d1f6a1ba0741db31d5fc46caaea9635791f8984166aa8de92bfb50db000ecc935df4fe6498ecc2456fc1029
7
- data.tar.gz: ef5ca8b2bb01a83a5673d0181d13627d5eb0b8bb01612f6e6ef146c5e4eb669cfd2ef0936c1aa09b15e6a5eed2367d7b1adb3c844c7e8aa4c72e7dc600201624
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
@@ -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
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveItem
4
- VERSION = '0.0.24'
4
+ VERSION = '0.0.25'
5
5
  end
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.24
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-10-30 00:00:00.000000000 Z
12
+ date: 2026-11-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activemodel