Gh 14503 unique discriminator null spec#15653
Open
jagiro wants to merge 1 commit into
Open
Conversation
…e#14503) Adds a Spock @PendingFeature regression test to MultiColumnUniqueConstraintSpec in both grails-data-hibernate5 and grails-data-hibernate7 core test modules. The test exercises the bug described in apache#14503: when a domain declares `unique: [discriminator]` and the discriminator is nullable, saving a new row with the discriminator set to null currently fails validation if any row with the same main field value already exists, regardless of the existing row's discriminator value. The validator emits SQL without the discriminator clause. The test is marked @PendingFeature with a reason referencing the issue, so it does not fail the build. When the fix lands and the test starts passing, Spock will fail with PendingFeatureNotFinished as a reminder to remove the annotation. No fix is proposed here per the maintainers' request to discuss the fix approach as a team. This change only codifies the failing scenario as a reproducer in the framework's own test suite.
4 tasks
Contributor
|
@jagiro I'm guessing you tried to merge 8.x into 7.x? Should the base of this be 8.x? |
Contributor
|
@jagiro I see in your issue comment this was meant to be merged against 8.0.x-hibernate7 so I've updated the base branch. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #14503 per @borinquenkid's request:
"add a spec to H5 and H7 core modules and mark them as pending and then we
will follow up on the fix".
This PR adds the failing scenario as a
@PendingFeatureSpock test in bothgrails-data-hibernate5/coreandgrails-data-hibernate7/coretest modules.It does not propose a fix. The fix approach is still open per
@jdaugherty's "we should discuss this as a team before proposing a fix"
(option 1 — skip-on-null SQL-standard, option 2 — explicit
IS NULLcheck,or configurable).
What this PR adds
In both modules,
MultiColumnUniqueConstraintSpec.groovygains:@Entity DomainTwowithname unique: ['discriminator']anddiscriminator nullable: true.@PendingFeaturetest case:"save with null discriminator succeeds when only non-null discriminator
rows exist for the same main field".
manager.addAllDomainClasses(...).Verification done locally
./gradlew :grails-data-hibernate5-core:test --tests "*MultiColumnUniqueConstraintSpec*"→ 4 tests, 3 passed, 1 skipped (the new
@PendingFeature, as expected)../gradlew :grails-data-hibernate7-core:test --tests "*MultiColumnUniqueConstraintSpec*"→ same result.
@PendingFeaturefrom the H5 file andre-ran. The test FAILED with
Condition not satisfied: saved != null(the
save()call returns null because the validator rejects the new rowas a duplicate even though the existing row has a non-null discriminator).
Restored
@PendingFeatureafter confirming../gradlew :grails-data-hibernate5-core:test :grails-data-hibernate7-core:test): 2892 tests, 5 failed, 30 skipped.All 5 failures are pre-existing environmental issues (testcontainers
cannot find a Docker environment on this machine):
RLikeHibernate7Spec(3 tests),GrailsSequenceGeneratorEnumSpec,HibernateDatastoreIntegrationSpec. None of the failures touch thefiles modified in this PR. CI with Docker available should report
these as passing.
When the fix lands and the test starts passing, Spock will throw
PendingFeatureNotFinishedas a reminder to remove the annotation.Note on AI tooling
This contribution was prepared with assistance from Claude (Anthropic).
The reproducer was first verified in an external Grails 7.x application
and the spec was authored, run, and sanity-checked locally before
submission, per the ASF Generative Tooling policy.