From ac3394f0ec2b4cec3ce99759e6426db6c0e77d0a Mon Sep 17 00:00:00 2001 From: David Justo Date: Thu, 30 May 2024 09:30:15 -0700 Subject: [PATCH 1/4] add connection resolver for schemaName --- .../SqlDurabilityOptions.cs | 10 ++++++++++ src/common.props | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/DurableTask.SqlServer.AzureFunctions/SqlDurabilityOptions.cs b/src/DurableTask.SqlServer.AzureFunctions/SqlDurabilityOptions.cs index 3b7fc99..be54aa4 100644 --- a/src/DurableTask.SqlServer.AzureFunctions/SqlDurabilityOptions.cs +++ b/src/DurableTask.SqlServer.AzureFunctions/SqlDurabilityOptions.cs @@ -42,6 +42,16 @@ internal SqlOrchestrationServiceSettings GetOrchestrationServiceSettings( throw new ArgumentNullException(nameof(connectionStringResolver)); } + // If SchemaName is wrapped in `%`, then it is an environment variable to be resolved + if (this.SchemaName != null && this.SchemaName.StartsWith("%") && this.SchemaName.EndsWith("%")) + { + // remove surrounding `%` characters + this.SchemaName = this.SchemaName.Substring(1, this.SchemaName.Length - 2); + + // resolve the environment variable + this.SchemaName = connectionStringResolver.Resolve(this.SchemaName)?.Value; + } + IConfigurationSection connectionStringSection = connectionStringResolver.Resolve(this.ConnectionStringName); if (connectionStringSection == null || string.IsNullOrEmpty(connectionStringSection.Value)) { diff --git a/src/common.props b/src/common.props index ace5c3e..01f2aaf 100644 --- a/src/common.props +++ b/src/common.props @@ -17,7 +17,7 @@ 1 3 - 0 + 1 $(MajorVersion).$(MinorVersion).$(PatchVersion) $(MajorVersion).$(MinorVersion).0.0 From 3be8ac30cb66a81d7874b05280b225bb380b6db5 Mon Sep 17 00:00:00 2001 From: David Justo Date: Thu, 30 May 2024 09:40:32 -0700 Subject: [PATCH 2/4] commenting out for testing --- .../SqlDurabilityOptions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DurableTask.SqlServer.AzureFunctions/SqlDurabilityOptions.cs b/src/DurableTask.SqlServer.AzureFunctions/SqlDurabilityOptions.cs index be54aa4..3dd4730 100644 --- a/src/DurableTask.SqlServer.AzureFunctions/SqlDurabilityOptions.cs +++ b/src/DurableTask.SqlServer.AzureFunctions/SqlDurabilityOptions.cs @@ -49,7 +49,7 @@ internal SqlOrchestrationServiceSettings GetOrchestrationServiceSettings( this.SchemaName = this.SchemaName.Substring(1, this.SchemaName.Length - 2); // resolve the environment variable - this.SchemaName = connectionStringResolver.Resolve(this.SchemaName)?.Value; + // this.SchemaName = connectionStringResolver.Resolve(this.SchemaName)?.Value; } IConfigurationSection connectionStringSection = connectionStringResolver.Resolve(this.ConnectionStringName); From 26c8015386310f0f3135fe3dbae0175806de4832 Mon Sep 17 00:00:00 2001 From: David Justo Date: Thu, 30 May 2024 09:40:46 -0700 Subject: [PATCH 3/4] further commenting things out, for testing --- .../SqlDurabilityOptions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DurableTask.SqlServer.AzureFunctions/SqlDurabilityOptions.cs b/src/DurableTask.SqlServer.AzureFunctions/SqlDurabilityOptions.cs index 3dd4730..a6bd137 100644 --- a/src/DurableTask.SqlServer.AzureFunctions/SqlDurabilityOptions.cs +++ b/src/DurableTask.SqlServer.AzureFunctions/SqlDurabilityOptions.cs @@ -46,7 +46,7 @@ internal SqlOrchestrationServiceSettings GetOrchestrationServiceSettings( if (this.SchemaName != null && this.SchemaName.StartsWith("%") && this.SchemaName.EndsWith("%")) { // remove surrounding `%` characters - this.SchemaName = this.SchemaName.Substring(1, this.SchemaName.Length - 2); + // this.SchemaName = this.SchemaName.Substring(1, this.SchemaName.Length - 2); // resolve the environment variable // this.SchemaName = connectionStringResolver.Resolve(this.SchemaName)?.Value; From a7a2ef5053a2b800ce8fcc31de58b6f2a7af334d Mon Sep 17 00:00:00 2001 From: David Justo Date: Thu, 30 May 2024 09:51:04 -0700 Subject: [PATCH 4/4] modify tests to expect the right schema --- .../SqlDurabilityOptions.cs | 4 ++-- .../Integration/DatabaseManagement.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/DurableTask.SqlServer.AzureFunctions/SqlDurabilityOptions.cs b/src/DurableTask.SqlServer.AzureFunctions/SqlDurabilityOptions.cs index a6bd137..be54aa4 100644 --- a/src/DurableTask.SqlServer.AzureFunctions/SqlDurabilityOptions.cs +++ b/src/DurableTask.SqlServer.AzureFunctions/SqlDurabilityOptions.cs @@ -46,10 +46,10 @@ internal SqlOrchestrationServiceSettings GetOrchestrationServiceSettings( if (this.SchemaName != null && this.SchemaName.StartsWith("%") && this.SchemaName.EndsWith("%")) { // remove surrounding `%` characters - // this.SchemaName = this.SchemaName.Substring(1, this.SchemaName.Length - 2); + this.SchemaName = this.SchemaName.Substring(1, this.SchemaName.Length - 2); // resolve the environment variable - // this.SchemaName = connectionStringResolver.Resolve(this.SchemaName)?.Value; + this.SchemaName = connectionStringResolver.Resolve(this.SchemaName)?.Value; } IConfigurationSection connectionStringSection = connectionStringResolver.Resolve(this.ConnectionStringName); diff --git a/test/DurableTask.SqlServer.Tests/Integration/DatabaseManagement.cs b/test/DurableTask.SqlServer.Tests/Integration/DatabaseManagement.cs index 3f4f024..f71d497 100644 --- a/test/DurableTask.SqlServer.Tests/Integration/DatabaseManagement.cs +++ b/test/DurableTask.SqlServer.Tests/Integration/DatabaseManagement.cs @@ -504,7 +504,7 @@ async Task ValidateDatabaseSchemaAsync(TestDatabase database, string schemaName schemaName); Assert.Equal(1, currentSchemaVersion.Major); Assert.Equal(3, currentSchemaVersion.Minor); - Assert.Equal(0, currentSchemaVersion.Patch); + Assert.Equal(1, currentSchemaVersion.Patch); } sealed class TestDatabase : IDisposable