-
Notifications
You must be signed in to change notification settings - Fork 161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Canonical functions not returning null for null parameters #1310
Comments
Can you provide an explicit example of how the final string looks like today, and how it should look like? |
The final string should be the concatenation of the specified strings for users with a VAT number (eg: |
@Xriuk oh I see now. I had slightly misunderstood your example. I see that both arguments for the concatenation are inside of the |
Yes, and they themselves are not nullable inside VatNumber, but VatNumber itself can be nullable. I don't know if maybe this is not causing the nullability to propagate to the returned value or if null values are not handled at all. |
If we don't have the null propagate setting, it's by default
You will get "empty string" in the payload: And yes, the Database has the similar log as: If you have the following configuration on the query setting:
|
See my test sample at: https://github.com/xuzhg/WebApiSample/tree/main/v8.x/NullValueSample |
The specification does not seem to allow customization, and seems pretty explicit to me.
|
This solution is conflicting with IMO there should be at least 2 separate options to handle nulls, one to handle generated code like properties/navigations and one to handle null for canonical functions. |
Assemblies affected
ASP.NET Core OData 8.2.4"
Describe the bug
At least one of the built-in/canonical functions do not return null when one of their parameter is null.
A
concat
with a non-nullable string property on a nullable complex property, does not return null but an empty string.Data Model
EDM (CSDL) Model
Request/Response
The response contain FullVAT property as an empty string for customers which do not have a VAT number.
The resulting SQL contains:
COALESCE([c].[VatNumber_Country], N'') + COALESCE([c].[VatNumber_Number], N'')
Expected behavior
Coalesce should not be used, I don't know if this is OData's fault or EF Core's. Anyway OData should perform some null checks I guess.
Additional context
Section 5.1.1.4 URL Conventions
The text was updated successfully, but these errors were encountered: