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

TCK cannot expect sorting on enum #831

Merged

Conversation

njr-11
Copy link
Contributor

@njr-11 njr-11 commented Aug 26, 2024

Fixes #830

This corrects the error in the TCK where it expects sorting on an enum attribute to be done in a particular way, which per the spec is vendor specific.

Because this fix is needed in the 1.0.1 maintenance release, it should be as minimal as possible to fix the TCK, which is achieved by adding an entity attribute for the ordinal value and switching a few places in the TCK to sort on that value instead of the enum.

@njr-11 njr-11 added bug Something isn't working test Something test-related labels Aug 26, 2024
@njr-11 njr-11 added this to the 1.0.1 milestone Aug 26, 2024
@@ -36,9 +36,14 @@ public enum NumberType {
@jakarta.nosql.Column
private Short numBitsRequired;

// Sorting on enum types is vendor-specific in Jakarta Data.
// Use numTypeOrdinal for sorting instead.
Copy link
Contributor

Choose a reason for hiding this comment

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

If you are already changing this entity why not put @Enumerated(STRING)

for semantic and that sounds better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you are already changing this entity why not put @Enumerated(STRING)

for semantic and that sounds better.

If you like, I can add that too, but it isn't a solution on its own and doesn't fix the problem. Without the other changes I made here, the test would remain broken for providers that are neither JPA nor NoSQL.

Copy link
Contributor

Choose a reason for hiding this comment

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

@njr-11 I know, but once you can change the tests, I recommend using String and updating the tests based on the String instead of int.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@njr-11 I know, but once you can change the tests, I recommend using String and updating the tests based on the String instead of int.

I added Enumerated(STRING) for you under ba68544
but it is wrong to redo test assertions like you are suggesting in a .0.1 maintenance release. The scope of a fix in a maintenance should be limited to fixing the problem only, not refactoring tests or switching things around that aren't required to fix the bug.

Copy link
Contributor

Choose a reason for hiding this comment

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

@njr-11 I know, but once you can change the tests, I recommend using String and updating the tests based on the String instead of int.

I added Enumerated(STRING) for you under ba68544 but it is wrong to redo test assertions like you are suggesting in a .0.1 maintenance release. The scope of a fix in a maintenance should be limited to fixing the problem only, not refactoring tests or switching things around that aren't required to fix the bug.

I agreed, and that is why I proposed to create those tests as a NoSQL extension:

#830 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agreed, and that is why I proposed to create those tests as a NoSQL extension:

#830 (comment)

Adding some NoSQL specific tests (and also some Jakarta Persistence specific ones) in this are is fine for the 1.1 release. It would be out of place for the 1.0.1 maintenance release and is not a substitute for fixing the bug that exists in 1.0 / 1.0.1 which this PR addresses.

private NumberType numType; // enum of ONE | PRIME | COMPOSITE

@jakarta.nosql.Column
private int numTypeOrdinal; // ordinal value of numType
Copy link
Contributor

Choose a reason for hiding this comment

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

@njr-11 you changed to String, but you still using this one here: numTypeOrdinal.

Shall we remove this one and update the tests to work with the enum as String?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@njr-11 you changed to String, but you still using this one here: numTypeOrdinal.

Shall we remove this one and update the tests to work with the enum as String?

To repeat what I said earlier, doing that "isn't a solution on its own and doesn't fix the problem. Without the other changes I made here, the test would remain broken for providers that are neither JPA nor NoSQL."

@otaviojava otaviojava merged commit 64a1bbd into jakartaee:main Sep 1, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working test Something test-related
Projects
None yet
2 participants