Skip to content

Fix some issues with PostgreSQL not running with an english locale#3616

Merged
jeremydmiller merged 7 commits into
JasperFx:masterfrom
e-tobi:master
Jan 24, 2025
Merged

Fix some issues with PostgreSQL not running with an english locale#3616
jeremydmiller merged 7 commits into
JasperFx:masterfrom
e-tobi:master

Conversation

@e-tobi

@e-tobi e-tobi commented Dec 31, 2024

Copy link
Copy Markdown
Contributor

Instead of relying on exception messages, use SqlState, because exception messages might be language dependent.

@e-tobi e-tobi changed the title Fix some issues with PostgreSQL notr running with an english locale Fix some issues with PostgreSQL not running with an english locale Jan 2, 2025

@rud rud left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's pretty elegant.

Would it be worth proving this with integration test or is that going too far?

@rud

rud commented Jan 14, 2025

Copy link
Copy Markdown
Contributor

@e-tobi the tests are failing, may just be a flaky test. Could you poke at it?

@e-tobi

e-tobi commented Jan 14, 2025

Copy link
Copy Markdown
Contributor Author

That's pretty elegant.

Would it be worth proving this with integration test or is that going too far?

Such an integration test would require the PostgreSQL server to be started with a different locale. Unfortunately the tests are currently designed to use a fixed external PostgreSQL server. It surely can be done (I'm actually doing this in the unit tests of my application that uses Marten) but I'm not sure, Jeremy would like this.

To check for exceptions caused by a uniqueness violation, use the SqlError instead of the exception messages, which might be translated to a different locale. Also use the PostgresErrorCodes constants from Npgsql.
Exception messages get translated!
Instead of checking the exception message, check if SqlState equals PostgresErrorCodes.InFailedSqlTransaction ("25P02")
Do not check the full exception messages, if they might be translated to a non-english locale.
Check constraint name instead of exception message and make regex for details extraction more language independent.
...when trying to truncate a non-existing table.
@e-tobi

e-tobi commented Jan 14, 2025

Copy link
Copy Markdown
Contributor Author

@e-tobi the tests are failing, may just be a flaky test. Could you poke at it?

I'm pretty sure the tests are not failing because of the changes in this PR.
I see failing tests also in the workflow run of the last release: https://github.com/JasperFx/marten/actions/runs/12773892842/job/35606812488#step:20:47

@jeremydmiller

Copy link
Copy Markdown
Member

The failing tests are unrelated (and most likely my fault for not catching it before)

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.

4 participants