-
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
IN operator on an ENUM value causes an exception #1375
Comments
The OData standard ABNF for the
So I believe the "quoted" request We should update this logic to allow for enum member values if no matching enum member name is found to match. |
Is there a reason such code doesn't rely on something like |
@ThomasHeijtink also, is there a reason that you are preferring to use the integer value for the enum rather than the member names? @julealgon that sounds like the right approach, I'll double check that the standard doesn't have any quirk that prevents using it, but that's probably what I'll go with, thanks! |
@corranrogue9 thanks for asking. It's mainly to keep queries small and slightly more robust and more versatile. Small is evident. Robust because a front-end or other clients don't require the most recent name/version in case we change it at the backend. Versatile because you can also use flagged enums. |
Assemblies affected
Which assemblies and versions are known to be affected e.g. ASP.NET Core OData 8.x
ASP.NET Core OData 9.1.1
Describe the bug
Filtering on an Enum property using the integer value as string in combination with the
IN
operator causes the following exception:When filtering on an enum value using just an integer value in combination with the
IN
operator we get the following exception:Regular filtering using the
EQ
operator on any of these two representation of an enum value works fine.Reproduce steps
Take the EnumsController. Change the Get to using the
ODataQueryOptions<Employee>
directly (rather than using theEnableQuery
attribute) and issue aGET
tohttp://localhost:5000/convention/employees?$filter=Gender in (2,3)
orhttp://localhost:5000/convention/employees?$filter=Gender in ('2','3')
.Data Model
Employee model in the
ODataCustomizedSample
sample project.EDM (CSDL) Model
Not applicable
Request/Response
Not relevant
Expected behavior
The endpoint to return employees of either gender.
Screenshots
Not applicable
Additional context
Exception + stacktrace with quoted numerical enum value:
Exception + stacktrace without quoted numerical enum value:
The text was updated successfully, but these errors were encountered: