From cff6b6bd68a91d59e75593bcbfa4fa85c359e458 Mon Sep 17 00:00:00 2001 From: vplauzon Date: Fri, 14 Apr 2023 17:04:57 -0400 Subject: [PATCH 1/3] Catch a change in function parameter length --- .../CommandModel/CreateFunctionCommand.cs | 1 + code/DeltaKustoUnitTest/Delta/DeltaFunctionTest.cs | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/code/DeltaKustoLib/CommandModel/CreateFunctionCommand.cs b/code/DeltaKustoLib/CommandModel/CreateFunctionCommand.cs index 9efb0f22..9ac08ecc 100644 --- a/code/DeltaKustoLib/CommandModel/CreateFunctionCommand.cs +++ b/code/DeltaKustoLib/CommandModel/CreateFunctionCommand.cs @@ -86,6 +86,7 @@ public override bool Equals(CommandBase? other) var areEqualed = otherFunction != null && otherFunction.FunctionName.Equals(FunctionName) // Check that all parameters are equal + && otherFunction.Parameters.Count() == Parameters.Count() && otherFunction.Parameters.Zip(Parameters, (p1, p2) => p1.Equals(p2)).All(p => p) && otherFunction.Body.Equals(Body) && object.Equals(otherFunction.Folder, Folder) diff --git a/code/DeltaKustoUnitTest/Delta/DeltaFunctionTest.cs b/code/DeltaKustoUnitTest/Delta/DeltaFunctionTest.cs index 080fc322..5fefd65b 100644 --- a/code/DeltaKustoUnitTest/Delta/DeltaFunctionTest.cs +++ b/code/DeltaKustoUnitTest/Delta/DeltaFunctionTest.cs @@ -62,6 +62,20 @@ public void UpdateOne() Assert.Equal("MyOtherFunction", ((CreateFunctionCommand)delta[0]).FunctionName.Name); } + [Fact] + public void UpdateParameter() + { + var currentCommands = Parse(".create function MyFunction(Id:int) { 42 }"); + var currentDatabase = DatabaseModel.FromCommands(currentCommands); + var targetCommands = Parse(".create function MyFunction(){ 42 }"); + var targetDatabase = DatabaseModel.FromCommands(targetCommands); + var delta = currentDatabase.ComputeDelta(targetDatabase); + + Assert.Single(delta); + Assert.IsType(delta[0]); + Assert.Equal("MyFunction", ((CreateFunctionCommand)delta[0]).FunctionName.Name); + } + [Fact] public void DetectDuplicates() { From 913ac45cc4ea1d7a4afa8841a72d6c938ac33245 Mon Sep 17 00:00:00 2001 From: vplauzon Date: Fri, 14 Apr 2023 17:11:40 -0400 Subject: [PATCH 2/3] Add fct test --- code/DeltaKustoUnitTest/Delta/DeltaFunctionTest.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/code/DeltaKustoUnitTest/Delta/DeltaFunctionTest.cs b/code/DeltaKustoUnitTest/Delta/DeltaFunctionTest.cs index 5fefd65b..bd15b611 100644 --- a/code/DeltaKustoUnitTest/Delta/DeltaFunctionTest.cs +++ b/code/DeltaKustoUnitTest/Delta/DeltaFunctionTest.cs @@ -76,6 +76,20 @@ public void UpdateParameter() Assert.Equal("MyFunction", ((CreateFunctionCommand)delta[0]).FunctionName.Name); } + [Fact] + public void UpdateParameterWithDefaultValue() + { + var currentCommands = Parse(".create function MyFunction(Id:int) { 42 }"); + var currentDatabase = DatabaseModel.FromCommands(currentCommands); + var targetCommands = Parse(".create function MyFunction(Id:int=5){ 42 }"); + var targetDatabase = DatabaseModel.FromCommands(targetCommands); + var delta = currentDatabase.ComputeDelta(targetDatabase); + + Assert.Single(delta); + Assert.IsType(delta[0]); + Assert.Equal("MyFunction", ((CreateFunctionCommand)delta[0]).FunctionName.Name); + } + [Fact] public void DetectDuplicates() { From 4eb0d6555844bafa0429ec3ae91608b2b40ed587 Mon Sep 17 00:00:00 2001 From: vplauzon Date: Fri, 14 Apr 2023 17:22:21 -0400 Subject: [PATCH 3/3] Bump version --- code/DeltaKustoUnitTest/Delta/DeltaFunctionTest.cs | 14 ++++++++++++++ code/delta-kusto/delta-kusto.csproj | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/code/DeltaKustoUnitTest/Delta/DeltaFunctionTest.cs b/code/DeltaKustoUnitTest/Delta/DeltaFunctionTest.cs index bd15b611..78f9e57e 100644 --- a/code/DeltaKustoUnitTest/Delta/DeltaFunctionTest.cs +++ b/code/DeltaKustoUnitTest/Delta/DeltaFunctionTest.cs @@ -90,6 +90,20 @@ public void UpdateParameterWithDefaultValue() Assert.Equal("MyFunction", ((CreateFunctionCommand)delta[0]).FunctionName.Name); } + [Fact] + public void NoUpdateParameterWithDefaultValue() + { + var currentCommands = Parse( + ".create function MyFunction(StartTime:datetime=datetime(null)) { 42 }"); + var currentDatabase = DatabaseModel.FromCommands(currentCommands); + var targetCommands = Parse( + ".create function MyFunction(StartTime:datetime=datetime(null)){ 42 }"); + var targetDatabase = DatabaseModel.FromCommands(targetCommands); + var delta = currentDatabase.ComputeDelta(targetDatabase); + + Assert.Empty(delta); + } + [Fact] public void DetectDuplicates() { diff --git a/code/delta-kusto/delta-kusto.csproj b/code/delta-kusto/delta-kusto.csproj index ea94466e..a2f7a699 100644 --- a/code/delta-kusto/delta-kusto.csproj +++ b/code/delta-kusto/delta-kusto.csproj @@ -5,7 +5,7 @@ net7.0 delta_kusto enable - 0.12.0 + 0.12.1 partial