You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The NULLIF function returns a null value if value1 equals value2; otherwise it returns value1. This can be used to perform the inverse operation of the COALESCE example given above:
SELECT NULLIF(value, '(none)') ...
In this example, if value is (none), null is returned, otherwise the value of value is returned.
After a second look, NULLIF is actually universally supported across databases and an issue already exists to track doing this in EF itself: dotnet/efcore#31682. So when I have a spare moment, I'll port this support into EF and remove it from EFCore.PG.
Activity
roji commentedon Aug 15, 2018
Don't you have it backwards in your implementation above? Shouldn't it be
a == b ? null : a?Otherwise I like it... If we can get the ternary version to work well that would be great, but mind null vs. default... This could get a bit tricky.
roji commentedon Dec 11, 2024
@WhatzGames can you please comment here so you can be assigned for credit?
Add NullIf Translation for Ternary expressions (#3403)
WhatzGames commentedon Dec 11, 2024
Sure! And thanks for the cleanup :)
roji commentedon Dec 12, 2024
After a second look, NULLIF is actually universally supported across databases and an issue already exists to track doing this in EF itself: dotnet/efcore#31682. So when I have a spare moment, I'll port this support into EF and remove it from EFCore.PG.
Add NullIf Translation for Ternary expressions (npgsql#3403)