From 7567fdad98e819908cf8d5818a4e6dff6b25b8d7 Mon Sep 17 00:00:00 2001 From: stidsborg Date: Sat, 30 Nov 2024 07:52:33 +0100 Subject: [PATCH] Fixed SqlServerFunctionStore missing parent in BulkSchedule bug --- .../TestTemplates/StoreTests.cs | 5 +++-- .../SqlServerFunctionStore.cs | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Core/Cleipnir.ResilientFunctions.Tests/TestTemplates/StoreTests.cs b/Core/Cleipnir.ResilientFunctions.Tests/TestTemplates/StoreTests.cs index 4cea029f..bc7c084f 100644 --- a/Core/Cleipnir.ResilientFunctions.Tests/TestTemplates/StoreTests.cs +++ b/Core/Cleipnir.ResilientFunctions.Tests/TestTemplates/StoreTests.cs @@ -1158,7 +1158,7 @@ await store.SucceedFunction( protected async Task BulkScheduleInsertsAllFunctionsSuccessfully(Task storeTask) { var store = await storeTask; - + var parent = TestStoredId.Create(); var typeId = TestStoredId.Create().Type; var functionIds = Enumerable .Range(0, 500) @@ -1167,7 +1167,7 @@ protected async Task BulkScheduleInsertsAllFunctionsSuccessfully(Task new IdWithParam(functionId, "humanInstanceId", Param: functionId.ToString().ToUtf8Bytes())), - parent: null + parent ); var eligibleFunctions = @@ -1184,6 +1184,7 @@ await store.BulkScheduleFunctions( var sf = await store.GetFunction(id); sf.ShouldNotBeNull(); sf.Parameter!.ToStringFromUtf8Bytes().ShouldBe(id.ToString()); + sf.ParentId.ShouldBe(parent); } } diff --git a/Stores/SqlServer/Cleipnir.ResilientFunctions.SqlServer/SqlServerFunctionStore.cs b/Stores/SqlServer/Cleipnir.ResilientFunctions.SqlServer/SqlServerFunctionStore.cs index 20449c08..d6a2a8e6 100644 --- a/Stores/SqlServer/Cleipnir.ResilientFunctions.SqlServer/SqlServerFunctionStore.cs +++ b/Stores/SqlServer/Cleipnir.ResilientFunctions.SqlServer/SqlServerFunctionStore.cs @@ -206,8 +206,8 @@ AS source ( ) ON {_tableName}.FlowType = source.FlowType AND {_tableName}.flowInstance = source.flowInstance WHEN NOT MATCHED THEN - INSERT (FlowType, FlowInstance, ParamJson, Status, Epoch, Expires, Timestamp, HumanInstanceId) - VALUES (source.FlowType, source.flowInstance, source.ParamJson, source.Status, source.Epoch, source.Expires, source.Timestamp, source.HumanInstanceId);"; + INSERT (FlowType, FlowInstance, ParamJson, Status, Epoch, Expires, Timestamp, HumanInstanceId, Parent) + VALUES (source.FlowType, source.flowInstance, source.ParamJson, source.Status, source.Epoch, source.Expires, source.Timestamp, source.HumanInstanceId, source.Parent);"; var parentStr = parent == null ? "NULL" : $"'{parent}'"; var valueSql = $"(@FlowType, @FlowInstance, @ParamJson, {(int)Status.Postponed}, 0, 0, 0, @HumanInstanceId, {parentStr})";