From 6aa63b2e6988f918f34164b1f68df8e5bd02319f Mon Sep 17 00:00:00 2001 From: Kimserey Lam Date: Wed, 25 Mar 2020 10:32:41 +0000 Subject: [PATCH 1/2] SQLStreamStore.MsSql: Fix for Initial Append operation failing (#209) --- CHANGELOG.md | 2 ++ src/Equinox.SqlStreamStore/SqlStreamStore.fs | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 255be318d..e12adbba8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,8 @@ The `Unreleased` section name is replaced by the expected version of next releas ### Removed ### Fixed +- `SqlStreamStore.MsSql`: Initial Append when stream empty on MsSql was perpetually failing :pray: [#209](https://github.com/jet/equinox/pull/209) [@Kimserey](https://github.com/kimserey) + ## [2.0.0] - 2020-02-19 diff --git a/src/Equinox.SqlStreamStore/SqlStreamStore.fs b/src/Equinox.SqlStreamStore/SqlStreamStore.fs index d1cc56d69..16b67fa00 100644 --- a/src/Equinox.SqlStreamStore/SqlStreamStore.fs +++ b/src/Equinox.SqlStreamStore/SqlStreamStore.fs @@ -134,7 +134,7 @@ module private Write = let private writeEventsAsync (log : ILogger) (conn : IEventStoreConnection) (streamName : string) (version : int64) (events : EventData[]) : Async = async { try - let! wr = conn.AppendToStream(StreamId streamName, int version, events) |> Async.AwaitTaskCorrect + let! wr = conn.AppendToStream(StreamId streamName, (if version = -1L then ExpectedVersion.NoStream else int version), events) |> Async.AwaitTaskCorrect return EsSyncResult.Written wr with :? WrongExpectedVersionException as ex -> log.Information(ex, "SqlEs TrySync WrongExpectedVersionException writing {EventTypes}, expected {ExpectedVersion}", @@ -285,9 +285,12 @@ module UnionEncoderAdapters = FsCodec.Core.TimelineEvent.Create(int64 e.StreamVersion, e.Type, data, meta, e.MessageId, null, null, let ts = e.CreatedUtc in DateTimeOffset ts) let eventDataOfEncodedEvent (x : FsCodec.IEventData) = let str = function null -> null | s -> System.Text.Encoding.UTF8.GetString s + // SQLStreamStore rejects IsNullOrEmpty data value. + // TODO: Follow up on inconsistency with ES + let str2 = function null -> "{}" | s -> System.Text.Encoding.UTF8.GetString s // TOCONSIDER wire x.CorrelationId, x.CausationId into x.Meta.["$correlationId"] and .["$causationId"] // https://eventstore.org/docs/server/metadata-and-reserved-names/index.html#event-metadata - NewStreamMessage(x.EventId, x.EventType, str x.Data, str x.Meta) + NewStreamMessage(x.EventId, x.EventType, str2 x.Data, str x.Meta) type Stream = { name: string } type Position = { streamVersion: int64; compactionEventNumber: int64 option; batchCapacityLimit: int option } From f5cb4519513b26057f1d9c65ec1fd8ab9a08ad31 Mon Sep 17 00:00:00 2001 From: Ruben Bartelink Date: Wed, 25 Mar 2020 13:37:14 +0000 Subject: [PATCH 2/2] Release 2.0.1 --- CHANGELOG.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e12adbba8..94c312596 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,8 +13,12 @@ The `Unreleased` section name is replaced by the expected version of next releas ### Removed ### Fixed + +## [2.0.1] - 2020-03-25 + - `SqlStreamStore.MsSql`: Initial Append when stream empty on MsSql was perpetually failing :pray: [#209](https://github.com/jet/equinox/pull/209) [@Kimserey](https://github.com/kimserey) +### Fixed ## [2.0.0] - 2020-02-19 @@ -369,7 +373,8 @@ The `Unreleased` section name is replaced by the expected version of next releas (For information pertaining to earlier releases, see release notes in https://github.com/jet/equinox/releases and/or can someone please add it!) -[Unreleased]: https://github.com/jet/equinox/compare/2.0.0...HEAD +[Unreleased]: https://github.com/jet/equinox/compare/2.0.1...HEAD +[2.0.1]: https://github.com/jet/equinox/compare/2.0.0...2.0.1 [2.0.0]: https://github.com/jet/equinox/compare/2.0.0-rc9...2.0.0 [2.0.0-rc9]: https://github.com/jet/equinox/compare/2.0.0-rc8...2.0.0-rc9 [2.0.0-rc8]: https://github.com/jet/equinox/compare/2.0.0-rc7...2.0.0-rc8