Translate nested CASE to simpler COALESCE
When EntityFramework UseDatabaseNullSemantics == true or when using null propagation expressións (?? or ?) EntityFramework6 generates and expression tree with many nested CASE WHEN expressions.
When this happens the generated SQL query is hard to analyze for optimizations.
Also CASE expression breaks Postgres type inference in many cases. View: #60 #62 #84 #87 #90 issues for more detail.
This pull request is a starting point for solving described issues. And very annoying #60 #62 #84 #87 #90 issues.
There are many compilation errores, sorry. I will fix all of then and open new pull request
Solved compilation errors and added unit tests
Hello, Thanks for your contribution, I will look at this as soon as I can! Can you please squash all commits to make it easier to review ? Thanks!
I have squash all commits into one. In any case, the #93 pull request is simpler and more urgent than this, and the core concept is the same, translate "case" to coalesce.
Differences:
-
#94: (current) reduce nested "case X is null" constructions that are generated when null propagation is used. (284 lines of code) Is a general solution of the approach of #93
-
#93 reduced only the leaf "case X is null" to coalesce. (19 lines of code). @Emill is working on it
Both solves issues #60 #62 #84 #87 #90
I think is better to prioritize the other pull request #93 and later work on this one.