From 7ffbbc874470adfc513c24f996fde0f882b70ddf Mon Sep 17 00:00:00 2001 From: stidsborg Date: Sun, 20 Oct 2024 11:36:05 +0200 Subject: [PATCH] Fixed bug in MySqlFunctionStore's bulk-insertion method --- .../TestTemplates/StoreTests.cs | 9 ++++++++- .../MySqlFunctionStore.cs | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Core/Cleipnir.ResilientFunctions.Tests/TestTemplates/StoreTests.cs b/Core/Cleipnir.ResilientFunctions.Tests/TestTemplates/StoreTests.cs index 16ea772b..89645199 100644 --- a/Core/Cleipnir.ResilientFunctions.Tests/TestTemplates/StoreTests.cs +++ b/Core/Cleipnir.ResilientFunctions.Tests/TestTemplates/StoreTests.cs @@ -1094,7 +1094,7 @@ protected async Task BulkScheduleInsertsAllFunctionsSuccessfully(Task new IdWithParam(functionId, Param: "".ToUtf8Bytes())) + functionIds.Select(functionId => new IdWithParam(functionId, Param: functionId.ToString().ToUtf8Bytes())) ); var eligibleFunctions = @@ -1105,6 +1105,13 @@ await store.BulkScheduleFunctions( { eligibleFunctions.Any(f => f.FlowId == flowId).ShouldBeTrue(); } + + foreach (var id in functionIds) + { + var sf = await store.GetFunction(id); + sf.ShouldNotBeNull(); + sf.Parameter!.ToStringFromUtf8Bytes().ShouldBe(id.ToString()); + } } public abstract Task DifferentTypesAreFetchedByGetExpiredFunctionsCall(); diff --git a/Stores/MySQL/Cleipnir.ResilientFunctions.MySQL/MySqlFunctionStore.cs b/Stores/MySQL/Cleipnir.ResilientFunctions.MySQL/MySqlFunctionStore.cs index 2fff20f2..b6378a7c 100644 --- a/Stores/MySQL/Cleipnir.ResilientFunctions.MySQL/MySqlFunctionStore.cs +++ b/Stores/MySQL/Cleipnir.ResilientFunctions.MySQL/MySqlFunctionStore.cs @@ -142,7 +142,7 @@ INSERT IGNORE INTO {_tablePrefix} var rows = new List(); foreach (var ((type, instance), param) in functionsWithParam) { - var row = $"('{type.Value.EscapeString()}', '{instance.Value.EscapeString()}', {(param == null ? "NULL" : $"'0x{Convert.ToHexString(param)}'")}, {(int) Status.Postponed}, 0, 0, {now})"; + var row = $"('{type.Value.EscapeString()}', '{instance.Value.EscapeString()}', {(param == null ? "NULL" : $"x'{Convert.ToHexString(param)}'")}, {(int) Status.Postponed}, 0, 0, {now})"; rows.Add(row); } var rowsSql = string.Join(", " + Environment.NewLine, rows);