apache / apache/grails-core

Error when updating a dynamic association in a newly created object

Open
#14,565 0 comments 0 reactions 0 assignees View on GitHub
relates-to: grails-data-neo4j
Dominant language
Groovy
Stars
2.9k
Forks
975
Avg merge
1d 22h
Merged PRs (30d)
92

Description

This test also fails in master.

I created a PR for 6.0.x.BRINQA, but it might not be the best solution.

def "Test update newly created object"() {
setup:
def victor = new Pet(name: 'Victor')
def fritz = new Pet(name: 'Fritz')
def franz = new Pet(name: 'Franz')
def heinrich = new Pet(name: 'Heinrich')
victor.buddies = [fritz, franz]

when:
victor.save()
heinrich.save()
session.flush()

then:
victor.buddies.name.sort() == ['Franz', 'Fritz']

when: "Adding an element"
victor.buddies.add(heinrich)
def cousin = victor.cousin

then:
victor.buddies.name.sort() == ['Franz', 'Fritz', 'Heinrich']

when:
victor.markDirty("buddies")
victor.save()
session.flush()
victor.discard()
victor = Pet.findByName("Victor")

then:
victor.buddies.name.sort() == ['Franz', 'Fritz', 'Heinrich']
}

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the failure in the shown Groovy test, especially the dynamic buddy association and the save/flush sequence. Done means the test passes: adding Heinrich to victor.buddies survives save, reload, and the final association assertion.

Written by the indexing model from the issue text.

Assessment

Tech stack
groovy
Domain
backend, database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.