Skip to content

Unique constraint ignores transient group in parent/child save #14532

Open
@rmorrise

Description

@rmorrise

Task List

  • Steps to reproduce provided
  • Example that reproduces the problem uploaded to Github
  • Full description of the issue provided (see below)

Steps to Reproduce

  1. Clone the example repo:
    https://github.com/rmorrise/grails-unique-child
  2. grails run-app
  3. POST the following JSON data:
    http://localhost:8080/MasterThing
    Content-Type application/json
{
	"details": [
		{
			"itemName": "Foo"
		}
	]
}
  1. Repeat the same POST request again.

Expected Behaviour

Both requests should be OK.

Validation of the unique constraint on DetailItem should be scoped to the master object that is being posted.

Actual Behaviour

HTTP error 422:
Property [itemName] of class [class grails.unique.child.DetailItem] with value [Foo] must be unique

The unique constraint is validated globally for the itemName properly only.

Environment Information

  • Operating System: Windows 7 x64
  • GORM Version: 6.1.10.RELEASE
  • Grails Version (if using Grails): 3.3.8
  • JDK Version: 1.8.0_121

Example Application

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions