eventsimple 2.0.4 → 2.0.6

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: ae9bbebb1de86056d5f59ce55f4b689acf234bc0edb22250a929bc50beab5e51
4
- data.tar.gz: a65c7510e97468125924def2c029dfb675553e86380b243c08dcbc7666b082af
3
+ metadata.gz: 90658d4182be4644e8885e2988333d4fdd6d7954bce1327087d3746c620a9d1e
4
+ data.tar.gz: ace638b47a463155a8adaa9a8713bd793e2be400466685ba777b74b928b02a4d
5
5
  SHA512:
6
- metadata.gz: dfda660ee2398b239ace585e95047b2fec9dcd5d8056258513b76061707ec730a5d5fd6ba2d40ffb22406d6aa3d8688401579a4c2d309d61e1afc056b001439b
7
- data.tar.gz: d23dbffcbc0229dc04f3b57b1755dfb107c1d32e7bbe684592cc0d737dd7c80a7970cb5fc157a5a3d57dca8d08466251e965dd02a30be28d1f1dd3b2d5536dfe
6
+ metadata.gz: 2eb305aa101f86076f12634f2d46b75f67f7acdade90bcf7ac79feae8babfcaa795a7406ccd4999f08745b6db23de62efd56e6017c27544811bd5d1fc8a1dbb0
7
+ data.tar.gz: b2bf21fdfc3ab8df167276148b69c933d2df87d44bb803bdc6620b011062428ea61c1e20920531bc056c19efb55cf1323114df71c3010f4943bb4ae4b8a0ff4d
data/CHANGELOG.md CHANGED
@@ -6,6 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## Unreleased
8
8
 
9
+ ## 2.0.6 - 2026-01-29
10
+ ### Fixed
11
+ - Fix `projection_matches_events?` returning false due to timestamp precision differences between Ruby (nanoseconds) and PostgreSQL (microseconds). Time attributes are now normalized to microsecond precision before comparison.
12
+
13
+ ## 2.0.5 - 2026-01-14
14
+ ### Changed
15
+ - Events can now load their aggregate even when the aggregate model has a default_scope. The association reader bypasses default_scope using unscoped queries.
16
+
9
17
  ## 2.0.4 - 2025-12-16
10
18
  ### Added
11
19
  - Fixes an issue where entities with deleted events were not being rendered correctly.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- eventsimple (2.0.4)
4
+ eventsimple (2.0.6)
5
5
  concurrent-ruby (>= 1.2.3)
6
6
  dry-struct (>= 1.8.0)
7
7
  dry-types (>= 1.7.0)
@@ -53,9 +53,21 @@ module Eventsimple
53
53
  def projection_matches_events?
54
54
  reprojected = self.class.unscoped.find(id).reproject
55
55
 
56
- attributes == reprojected.attributes
56
+ normalize_times(attributes) == normalize_times(reprojected.attributes)
57
57
  end
58
58
 
59
+ private
60
+
61
+ # Normalize time values to microsecond precision to match PostgreSQL storage.
62
+ # This prevents false mismatches due to Ruby's nanosecond vs PostgreSQL's microsecond precision.
63
+ def normalize_times(attrs)
64
+ attrs.transform_values do |value|
65
+ value.is_a?(Time) ? value.change(nsec: value.usec * 1000) : value
66
+ end
67
+ end
68
+
69
+ public
70
+
59
71
  def enable_writes!(&block)
60
72
  was_readonly = @readonly
61
73
  @readonly = false
@@ -49,6 +49,19 @@ module Eventsimple
49
49
  autosave: false,
50
50
  validate: false
51
51
 
52
+ # Override the association reader to bypass any default_scope on the aggregate model.
53
+ # This ensures events can always find their aggregate, even if there is a default scope.
54
+ aggregate_name = _aggregate_klass.model_name.element.to_sym
55
+ define_method(aggregate_name) do
56
+ assoc = association(aggregate_name)
57
+ return assoc.target if assoc.loaded?
58
+ return nil if self.aggregate_id.nil?
59
+
60
+ record = _aggregate_klass.unscoped.find_by(_aggregate_id => self.aggregate_id)
61
+ assoc.target = record
62
+ record
63
+ end
64
+
52
65
  default_scope { order(:created_at) }
53
66
 
54
67
  after_initialize :readonly!, if: :persisted?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Eventsimple
4
- VERSION = '2.0.4'
4
+ VERSION = '2.0.6'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eventsimple
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.4
4
+ version: 2.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zulfiqar Ali