diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1f401eea7..35df97ae9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -51,6 +51,7 @@ jobs: echo "Create extra databases" sqlcmd -Q "CREATE DATABASE nservicebus1" sqlcmd -Q "CREATE DATABASE nservicebus2" + sqlcmd -Q "CREATE DATABASE [n service.bus&#]" echo "Create additional schemas" sqlcmd -Q "CREATE SCHEMA receiver AUTHORIZATION db_owner" -d "nservicebus" diff --git a/src/NServiceBus.Transport.SqlServer.AcceptanceTests/MultiCatalog/When_catalog_with_special_characters_configured_for_endpoint.cs b/src/NServiceBus.Transport.SqlServer.AcceptanceTests/MultiCatalog/When_catalog_with_special_characters_configured_for_endpoint.cs new file mode 100644 index 000000000..d3f998500 --- /dev/null +++ b/src/NServiceBus.Transport.SqlServer.AcceptanceTests/MultiCatalog/When_catalog_with_special_characters_configured_for_endpoint.cs @@ -0,0 +1,46 @@ +namespace NServiceBus.Transport.SqlServer.AcceptanceTests.MultiCatalog; + +using System.Threading.Tasks; +using AcceptanceTesting; +using NUnit.Framework; + +public class When_catalog_with_special_characters_configured_for_endpoint : MultiCatalogAcceptanceTest +{ + static string EndpointConnectionString => WithCustomCatalog(GetDefaultConnectionString(), "n service.bus&#"); + + [Test] + public async Task Should_be_able_to_send_messages_to_the_endpoint() + { + await Scenario.Define() + .WithEndpoint(c => c.When(s => s.SendLocal(new Message()))) + .Done(c => c.MessageReceived) + .Run(); + + Assert.Pass(); + } + + public class AnEndpoint : EndpointConfigurationBuilder + { + public AnEndpoint() => + EndpointSetup(new CustomizedServer(EndpointConnectionString), (_, _) => { }); + + class Handler(Context scenarioContext) : IHandleMessages + { + public Task Handle(Message message, IMessageHandlerContext context) + { + scenarioContext.MessageReceived = true; + + return Task.FromResult(0); + } + } + } + + public class Message : ICommand + { + } + + class Context : ScenarioContext + { + public bool MessageReceived { get; set; } + } +} \ No newline at end of file diff --git a/src/NServiceBus.Transport.SqlServer/Queuing/SqlServerConstants.cs b/src/NServiceBus.Transport.SqlServer/Queuing/SqlServerConstants.cs index 370be340b..468dcf74a 100644 --- a/src/NServiceBus.Transport.SqlServer/Queuing/SqlServerConstants.cs +++ b/src/NServiceBus.Transport.SqlServer/Queuing/SqlServerConstants.cs @@ -52,7 +52,7 @@ THEN DATEADD(ms, @TimeToBeReceivedMs, GETUTCDATE()) END, public string CheckIfTableHasRecoverableText { get; set; } = @" SELECT COUNT(*) -FROM {0}.sys.columns c +FROM [{0}].sys.columns c WHERE c.object_id = OBJECT_ID(N'{1}') AND c.name = 'Recoverable'";