You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@grails.apache.org by ja...@apache.org on 2026/06/17 15:19:28 UTC

(grails-core) 01/01: Merge remote-tracking branch 'origin/8.0.x' into grails8-groovy5-sb4

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

jamesfredley pushed a commit to branch grails8-groovy5-sb4
in repository https://gitbox.apache.org/repos/asf/grails-core.git

commit 29f5aa8ee5f3adbdf9382e2c0ccb33044cde4572
Merge: 5fc96aee06 2657f33509
Author: James Fredley <ja...@users.noreply.github.com>
AuthorDate: Wed Jun 17 11:17:04 2026 -0400

    Merge remote-tracking branch 'origin/8.0.x' into grails8-groovy5-sb4
    
    # Conflicts:
    #       grails-doc/src/en/guide/upgrading/upgrading80x.adoc

 .../src/main/groovy/grails/config/Settings.groovy  |   5 +
 .../grails/validation/ConstraintEvalUtils.groovy   |   8 ++
 .../META-INF/spring-configuration-metadata.json    |   6 +
 .../SaveWithExistingValidationErrorSpec.groovy     |   1 +
 .../grails/gorm/tests/entities/Contract.groovy     |   4 +
 .../tests/validation/CascadeValidationSpec.groovy  |   3 +
 .../test/mixin/hibernate/HibernateSpecSpec.groovy  |   2 +-
 .../SaveWithExistingValidationErrorSpec.groovy     |   1 +
 .../grails/gorm/tests/entities/Contract.groovy     |   4 +
 .../tests/validation/CascadeValidationSpec.groovy  |   3 +
 .../test/mixin/hibernate/HibernateSpecSpec.groovy  |   2 +-
 .../src/test/groovy/grails/gorm/tests/Plant.groovy |   4 +
 .../MongoDbDataStoreSpringInitializerSpec.groovy   |   2 +-
 .../gorm/mongo/FindOrCreateWhereSpec.groovy        |   1 +
 .../grails/gorm/tests/CircularCascadeSpec.groovy   |   8 ++
 .../domains/ClassWithListArgBeforeValidate.groovy  |   2 +-
 .../domains/ClassWithNoArgBeforeValidate.groovy    |   2 +-
 .../ClassWithOverloadedBeforeValidate.groovy       |   2 +-
 .../eval/DefaultConstraintEvaluator.java           |  15 ++-
 .../registry/DefaultValidatorRegistry.groovy       |   3 +-
 .../gorm/validation/NullableByDefaultSpec.groovy   | 121 +++++++++++++++++++++
 .../PersistentEntityValidatorSpec.groovy           |   2 +
 .../connections/ConnectionSourceSettings.groovy    |   6 +
 .../src/en/guide/upgrading/upgrading80x.adoc       |  50 ++++++++-
 .../src/en/guide/validation/constraints.adoc       |   2 +-
 grails-doc/src/en/ref/Constraints/nullable.adoc    |  21 +++-
 .../DefaultConstraintEvaluatorFactoryBean.groovy   |   4 +-
 .../grails/plugin/formfields/mock/Author.groovy    |   2 +-
 .../grails/plugin/formfields/mock/Person.groovy    |   5 +-
 .../EntityValidatorDomainPropertySpec.groovy       |   2 +
 grails-forge/grails-forge-web-netty/build.gradle   |   4 +-
 .../grails/web/taglib/ValidationTagLibSpec.groovy  |   7 ++
 .../app1/grails-app/conf/application.yml           |   6 +
 .../grails-app/domain/functionaltests/Book.groovy  |   1 +
 .../demo33/grails-app/domain/demo/Car.groovy       |   1 +
 .../gorm/grails-app/conf/application.yml           |   3 +
 .../grails-app/domain/functional/tests/Book.groovy |   2 +-
 .../domain/functional/tests/Business.groovy        |   3 +
 .../grails-app/conf/application.yml                |   8 +-
 .../grails-app/domain/functional/tests/Book.groovy |   2 +-
 .../domain/functional/tests/Business.groovy        |   3 +
 .../grails-app/conf/application.yml                |   8 +-
 .../grails-app/conf/application.yml                |   6 +
 .../mongodb/base/grails-app/conf/application.yml   |   6 +
 .../grails-app/conf/application.yml                |   6 +
 .../scaffolding/grails-app/conf/application.yml    |   6 +
 .../grails-app/conf/application.yml                |   6 +
 .../mixin/CascadeValidationForEmbeddedSpec.groovy  |   2 +-
 .../mixin/DomainClassDeepValidationSpec.groovy     |   4 +-
 .../mixin/RestfulControllerSubclassSpec.groovy     |   4 +
 .../test/mixin/cascade/CascadeCircularSpec.groovy  |   1 +
 .../validation/DomainConstraintGettersSpec.groovy  |  11 ++
 .../grails/web/metaclass/ChainMethodTests.groovy   |   4 +
 .../web/servlet/FlashScopeWithErrorsTests.groovy   |   4 +
 .../grails/rest/web/RespondMethodSpec.groovy       |   2 +-
 .../web/converters/JSONConverterTests.groovy       |   5 +
 .../plugin/json/view/JsonViewHelperSpec.groovy     |   4 +
 57 files changed, 387 insertions(+), 25 deletions(-)

