You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@grails.apache.org by ma...@apache.org on 2026/08/14 06:33:09 UTC

(grails-core) branch fix/issue-16133 updated (5a10ebfac3 -> 07a30bb3eb)

This is an automated email from the ASF dual-hosted git repository.

matrei pushed a change to branch fix/issue-16133
in repository https://gitbox.apache.org/repos/asf/grails-core.git


    from 5a10ebfac3 test: adapt other tests to fixing issue 16133
     new 6948b393a3 chore: whitespace
     new f07ddd11b7 test: reset fixtures and UserIntegrationSpec assertions
     new 2263394899 fix: initialize `defaultNullable` to `true` in `AbstractGormMappingFactory`
     new 07a30bb3eb fix: preserve bidirectional binding with nullable associations

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../mapping/config/AbstractGormMappingFactory.java |  5 +++--
 .../mapping/model/AbstractMappingContext.java      |  1 +
 .../mapping/KeyValueMappingFactoryTests.groovy     |  2 +-
 .../domain/grails/test/app/Address.groovy          |  3 +++
 .../grails-app/domain/grails/test/app/User.groovy  |  3 ---
 .../grails/test/app/UserIntegrationSpec.groovy     | 22 +++++++++++++++++-----
 .../groovy/grails/test/app/pogo/Profile.groovy     |  6 ++++++
 .../web/databinding/GrailsWebDataBinder.groovy     |  2 +-
 8 files changed, 32 insertions(+), 12 deletions(-)


(grails-core) 04/04: fix: preserve bidirectional binding with nullable associations

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

matrei pushed a commit to branch fix/issue-16133
in repository https://gitbox.apache.org/repos/asf/grails-core.git

commit 07a30bb3eb9d39ab64dd1121567ba025c1bff472
Author: Mattias Reichel <ma...@gmail.com>
AuthorDate: Fri Aug 14 08:32:40 2026 +0200

    fix: preserve bidirectional binding with nullable associations
---
 .../grails/datastore/mapping/config/AbstractGormMappingFactory.java    | 3 ++-
 .../src/main/groovy/grails/web/databinding/GrailsWebDataBinder.groovy  | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/grails-datastore-core/src/main/groovy/org/grails/datastore/mapping/config/AbstractGormMappingFactory.java b/grails-datastore-core/src/main/groovy/org/grails/datastore/mapping/config/AbstractGormMappingFactory.java
