-
Notifications
You must be signed in to change notification settings - Fork 32
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]: Inconsistent Enum Persistence Between Jakarta Persistence and Jakarta NoSQL Affects Query Behavior in TCK Tests #830
Comments
I mean, that's why we say explicitly:
|
Thus, I only need to change the TCK; |
Oh OK I misunderstood. |
It looks like TCK tests were never updated accordingly after the decision was made to have order of enums be vendor-specific. I see at least 4 tests that depend on a NumberType attribute to be ordered in a particular way. Creating NoSQL-specific tests isn't the right answer. The TCK would still be invalid for anything else that isn't JPA. JPA by the way can configure how the enum value is persisted and could be made to use a String instead, but that isn't the right answer either due to what the spec says. I'm thinking the least intrusive way to correct this will be to duplicate the NumberType attribute on the entity into two attributes where one is the enum (preserving most tests as is because they don't order by it) and another is a numeric constant value that can be used to consistently order in the way that tests already expect. I can look into this on Monday. |
Signed-off-by: Nathan Rauh <[email protected]>
Specification Version
1.0.0
Bug report
There is an inconsistency in how enums are persisted by default in Jakarta Persistence (JPA) and Jakarta NoSQL, which significantly impacts queries and the related TCK (Technology Compatibility Kit) tests that involve fields of enum type.
Issue Overview:
Jakarta Persistence (JPA):
0
for the first constant,1
for the second, etc.) is stored in the database.Jakarta NoSQL:
"ONE"
,"PRIME"
,"COMPOSITE"
) is stored.Impact on Query Behavior:
This difference in storage strategies leads to inconsistencies in query results between SQL and NoSQL databases when dealing with enum fields. Specifically:
Sorting Behavior:
ONE (0)
,PRIME (1)
,COMPOSITE (2)
."COMPOSITE"
,"ONE"
,"PRIME"
.Filtering and Equality Checks:
Solution
That is a classic case for test specialization; thus, I could create tests to verify it on the NoSQL side; we already have a package for NoSQL. The goal could be to use the
NoSQLEntityTests
for this.The text was updated successfully, but these errors were encountered: