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

Housekeeping: use plain enums with IN clauses where possible #5343

Open
davidwatkins73 opened this issue Mar 24, 2021 · 5 comments
Open

Housekeeping: use plain enums with IN clauses where possible #5343

davidwatkins73 opened this issue Mar 24, 2021 · 5 comments
Assignees
Labels
good first issue An issue suitable for new project collaborators small change Should be a simple, low complexity issue

Comments

@davidwatkins73
Copy link
Member

In some parts of waltz we needlessly convert enum values to string equivalents eg.

dsl.select().from(Tables.FOO).where(FOO.COL.in(MyEnum.BAA.name());

jOOQ is perfectly happy to allow this instead:

dsl.select().from(Tables.FOO).where(FOO.COL.in(MyEnum.BAA);

As a first pass looking for code that matches the following search str: ENTITY_LIFECYCLE_STATUS.in( - gives a few candidates where we are mapping over a set of enums to get their string's and using those in the in clause.

`

@davidwatkins73 davidwatkins73 added the good first issue An issue suitable for new project collaborators label Mar 24, 2021
@davidwatkins73
Copy link
Member Author

Here's an example:

List<String> validStatusNames = map(
          options.entityLifecycleStatuses(),
          s -> s.name());

Condition statusCondition = LOGICAL_DATA_ELEMENT.ENTITY_LIFECYCLE_STATUS.in(validStatusNames);

where we could just have written:

Condition statusCondition = LOGICAL_DATA_ELEMENT.ENTITY_LIFECYCLE_STATUS.in(options.entityLifecycleStatuses);

@mcleo-d
Copy link
Member

mcleo-d commented May 10, 2021

Hi @davidwatkins73 - Is there anything I can do to help pull contributors into this issue. It would be great to get into closed and over the line?

Speak soon,

James 🚀

@davidwatkins73 davidwatkins73 added the small change Should be a simple, low complexity issue label Feb 12, 2023
@vijaya-lakshmi-venkatraman

Hi @davidwatkins73
I am a newbie to waltz and I'd like to give a try.
Does the below format need changing too?

Map<Long, Long> entityToRatingMap = dsl
                .select(ar.RATING_ID, ar.ENTITY_ID)
                .from(ar)
                .where(ar.ASSESSMENT_DEFINITION_ID.eq(assessmentId))
                .and(ar.ENTITY_ID.in(diagramEntityIds))
                .and(ar.ENTITY_KIND.eq(aggregatedEntityKind.name()))
                .fetchMap(ar.ENTITY_ID, ar.RATING_ID);

to

Map<Long, Long> entityToRatingMap = dsl
                .select(ar.RATING_ID, ar.ENTITY_ID)
                .from(ar)
                .where(ar.ASSESSMENT_DEFINITION_ID.eq(assessmentId))
                .and(ar.ENTITY_ID.in(diagramEntityIds))
                .and(ar.ENTITY_KIND.eq(aggregatedEntityKind)
                .fetchMap(ar.ENTITY_ID, ar.RATING_ID);

@davidwatkins73
Copy link
Member Author

Hi @vijaya-lakshmi-venkatraman
Thanks for the interest in making a contribution!

I've taken a look at your suggestion, however I'm not sure it will work as I don't think jOOQ offers overloaded variants of .eq which can accept enums.

Thanks, /dw

@davidwatkins73
Copy link
Member Author

I've assigned the issue to you for tracking purposes. It doesn't mean we are expecting you to contribute, just that we want to ensure that we don't end up with duplicate work. Let me know if you'd rather not be listed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue An issue suitable for new project collaborators small change Should be a simple, low complexity issue
Projects
None yet
Development

No branches or pull requests

3 participants