Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Patch for custom binary operators that use standard comparison symbols
When a custom binary operator uses a standard comparison operator (=, <>, <, >, <=, >=) EF Core will generate a pattern that causes a syntax error in PostgreSQL. Example SQL: WHERE a < b = TRUE This patch adds logic to check if the custom binary operator is one of the standard comparison operators. If so, it wraps the expression in parenthesis. While it seems like this could be avoided by having the custom translator construct a standard Expression.LessThan(Expression,Expression), this causes an error to be thrown...because the binary operator isn't defined. See the related links for more information. Example stack trace: System.InvalidOperationException : The binary operator LessThanOrEqual is not defined for the types 'System.Net.IPAddress' and 'System.Net.IPAddress'. at System.Linq.Expressions.Expression.GetUserDefinedBinaryOperatorOrThrow(...) at System.Linq.Expressions.Expression.GetComparisonOperator(...) at System.Linq.Expressions.Expression.LessThanOrEqual(...) Related: - dotnet/efcore#9143 - npgsql#323 (review)
- Loading branch information