From cb49f977d2ca33ccb72ac3f592f8528eb6f644e9 Mon Sep 17 00:00:00 2001 From: "Jeremy D. Miller" Date: Mon, 2 Sep 2024 06:19:26 -0500 Subject: [PATCH] Adjusting the Postgresql lightweight sagas to use JSONB across the board --- .../Wolverine.Postgresql/Sagas/SagaStorage.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Persistence/Wolverine.Postgresql/Sagas/SagaStorage.cs b/src/Persistence/Wolverine.Postgresql/Sagas/SagaStorage.cs index a54fdbfd5..ec20d115d 100644 --- a/src/Persistence/Wolverine.Postgresql/Sagas/SagaStorage.cs +++ b/src/Persistence/Wolverine.Postgresql/Sagas/SagaStorage.cs @@ -2,6 +2,7 @@ using System.Text.Json; using JasperFx.Core.Reflection; using Npgsql; +using NpgsqlTypes; using Weasel.Core; using Weasel.Postgresql; using Weasel.Postgresql.Tables; @@ -81,9 +82,9 @@ public async Task InsertAsync(T saga, DbTransaction transaction, CancellationTok if (id == null || id.Equals(default(TId))) throw new ArgumentOutOfRangeException(nameof(saga), "You must define the saga id when using the lightweight saga storage"); await ensureStorageExistsAsync(cancellationToken); - await transaction.CreateCommand(_insertSql) + await transaction.CreateCommand(_insertSql).As() .With("id", id) - .With("body", JsonSerializer.SerializeToUtf8Bytes(saga)) + .With("body", JsonSerializer.SerializeToUtf8Bytes(saga), NpgsqlDbType.Jsonb) .ExecuteNonQueryAsync(cancellationToken); saga.Version = 1; @@ -94,9 +95,9 @@ public async Task UpdateAsync(T saga, DbTransaction transaction, CancellationTok await ensureStorageExistsAsync(cancellationToken); var id = IdSource(saga); - var count = await transaction.CreateCommand(_updateSql) + var count = await transaction.CreateCommand(_updateSql).As() .With("id", id) - .With("body", JsonSerializer.SerializeToUtf8Bytes(saga)) + .With("body", JsonSerializer.SerializeToUtf8Bytes(saga), NpgsqlDbType.Jsonb) .With("version", saga.Version) .ExecuteNonQueryAsync(cancellationToken);