[5.0 RC2] Handle square brackets around explicitly specified SQL Server type names #22610
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #22569
Description
In EF Core 3.1, it was possible to specify a SQL Server column type using square brackets. For example, "[money]" instead of "money". EF Core didn't understand this, so we treated it as an unknown decimal type, and passed it through to SQL Server as-is.
In EF Core 5.0, we added support for precision and scale specified independently of the type. We don't do this when we know the type is
money
because doing so is not valid. However, since we don't recognize "[money]" it gets precision and scale added.The fix is to recognize SQL Server types with square brackets. Note that only type names without spaces can have square brackets.
Customer Impact
I don't believe many customers are using square brackets like this. However, I could be wrong about this since they "just worked" in this case before 5.0, so nobody would have had a reason to tell us they were doing so. Regardless, it is a regression from 3.1.
How found
Customer reported on RC1.
Test coverage
We didn't know people were doing this (and we never considered it) so we had no coverage. I've added type mapping coverage for this kind of usage in this PR.
Regression?
Yes, from 3.1.
Risk
Low. The fix adds additional support for these cases without changing existing support.