Skip to content
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

Allow $filtering with enum integer value in squote and without squote #3014

Merged
merged 9 commits into from
Jul 22, 2024

Conversation

WanjohiSammy
Copy link
Contributor

Issues

This pull request fixes #2542.

Description

This change is to allow $filter using enum integer value.

For example, to allow:

Checklist (Uncheck if it is not completed)

  • Test cases added
  • Build and test with one-click build and test script passed

Additional work necessary

If documentation update is needed, please add "Docs Needed" label to the issue and provide details about the required document change in the issue.

var enumMember = enumType.Members.FirstOrDefault(m => m.Value.Value == memberIntegralValue);
if (enumMember != null)
{
string literalText = ODataUriUtils.ConvertToUriLiteral(enumMember.Name, default(ODataVersion));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to use the version from configuration?

Copy link
Member

@xuzhg xuzhg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Donot we need to change 'EnumAsStringUriResolver'?

habbes
habbes previously approved these changes Jul 17, 2024
Copy link
Contributor

@gathogojr gathogojr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@WanjohiSammy WanjohiSammy merged commit 3080ebc into main Jul 22, 2024
5 checks passed
WanjohiSammy added a commit that referenced this pull request Jul 22, 2024
…#3014)

* Allow comparison with underlying integral for Enum member and add capability to convert integral value to enum member name

* Bump with tests

* Move helper methods to EnumHelper, use them to check for enum values and adds more tests to handle float, long and int.

* Use explicit/exact type instead of 'var'

* Add more tests to handle huge, long values

* Add assertion for comparing enum member name with the result

* Move extension methods from Edm EnumHelper.cs to Core in EdmExtensionMethods.cs
WanjohiSammy added a commit that referenced this pull request Jul 23, 2024
…nteger value in squote and without squote (#3018)

* Support Enums as Keys in OData Client (#3013)

* Checkout from 'main'

* Add and modify test cases

* Only allow nullable Generic Type Enum

* Adding a test that throws Exception if key is nullable generic type with struct as generic argument

* Adding a test to mock querying data with enum as keys

* Add a test to select single entity

* Add test to filter by enum member name and a test to use ByKey to filter by composite keys

* Add a test to filter by enum key only using ByKey()

* Allow $filtering with enum integer value in squote and without squote (#3014)

* Allow comparison with underlying integral for Enum member and add capability to convert integral value to enum member name

* Bump with tests

* Move helper methods to EnumHelper, use them to check for enum values and adds more tests to handle float, long and int.

* Use explicit/exact type instead of 'var'

* Add more tests to handle huge, long values

* Add assertion for comparing enum member name with the result

* Move extension methods from Edm EnumHelper.cs to Core in EdmExtensionMethods.cs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Filter with enum integer value
4 participants