Skip to content

Fix OPENJSON compatibility for SQL Server 2008 and low compatibility …#120

Open
martincardosotoledo wants to merge 1 commit intorebus-org:masterfrom
martincardosotoledo:fix/sql-server-2008-openjson-compat
Open

Fix OPENJSON compatibility for SQL Server 2008 and low compatibility …#120
martincardosotoledo wants to merge 1 commit intorebus-org:masterfrom
martincardosotoledo:fix/sql-server-2008-openjson-compat

Conversation

@martincardosotoledo
Copy link
Copy Markdown

Problem

CompleteMessages used OPENJSON to update outbox messages as sent, which requires SQL Server 2016 or higher and a database compatibility level of 130 or above. This caused failures on SQL Server 2008 and on newer SQL Server versions with a lower compatibility level configured.

Additionally, GetOutboxMessages had a missing AND keyword in the WHERE clause when filtering by correlationId, causing a SQL syntax error when correlation ID filtering was used.

Changes

  • Added DetectOpenJsonSupportAsync in Initialize() that checks compatibility_level from sys.databases to determine if OPENJSON is available
  • CompleteMessages now falls back to an equivalent XML-based approach when OPENJSON is not supported
  • Fixed missing AND in GetOutboxMessages when filtering by correlationId

Notes

The XML fallback produces identical results to the OPENJSON approach. The compatibility check uses sys.databases as recommended by Microsoft's own documentation for OPENJSON.

Closes #119

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@martincardosotoledo
Copy link
Copy Markdown
Author

The CI failure appears to be unrelated to this PR — it's failing on dotnet restore due to the AppVeyor environment not having the .NET 10 SDK installed. The same failure would occur on any PR against current master.

@mlcardosotoledo
Copy link
Copy Markdown

Hi! Just a heads-up regarding my PR — the CLA Assistant bot is showing "Contributor License Agreement is not signed yet", but I have already signed the CLA. It seems like the bot isn't picking up my signature automatically.

I wanted to let you know so you're not blocked waiting on that status to clear. If there's anything on your end that can help trigger a re-check, or if you need me to take any additional steps, just let me know!

Thanks for your time and for maintaining this project 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OPENJSON incompatibility with SQL Server 2008 in SqlServerOutboxStorage

3 participants