EntityFramework6.Npgsql icon indicating copy to clipboard operation
EntityFramework6.Npgsql copied to clipboard

Translate nested CASE to simpler COALESCE

Open bgurmendi opened this issue 7 years ago • 4 comments

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.

bgurmendi avatar Apr 30 '18 09:04 bgurmendi

There are many compilation errores, sorry. I will fix all of then and open new pull request

bgurmendi avatar Apr 30 '18 12:04 bgurmendi

Solved compilation errors and added unit tests

bgurmendi avatar Apr 30 '18 14:04 bgurmendi

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!

rwasef1830 avatar May 01 '18 09:05 rwasef1830

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.

bgurmendi avatar May 02 '18 09:05 bgurmendi