Comparing a flags enum field with string constant using the has operator fails
Comparing a flags enum field with string constant using the has operator fails.
/odata/files?$filter=Attributes has 'Hidden'
Assemblies affected
Microsoft.OData.Core
Reproduce steps
Use the has operator to compare a flag enum filed and a string constant
Expected result
The string constant should be treated as enum constant value.
Actual result
The exception of type Microsoft.OData.ODataException is thrown with message: "A binary operator with incompatible types was detected. Found operand types 'My.FlagsEnumType' and 'Edm.String' for operator kind 'Has'."
Additional detail
The code in the Microsoft.OData.UriParser.TypePromotionUtils.PromoteOperandTypes method should be fixed to support comparing enum with string using the has operator.
@khodaie Have you tried using the fully qualified namespace for the enum? It seems like ODL is treating Hidden as a string and not as enum . You can try using has - NameSpace'Hidden'.
@KanishManuja-MS When using UnqualifiedCallAndEnumPrefixFreeResolver or StringAsEnumResolver, I expect to use the prefix free enum in the has operrator as well as eq and ne. In previous versions of the ODATA(v6.19-) it works as expected and I cannot tell my API users to change their queries because of my internal framework update.