-
-
Notifications
You must be signed in to change notification settings - Fork 466
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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?
@e-tobi the tests are failing, may just be a flaky test. Could you poke at it? |
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.
I'm pretty sure the tests are not failing because of the changes in this PR. |
Instead of relying on exception messages, use SqlState, because exception messages might be language dependent.