From ad6d9f142b53941077e7c5abf732b5334fa3bae9 Mon Sep 17 00:00:00 2001 From: James Fredley Date: Wed, 27 May 2026 17:16:39 -0400 Subject: [PATCH] Convert eq/like parens to command-chain syntax in DetachedCriteriaSpec Replaces 18 method calls of the form `eq('field', 'value')` and `like('field', 'pattern')` inside `criteria.with { ... }` and `criteria.build { ... }` closures with the Groovy command-chain form `eq 'field', 'value'` / `like 'field', 'pattern'`. This matches the idiomatic Groovy DSL style used elsewhere in GORM criteria builders and was the convention adopted in the hibernate7 staging branch. This change was originally pulled forward into the hibernate7 staging branch as part of a larger PR #15654 commit and was flagged by @sbglasius as belonging in a separate clean-up PR rather than mixed with the Hibernate 7 clone. Extracting it here so it can land on 8.0.x on its own merits as a prerequisite for the Hibernate 7 work. Once merged here, the corresponding style change on the hibernate7 staging branch should be removed since it will arrive through the next merge of 8.0.x. Assisted-by: claude-code:claude-4.7-opus --- .../tck/tests/DetachedCriteriaSpec.groovy | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/grails-datamapping-tck/src/main/groovy/org/apache/grails/data/testing/tck/tests/DetachedCriteriaSpec.groovy b/grails-datamapping-tck/src/main/groovy/org/apache/grails/data/testing/tck/tests/DetachedCriteriaSpec.groovy index a23ca037f02..f5e58e34473 100644 --- a/grails-datamapping-tck/src/main/groovy/org/apache/grails/data/testing/tck/tests/DetachedCriteriaSpec.groovy +++ b/grails-datamapping-tck/src/main/groovy/org/apache/grails/data/testing/tck/tests/DetachedCriteriaSpec.groovy @@ -32,7 +32,7 @@ class DetachedCriteriaSpec extends GrailsDataTckSpec { when: 'A detached criteria instance is created and the list method used with the max parameter' def criteria = new DetachedCriteria(Person) criteria.with { - eq('lastName', 'Simpson') + eq 'lastName', 'Simpson' } def results = criteria.list(max: 2) @@ -45,7 +45,7 @@ class DetachedCriteriaSpec extends GrailsDataTckSpec { when: 'A detached criteria instance is created and the list method used with the max parameter' criteria = new DetachedCriteria(Person) criteria.with { - eq('lastName', 'Simpson') + eq 'lastName', 'Simpson' } results = criteria.list(offset: 2, max: 4) @@ -63,7 +63,7 @@ class DetachedCriteriaSpec extends GrailsDataTckSpec { when: 'A detached criteria instance is created that uses a property projection' def criteria = new DetachedCriteria(Person) criteria.with { - eq('lastName', 'Simpson') + eq 'lastName', 'Simpson' } criteria = criteria.property('firstName') @@ -75,7 +75,7 @@ class DetachedCriteriaSpec extends GrailsDataTckSpec { when: 'A detached criteria instance is created that uses a property projection using property missing' criteria = new DetachedCriteria(Person) criteria.with { - eq('lastName', 'Simpson') + eq 'lastName', 'Simpson' } criteria = criteria.firstName @@ -93,7 +93,7 @@ class DetachedCriteriaSpec extends GrailsDataTckSpec { when: 'A detached criteria instance is created matching the last name' def criteria = new DetachedCriteria(Person) criteria.with { - eq('lastName', 'Simpson') + eq 'lastName', 'Simpson' } then: 'The count method returns the right results' @@ -106,7 +106,7 @@ class DetachedCriteriaSpec extends GrailsDataTckSpec { when: 'A detached criteria is created that deletes all matching records' def criteria = new DetachedCriteria(Person).build { - eq('lastName', 'Simpson') + eq 'lastName', 'Simpson' } int total = criteria.updateAll(lastName: 'Bloggs') then: 'The number of deletions is correct' @@ -122,7 +122,7 @@ class DetachedCriteriaSpec extends GrailsDataTckSpec { when: 'A detached criteria is created that deletes all matching records' def criteria = new DetachedCriteria(Person).build { - eq('lastName', 'Simpson') + eq 'lastName', 'Simpson' } int total = criteria.deleteAll() @@ -137,7 +137,7 @@ class DetachedCriteriaSpec extends GrailsDataTckSpec { when: 'A detached criteria is created that matches the last name and then iterated over' def criteria = new DetachedCriteria(Person).build { - eq('lastName', 'Simpson') + eq 'lastName', 'Simpson' } int total = 0 criteria.each { @@ -155,7 +155,7 @@ class DetachedCriteriaSpec extends GrailsDataTckSpec { when: 'A detached criteria instance is created matching the last name' def criteria = new DetachedCriteria(Person) criteria.with { - eq('lastName', 'Simpson') + eq 'lastName', 'Simpson' } def result = criteria.findByFirstNameLike('B%') @@ -172,11 +172,11 @@ class DetachedCriteriaSpec extends GrailsDataTckSpec { when: 'A detached criteria instance is created matching the last name' def criteria = new DetachedCriteria(Person) criteria.with { - eq('lastName', 'Simpson') + eq 'lastName', 'Simpson' } def result = criteria.get { - like('firstName', 'B%') + like 'firstName', 'B%' } then: 'The list method returns the right results' result != null @@ -190,11 +190,11 @@ class DetachedCriteriaSpec extends GrailsDataTckSpec { when: 'A detached criteria instance is created matching the last name' def criteria = new DetachedCriteria(Person) criteria.with { - eq('lastName', 'Simpson') + eq 'lastName', 'Simpson' } def results = criteria.list { - like('firstName', 'B%') + like 'firstName', 'B%' } then: 'The list method returns the right results' results.size() == 1 @@ -215,11 +215,11 @@ class DetachedCriteriaSpec extends GrailsDataTckSpec { when: 'A detached criteria instance is created matching the last name and count is called with additional criteria' def criteria = new DetachedCriteria(Person) criteria.with { - eq('lastName', 'Simpson') + eq 'lastName', 'Simpson' } def result = criteria.count { - like('firstName', 'B%') + like 'firstName', 'B%' } then: 'The count method returns the right results' result == 1 @@ -233,7 +233,7 @@ class DetachedCriteriaSpec extends GrailsDataTckSpec { when: 'A detached criteria instance is created matching the last name' def criteria = new DetachedCriteria(Person) criteria.with { - eq('lastName', 'Simpson') + eq 'lastName', 'Simpson' } def result = criteria.count() @@ -249,7 +249,7 @@ class DetachedCriteriaSpec extends GrailsDataTckSpec { when: 'A detached criteria instance is created matching the last name' def criteria = new DetachedCriteria(Person) criteria.with { - eq('lastName', 'Simpson') + eq 'lastName', 'Simpson' } def results = criteria.list() @@ -265,7 +265,7 @@ class DetachedCriteriaSpec extends GrailsDataTckSpec { when: 'A detached criteria instance is created matching the last name' def criteria = new DetachedCriteria(Person) criteria = criteria.build { - eq('lastName', 'Simpson') + eq 'lastName', 'Simpson' } def results = criteria.list(max: 2)