Skip to content

Commit cb49f97

Browse files
committed
Adjusting the Postgresql lightweight sagas to use JSONB across the board
1 parent d1c99b4 commit cb49f97

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/Persistence/Wolverine.Postgresql/Sagas/SagaStorage.cs

+5-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Text.Json;
33
using JasperFx.Core.Reflection;
44
using Npgsql;
5+
using NpgsqlTypes;
56
using Weasel.Core;
67
using Weasel.Postgresql;
78
using Weasel.Postgresql.Tables;
@@ -81,9 +82,9 @@ public async Task InsertAsync(T saga, DbTransaction transaction, CancellationTok
8182
if (id == null || id.Equals(default(TId))) throw new ArgumentOutOfRangeException(nameof(saga), "You must define the saga id when using the lightweight saga storage");
8283

8384
await ensureStorageExistsAsync(cancellationToken);
84-
await transaction.CreateCommand(_insertSql)
85+
await transaction.CreateCommand(_insertSql).As<NpgsqlCommand>()
8586
.With("id", id)
86-
.With("body", JsonSerializer.SerializeToUtf8Bytes(saga))
87+
.With("body", JsonSerializer.SerializeToUtf8Bytes(saga), NpgsqlDbType.Jsonb)
8788
.ExecuteNonQueryAsync(cancellationToken);
8889

8990
saga.Version = 1;
@@ -94,9 +95,9 @@ public async Task UpdateAsync(T saga, DbTransaction transaction, CancellationTok
9495
await ensureStorageExistsAsync(cancellationToken);
9596

9697
var id = IdSource(saga);
97-
var count = await transaction.CreateCommand(_updateSql)
98+
var count = await transaction.CreateCommand(_updateSql).As<NpgsqlCommand>()
9899
.With("id", id)
99-
.With("body", JsonSerializer.SerializeToUtf8Bytes(saga))
100+
.With("body", JsonSerializer.SerializeToUtf8Bytes(saga), NpgsqlDbType.Jsonb)
100101
.With("version", saga.Version)
101102
.ExecuteNonQueryAsync(cancellationToken);
102103

0 commit comments

Comments
 (0)