Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

e-tobi
Copy link
Contributor

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

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
Copy link
Contributor

@rud rud left a comment

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
Copy link
Contributor

rud commented Jan 14, 2025

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

@e-tobi
Copy link
Contributor Author

e-tobi commented Jan 14, 2025

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.

Tobias Grimm added 7 commits January 14, 2025 21:51
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
Copy link
Contributor Author

e-tobi commented Jan 14, 2025

@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

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.

2 participants