Skip to content

Conversation

GromNaN
Copy link
Member

@GromNaN GromNaN commented Sep 1, 2025

Q A
Type bug
Fixed issues fix symfony/symfony#61579

Summary

The error code 15151 is generic, but we can detect the type of object from the message; and throw a TableNotFoundException when the error is for a missing table.

@GromNaN GromNaN force-pushed the mssql-table-not-found branch from b84ddb3 to 4d24a68 Compare September 1, 2025 22:32
@morozov
Copy link
Member

morozov commented Sep 3, 2025

@GromNaN thanks for the patch. It would be good to add an integration test that covers the issue and ensures that the behavior is consistent across all supported platforms.

@GromNaN
Copy link
Member Author

GromNaN commented Sep 3, 2025

@morozov I agree, I'll try.

@derrabus
Copy link
Member

derrabus commented Sep 3, 2025

Parsing error messages is really fragile. And IIRC, SQL Server might even emit localized error messages when running on a non-English Windows system. In the context of the issue you're attempting to solve, I wonder if it wouldn't be the more robust solution to catch the DatabaseObjectNotFoundException instead.

@GromNaN
Copy link
Member Author

GromNaN commented Sep 3, 2025

In the context of the issue you're attempting to solve, I wonder if it wouldn't be the more robust solution to catch the DatabaseObjectNotFoundException instead.

This was done in symfony/symfony#61583, and that fixed the issue.

The goal is to prevent someone else from thinking they can catch a TableNotFoundException when DBAL returns a generic DatabaseObjectNotFoundException on SQL Server.

Parsing error messages is really fragile. And IIRC, SQL Server might even emit localized error messages when running on a non-English Windows system.

Indeed, there are Local Language Versions in SQL Server and we don't want to parse the message in every possible language. Having the correct exception class thrown only when the server is in English is worse than the current situation where the generic class is always thrown.

@derrabus
Copy link
Member

derrabus commented Sep 3, 2025

In the context of the issue you're attempting to solve, I wonder if it wouldn't be the more robust solution to catch the DatabaseObjectNotFoundException instead.

This was done in symfony/symfony#61583, and that fixed the issue.

👍🏻

The goal is to prevent someone else from thinking they can catch a TableNotFoundException when DBAL returns a generic DatabaseObjectNotFoundException on SQL Server.

Yeah, I realize that this is a pitfall. We should probably document this as a known limitation. Don't know what's the best place for that though.

Parsing error messages is really fragile. And IIRC, SQL Server might even emit localized error messages when running on a non-English Windows system.

Indeed, there are Local Language Versions in SQL Server and we don't want to parse the message in every possible language. Having the correct exception class thrown only when the server is in English is worse than the current situation where the generic class is always thrown.

Exactly. So, let's close the PR?

@GromNaN
Copy link
Member Author

GromNaN commented Sep 4, 2025

Closing as this does not improve the situation.

@GromNaN GromNaN closed this Sep 4, 2025
@GromNaN GromNaN deleted the mssql-table-not-found branch September 4, 2025 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

getIsSameDatabaseChecker catches wrong exception on SQL_SERVER
3 participants