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 +4 -4
- data/CHANGELOG.md +8 -0
- data/Gemfile.lock +1 -1
- data/lib/eventsimple/entity.rb +13 -1
- data/lib/eventsimple/event.rb +13 -0
- data/lib/eventsimple/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: 90658d4182be4644e8885e2988333d4fdd6d7954bce1327087d3746c620a9d1e
|
|
4
|
+
data.tar.gz: ace638b47a463155a8adaa9a8713bd793e2be400466685ba777b74b928b02a4d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
data/lib/eventsimple/entity.rb
CHANGED
|
@@ -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
|
data/lib/eventsimple/event.rb
CHANGED
|
@@ -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?
|
data/lib/eventsimple/version.rb
CHANGED