Open roji opened 3 years ago
@roji Are we sure this is useless? SQL Server can be picky about the two sides of an expression having the same type, and the type mapping for IPAddress is nvarchar(45)
.
@ajcvickers well, the nvarchar(45)
cast is inferred from the other side of the equality operator, i.e. the Address
column; I think (but I could be PG-centric here) that SQL Server should be able to infer the literal type just as well without the explicit class.
Put differently, if this explicit cast is somehow necessary, then we have a bug in the simpler case where the property is compared against an IPAddress literal, rather than against a ReadOnlyIPAddress, since in that case no cast is generated...
When comparing a property with a value-converted literal/parameter, if the literal/parameter's type is a subclass of the properties, a Convert node is introduced. If both nodes end up the same type mapping, the convert should be removable.
As an example, see test Comparison_with_value_converted_subclass in GearsOfWars, where comparing an IPAddress with a ReadOnlyIPAddress generates
WHERE [b].[Address] = CAST(N'127.0.0.1' AS nvarchar(45))
.Split out of #25587