index 9e3f66a649..494bf0e8eb 100644
--- a/grails-datastore-core/src/main/groovy/org/grails/datastore/mapping/config/AbstractGormMappingFactory.java
+++ b/grails-datastore-core/src/main/groovy/org/grails/datastore/mapping/config/AbstractGormMappingFactory.java
@@ -202,7 +202,8 @@ public abstract class AbstractGormMappingFactory<R extends Entity, T extends Pro
         }
         else {
             T property = BeanUtils.instantiateClass(getPropertyMappedFormType());
-            if (!GormProperties.IDENTITY.equals(mpp.getName()) && !GormProperties.VERSION.equals(mpp.getName())) {
+            if (!GormProperties.IDENTITY.equals(mpp.getName()) &&
+                    !GormProperties.VERSION.equals(mpp.getName())) {
                 property.setNullable(defaultNullable);
             }
             return property;
diff --git a/grails-web-databinding/src/main/groovy/grails/web/databinding/GrailsWebDataBinder.groovy b/grails-web-databinding/src/main/groovy/grails/web/databinding/GrailsWebDataBinder.groovy
index 80a87452dd..ec86f0860b 100644
--- a/grails-web-databinding/src/main/groovy/grails/web/databinding/GrailsWebDataBinder.groovy
+++ b/grails-web-databinding/src/main/groovy/grails/web/databinding/GrailsWebDataBinder.groovy
@@ -586,7 +586,7 @@ class GrailsWebDataBinder extends SimpleDataBinder {
                         otherSide = ((Association) property).inverseSide
                     }
                 }
-                if (otherSide != null && List.isAssignableFrom(otherSide.getType()) && !property.isNullable()) {
+                if (otherSide != null && List.isAssignableFrom(otherSide.getType())) {
                     DeferredBindingActions.addBindingAction(new Runnable() {
                         void run() {
                             if (obj[propName] != null && otherSide instanceof OneToMany) {


(grails-core) 01/04: chore: whitespace

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

matrei pushed a commit to branch fix/issue-16133
in repository https://gitbox.apache.org/repos/asf/grails-core.git

commit 6948b393a3daebc3b4ed4c377e7ecd94c3a3b67a
Author: Mattias Reichel <ma...@gmail.com>
AuthorDate: Thu Aug 13 16:49:40 2026 +0200

    chore: whitespace
---
 .../integration-test/groovy/grails/test/app/UserIntegrationSpec.groovy  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/grails-test-examples/graphql/grails-test-app/src/integration-test/groovy/grails/test/app/UserIntegrationSpec.groovy b/grails-test-examples/graphql/grails-test-app/src/integration-test/groovy/grails/test/app/UserIntegrationSpec.groovy
index 975d0e9bb8..3977e0f8bf 100644
--- a/grails-test-examples/graphql/grails-test-app/src/integration-test/groovy/grails/test/app/UserIntegrationSpec.groovy
+++ b/grails-test-examples/graphql/grails-test-app/src/integration-test/groovy/grails/test/app/UserIntegrationSpec.groovy
@@ -98,7 +98,7 @@ class UserIntegrationSpec extends Specification implements GraphQLSpec {
                 }
             }
         """)
-        Map         obj = resp.body
+        Map obj = resp.body
 
         then:
         obj.data.userCreate != null


(grails-core) 03/04: fix: initialize `defaultNullable` to `true` in `AbstractGormMappingFactory`

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

matrei pushed a commit to branch fix/issue-16133
in repository https://gitbox.apache.org/repos/asf/grails-core.git

commit 22633948995761dd1ac09e6a7ef72e74fc47ddaf
Author: Mattias Reichel <ma...@gmail.com>
AuthorDate: Thu Aug 13 17:17:59 2026 +0200

    fix: initialize `defaultNullable` to `true` in `AbstractGormMappingFactory`
---
 .../org/grails/datastore/mapping/config/AbstractGormMappingFactory.java | 2 +-
 .../org/grails/datastore/mapping/model/AbstractMappingContext.java      | 1 +
 .../mapping/keyvalue/mapping/KeyValueMappingFactoryTests.groovy         | 2 +-
 3 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/grails-datastore-core/src/main/groovy/org/grails/datastore/mapping/config/AbstractGormMappingFactory.java b/grails-datastore-core/src/main/groovy/org/grails/datastore/mapping/config/AbstractGormMappingFactory.java
index d7a33ed134..9e3f66a649 100644
--- a/grails-datastore-core/src/main/groovy/org/grails/datastore/mapping/config/AbstractGormMappingFactory.java
+++ b/grails-datastore-core/src/main/groovy/org/grails/datastore/mapping/config/AbstractGormMappingFactory.java
@@ -54,7 +54,7 @@ public abstract class AbstractGormMappingFactory<R extends Entity, T extends Pro
     private Object contextObject;
     protected Closure defaultConstraints;
     protected boolean versionByDefault = true;
-    protected boolean defaultNullable = false;
+    protected boolean defaultNullable = true;
 
     /**
      * @param contextObject Context object to be passed to mapping blocks
diff --git a/grails-datastore-core/src/main/groovy/org/grails/datastore/mapping/model/AbstractMappingContext.java b/grails-datastore-core/src/main/groovy/org/grails/datastore/mapping/model/AbstractMappingContext.java
index 8afab3ed45..e8e139b619 100644
--- a/grails-datastore-core/src/main/groovy/org/grails/datastore/mapping/model/AbstractMappingContext.java
+++ b/grails-datastore-core/src/main/groovy/org/grails/datastore/mapping/model/AbstractMappingContext.java
@@ -109,6 +109,7 @@ public abstract class AbstractMappingContext implements MappingContext, Initiali
             AbstractGormMappingFactory gormMappingFactory = (AbstractGormMappingFactory) mappingFactory;
             gormMappingFactory.setDefaultConstraints(settings.getDefault().getConstraints());
             gormMappingFactory.setDefaultMapping(settings.getDefault().getMapping());
+            gormMappingFactory.setDefaultNullable(settings.getDefault().isNullable());
         }
     }
 
diff --git a/grails-datastore-core/src/test/groovy/org/grails/datastore/mapping/keyvalue/mapping/KeyValueMappingFactoryTests.groovy b/grails-datastore-core/src/test/groovy/org/grails/datastore/mapping/keyvalue/mapping/KeyValueMappingFactoryTests.groovy
index 681898b1b9..ad013b9f94 100644
--- a/grails-datastore-core/src/test/groovy/org/grails/datastore/mapping/keyvalue/mapping/KeyValueMappingFactoryTests.groovy
+++ b/grails-datastore-core/src/test/groovy/org/grails/datastore/mapping/keyvalue/mapping/KeyValueMappingFactoryTests.groovy
@@ -67,7 +67,7 @@ class KeyValueMappingFactoryTests {
 
         PersistentProperty prop = entity.getPropertyByName('nonFormulaProperty')
         assert !prop.mapping.mappedForm.derived
-        assert !prop.mapping.mappedForm.nullable
+        assert prop.mapping.mappedForm.nullable
 
         // Formula properties should be flagged as derived
         prop = entity.getPropertyByName('formulaProperty')


(grails-core) 02/04: test: reset fixtures and UserIntegrationSpec assertions

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

matrei pushed a commit to branch fix/issue-16133
in repository https://gitbox.apache.org/repos/asf/grails-core.git

commit f07ddd11b72b1d26e61d78725ec65227165ce4b3
Author: Mattias Reichel <ma...@gmail.com>
AuthorDate: Thu Aug 13 17:07:04 2026 +0200

    test: reset fixtures and UserIntegrationSpec assertions
---
 .../grails-app/domain/grails/test/app/Address.groovy |  3 +++
 .../grails-app/domain/grails/test/app/User.groovy    |  3 ---
 .../grails/test/app/UserIntegrationSpec.groovy       | 20 ++++++++++++++++----
 .../main/groovy/grails/test/app/pogo/Profile.groovy  |  6 ++++++
 4 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/grails-test-examples/graphql/grails-test-app/grails-app/domain/grails/test/app/Address.groovy b/grails-test-examples/graphql/grails-test-app/grails-app/domain/grails/test/app/Address.groovy
index 98c769a502..b5c9ee73b0 100644
--- a/grails-test-examples/graphql/grails-test-app/grails-app/domain/grails/test/app/Address.groovy
+++ b/grails-test-examples/graphql/grails-test-app/grails-app/domain/grails/test/app/Address.groovy
@@ -26,5 +26,8 @@ class Address {
     Integer zip
 
     static constraints = {
+        city nullable: false
+        state nullable: false
+        zip nullable: false
     }
 }
diff --git a/grails-test-examples/graphql/grails-test-app/grails-app/domain/grails/test/app/User.groovy b/grails-test-examples/graphql/grails-test-app/grails-app/domain/grails/test/app/User.groovy
index 4baed680d7..375049925b 100644
--- a/grails-test-examples/graphql/grails-test-app/grails-app/domain/grails/test/app/User.groovy
+++ b/grails-test-examples/graphql/grails-test-app/grails-app/domain/grails/test/app/User.groovy
@@ -32,7 +32,6 @@ class User {
     Address address //embedded domain class
 
     static constraints = {
-        manager nullable: true
         profile nullable: false
         address nullable: false
     }
@@ -45,8 +44,6 @@ class User {
     }
 
     static graphql = GraphQLMapping.build {
-        property('profile', nullable: false)
-        property('address', nullable: false)
         add('firstNumber', Integer) {
             //don't include this property in the list of properties to return from operations
             output(false)
diff --git a/grails-test-examples/graphql/grails-test-app/src/integration-test/groovy/grails/test/app/UserIntegrationSpec.groovy b/grails-test-examples/graphql/grails-test-app/src/integration-test/groovy/grails/test/app/UserIntegrationSpec.groovy
index 3977e0f8bf..87f29c71a4 100644
--- a/grails-test-examples/graphql/grails-test-app/src/integration-test/groovy/grails/test/app/UserIntegrationSpec.groovy
+++ b/grails-test-examples/graphql/grails-test-app/src/integration-test/groovy/grails/test/app/UserIntegrationSpec.groovy
@@ -53,7 +53,10 @@ class UserIntegrationSpec extends Specification implements GraphQLSpec {
         Map obj = resp.body
 
         then:
-        obj.data.userCreate != null
+        obj.data == null
+        obj.errors.size() == 1
+        obj.errors[0].message.startsWith('Validation error (WrongType@[userCreate])')
+        obj.errors[0].message.endsWith("is missing required fields '[profile]'")
 
         when: 'The profile is provided, but missing a required field'
         resp = graphQL.graphql("""
@@ -78,7 +81,10 @@ class UserIntegrationSpec extends Specification implements GraphQLSpec {
         obj = resp.body
 
         then:
-        obj.data.userCreate != null
+        obj.data == null
+        obj.errors.size() == 1
+        obj.errors[0].message.startsWith('Validation error (WrongType@[userCreate])')
+        obj.errors[0].message.endsWith("is missing required fields '[lastName]'")
     }
 
     void "test creating a user without an address"() {
@@ -101,7 +107,10 @@ class UserIntegrationSpec extends Specification implements GraphQLSpec {
         Map obj = resp.body
 
         then:
-        obj.data.userCreate != null
+        obj.data == null
+        obj.errors.size() == 1
+        obj.errors[0].message.startsWith('Validation error (WrongType@[userCreate])')
+        obj.errors[0].message.endsWith("is missing required fields '[address]'")
 
         when: 'The address is provided, but missing a required field'
         resp = graphQL.graphql("""
@@ -126,7 +135,10 @@ class UserIntegrationSpec extends Specification implements GraphQLSpec {
         obj = resp.body
 
         then:
-        obj.data.userCreate != null
+        obj.data == null
+        obj.errors.size() == 1
+        obj.errors[0].message.startsWith('Validation error (WrongType@[userCreate])')
+        obj.errors[0].message.endsWith("is missing required fields '[zip]'")
     }
 
     void "test creating the top level manager"() {
diff --git a/grails-test-examples/graphql/grails-test-app/src/main/groovy/grails/test/app/pogo/Profile.groovy b/grails-test-examples/graphql/grails-test-app/src/main/groovy/grails/test/app/pogo/Profile.groovy
index 670472acdb..5c11b8963f 100644
--- a/grails-test-examples/graphql/grails-test-app/src/main/groovy/grails/test/app/pogo/Profile.groovy
+++ b/grails-test-examples/graphql/grails-test-app/src/main/groovy/grails/test/app/pogo/Profile.groovy
@@ -28,4 +28,10 @@ class Profile {
     String firstName
     String lastName
 
+    static constraints = {
+        email nullable: false
+        firstName nullable: false
+        lastName nullable: false
+    }
+
 }