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

Translate enum string name to underlying enum type #137

Merged
merged 14 commits into from
Sep 10, 2023

Conversation

charliettaylor
Copy link
Collaborator

Drafting this for now since it needs more work, but I think I have the gist of it!

  • Add field to ColumnInfo to store the enum that will translate the string
  • Change tests to Strict mode because enum can only be specified in Strict mode
  • Update EmployeeObj to have an enum for testing
    • need to add more tests
  • Only implemented for LinqExecutor, need to make sure it works for all other ones as well

@tspence
Copy link
Owner

tspence commented Sep 7, 2023

Thanks for this PR! I’m traveling right now but will return on Sept 9 and can review and merge.

@tspence
Copy link
Owner

tspence commented Sep 7, 2023

I should mention that searchlight used to be really good with enums - I was a heavy user of enums back in 2015; but I gradually started phasing them out in most of my APIs which is why the test coverage probably isn’t as good anymore. Thanks for working on this!

@charliettaylor
Copy link
Collaborator Author

charliettaylor commented Sep 9, 2023

Updates

  • Update testing for all supported DB types, now support automatic enum translation
    • Mongo is a bit weird if you don't use int, other sources let you use tinyint/byte or other types of ints
  • Update a couple files to use file scoped namespaces
  • Formatting and cleanup
  • Not sure why GitHub workflow isn't passing, all the checks pass on my local Docker containers

@charliettaylor charliettaylor marked this pull request as ready for review September 9, 2023 22:20
@charliettaylor charliettaylor linked an issue Sep 10, 2023 that may be closed by this pull request
@tspence
Copy link
Owner

tspence commented Sep 10, 2023

I'm back from travels and am looking at this PR.

@tspence
Copy link
Owner

tspence commented Sep 10, 2023

Darnit, it looks like this has some conflicts with my work on autocomplete. Let me try to merge

@tspence
Copy link
Owner

tspence commented Sep 10, 2023

@charliettaylor this PR now passes all tests locally - I'm not sure exactly why the github action is failing. It seems to be not allowing you to view the SonarCloud token on the repository since the PR comes from your repo. Regardless, I'm happy to merge this - are my changes OK to you?

Copy link
Owner

@tspence tspence left a comment

Choose a reason for hiding this comment

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

Only concern is that enumType seems duplicative. I remember I had that in my code originally specifically for cases where the underlying value was an enum but it was presented in the API as a string or integer.

@charliettaylor
Copy link
Collaborator Author

Only concern is that enumType seems duplicative. I remember I had that in my code originally specifically for cases where the underlying value was an enum but it was presented in the API as a string or integer.

Yeah I tried to avoid having another enum type field, but the way that the DataSource parses it makes it simpler to pass it via ColumnInfo. Your changes look fine to me! I'll merge it in a bit

@charliettaylor charliettaylor merged commit 70b0e0d into tspence:main Sep 10, 2023
1 check failed
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.

SearchlightField EnumType doesn't do anything
3 participants