diff --cc grails-doc/src/en/guide/upgrading/upgrading80x.adoc
index 6d6b7cd53b,628b92cac7..7492aff0ff
--- a/grails-doc/src/en/guide/upgrading/upgrading80x.adoc
+++ b/grails-doc/src/en/guide/upgrading/upgrading80x.adoc
@@@ -965,44 -965,46 +965,88 @@@ Previously, rendering an enum value wou
  Rendering an enum value as JSON will now instead throw a `ConverterException`.
  See https://github.com/apache/grails-core/pull/15212[PR 15212] for more details on this change.
  
- ==== 24. Apache Groovy 5 Behavior Changes
+ ==== 26. GORM Properties Are Nullable by Default
+ 
+ Grails 8 changes the validation default so that an *unconstrained persistent (domain) property is nullable by default* rather than required.
+ This aligns Grails with the rest of the JVM persistence/validation ecosystem (JPA/Hibernate, Spring Data, Micronaut Data and Jakarta Bean Validation), all of which treat an unconstrained property as valid when `null`.
+ 
+ Previously every domain property without an explicit constraint had an implicit `nullable: false` applied, so `save()` failed validation when the property was `null`.
+ From Grails 8 such a property is optional unless you declare otherwise:
+ 
+ [source,groovy]
+ ----
+ class Book {
+     String title    // Grails 7: required, Grails 8: nullable
+ 
+     static constraints = {
+         title nullable: false   // declare explicitly to keep it required
+     }
+ }
+ ----
+ 
+ This is a *validation-layer* change only.
+ Column/DDL nullability is governed separately by the mapping layer and is unaffected.
+ Command objects are also unaffected: `Validateable` command-object fields remain required by default.
+ 
+ To restore the legacy required-by-default behaviour for an entire application, set the new `grails.gorm.default.nullable` property to `false`:
+ 
+ [source,yaml]
+ .application.yml
+ ----
+ grails:
+     gorm:
+         default:
+             nullable: false
+ ----
+ 
+ The existing `grails.gorm.default.constraints` wildcard form also works:
+ 
+ [source,groovy]
+ .application.groovy
+ ----
+ grails.gorm.default.constraints = {
+     '*'(nullable: false)
+ }
+ ----
++
++==== 27. Apache Groovy 5 Behavior Changes
 +
 +Grails 8 upgrades from Apache Groovy 4 to Apache Groovy 5.
 +Most applications need no changes, but a few stricter behaviors can affect application code.
 +
- ===== 24.1 Assigning a static field from a static closure requires the class name
++===== 27.1 Assigning a static field from a static closure requires the class name
 +
 +Under Groovy 5 with static compilation (`@CompileStatic` / `@GrailsCompileStatic`), assigning to a static field from inside a static closure - such as the `constraints`, `mapping`, or `namedQueries` blocks of a statically compiled class - no longer resolves an unqualified field name to the enclosing class's static field.
 +Qualify the assignment with the class name:
 +
 +[source,groovy]
 +----
 +@GrailsCompileStatic
 +class Book implements Validateable {
 +    static boolean constraintsClosureCalled = false
 +
 +    static constraints = {
 +        // Groovy 4: an unqualified assignment resolved to Book.constraintsClosureCalled
 +        // Groovy 5: the field must be qualified with the class name
 +        Book.constraintsClosureCalled = true
 +    }
 +}
 +----
 +
 +Reading a static field is unaffected; only assignment from within the static closure needs the class-name qualifier.
 +
- ===== 24.2 Probing a `ConfigObject` for a missing key
++===== 27.2 Probing a `ConfigObject` for a missing key
 +
 +In Groovy 5, indexing a `groovy.util.ConfigObject` with the subscript operator for a key that does not exist creates and inserts an empty nested `ConfigObject` for that key, rather than reading back as a falsy value.
 +Code that walks a configuration source with `[]` and expects a missing key to be `null` should test for the key explicitly before reading it:
 +
 +[source,groovy]
 +----
 +// Under Groovy 5 this inserts an empty entry for a missing key
 +def value = configObject[key]
 +
 +// Probe without creating an entry
 +def value = configObject.containsKey(key) ? configObject.get(key) : null
 +----
 +
 +Grails applies this guard internally when resolving Spring profile activation keys; you only need it in application code that navigates a raw `ConfigObject` by subscript.