From d9c06d1b5b20afed66e468360630b9cf418bb9a5 Mon Sep 17 00:00:00 2001 From: Scott Murphy Heiberg Date: Fri, 3 Oct 2025 20:05:38 -0700 Subject: [PATCH 1/4] Instant should persist the same way (BsonType.DATE_TIME) as LocalDateTime and Date --- .../bson/codecs/temporal/InstantBsonConverter.groovy | 6 +++--- .../bson/codecs/temporal/InstantBsonConverterSpec.groovy | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/grails-data-mongodb/bson/src/main/groovy/org/grails/datastore/bson/codecs/temporal/InstantBsonConverter.groovy b/grails-data-mongodb/bson/src/main/groovy/org/grails/datastore/bson/codecs/temporal/InstantBsonConverter.groovy index 120170b8689..8d13a83101f 100644 --- a/grails-data-mongodb/bson/src/main/groovy/org/grails/datastore/bson/codecs/temporal/InstantBsonConverter.groovy +++ b/grails-data-mongodb/bson/src/main/groovy/org/grails/datastore/bson/codecs/temporal/InstantBsonConverter.groovy @@ -39,17 +39,17 @@ trait InstantBsonConverter implements TemporalBsonConverter, InstantCon @Override void write(BsonWriter writer, Instant value) { - writer.writeInt64(convert(value)) + writer.writeDateTime(convert(value)) } @Override Instant read(BsonReader reader) { - convert(reader.readInt64()) + convert(reader.readDateTime()) } @Override BsonType bsonType() { - BsonType.INT64 + BsonType.DATE_TIME } } diff --git a/grails-data-mongodb/bson/src/test/groovy/org/grails/datastore/bson/codecs/temporal/InstantBsonConverterSpec.groovy b/grails-data-mongodb/bson/src/test/groovy/org/grails/datastore/bson/codecs/temporal/InstantBsonConverterSpec.groovy index 03c2305e552..e2d6ad72d24 100644 --- a/grails-data-mongodb/bson/src/test/groovy/org/grails/datastore/bson/codecs/temporal/InstantBsonConverterSpec.groovy +++ b/grails-data-mongodb/bson/src/test/groovy/org/grails/datastore/bson/codecs/temporal/InstantBsonConverterSpec.groovy @@ -38,7 +38,7 @@ class InstantBsonConverterSpec extends Specification implements InstantBsonConve void "test read"() { given: BsonReader bsonReader = Mock(BsonReader) { - 1 * readInt64() >> 100L + 1 * readDateTime() >> 100L } when: @@ -56,11 +56,11 @@ class InstantBsonConverterSpec extends Specification implements InstantBsonConve write(bsonWriter, instant) then: - 1 * bsonWriter.writeInt64(100L) + 1 * bsonWriter.writeDateTime(100L) } void "test bson type"() { expect: - bsonType() == BsonType.INT64 + bsonType() == BsonType.DATE_TIME } } \ No newline at end of file From e5d7890d96776027977e20c48dd15927f02be285 Mon Sep 17 00:00:00 2001 From: Scott Murphy Heiberg Date: Mon, 6 Oct 2025 13:24:26 -0700 Subject: [PATCH 2/4] Document Instant persistence change for mongodb --- UPGRADE7.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/UPGRADE7.md b/UPGRADE7.md index c628675b433..c12b044a199 100644 --- a/UPGRADE7.md +++ b/UPGRADE7.md @@ -43,6 +43,15 @@ Experienced while upgrading modules for Grails 7 } } +## Mongo DB +- `Instant` persistence switched from epoch milliseconds (BSON int64) to BSON DateTime (same BSON type as `java.util.Date`); `LocalDateTime` continues to be converted to BSON DateTime using the configured zone. If you currently using domain objects with property type `Instant`, you will need to convert them prior to upgrading. For more info, see [#1511](https://github.com/apache/grails-core/pull/15111) + +``` +db.Example.updateMany( + { created: { $type: "long" } }, + [ { $set: { created: { $toDate: "$created" } } } ] +); +``` ## NOTE: This document is a draft and the explanations are only highlights and will be expanded further prior to release of 7.0. From ebfa112482cbe7f5a84ae68baf9d184e08abd9a4 Mon Sep 17 00:00:00 2001 From: Scott Murphy Heiberg Date: Tue, 7 Oct 2025 11:40:05 -0700 Subject: [PATCH 3/4] Add Instant mongodb upgrade conversion instructions --- grails-doc/src/en/guide/upgrading/upgrading60x.adoc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/grails-doc/src/en/guide/upgrading/upgrading60x.adoc b/grails-doc/src/en/guide/upgrading/upgrading60x.adoc index caad00836e5..ee21d8daf0b 100644 --- a/grails-doc/src/en/guide/upgrading/upgrading60x.adoc +++ b/grails-doc/src/en/guide/upgrading/upgrading60x.adoc @@ -557,4 +557,16 @@ tasks.withType(Test).configureEach { tasks.withType(JavaExec).configureEach { jvmArgs('-XX:+TieredCompilation', '-XX:TieredStopAtLevel=1', '-XX:CICompilerCount=3') } +---- + +===== 12.24 MongoDB + +`Instant` persistence switched from epoch milliseconds (BSON int64) to BSON DateTime (same BSON type as `java.util.Date`); `LocalDateTime` continues to be converted to BSON DateTime using the configured zone. If you currently using domain objects with property type `Instant`, you will need to convert them prior to upgrading. For more info, see https://github.com/apache/grails-core/pull/15111[#15111]. + +[source,javascript] +---- +db.Example.updateMany( + { created: { $type: "long" } }, + [ { $set: { created: { $toDate: "$created" } } } ] +); ---- \ No newline at end of file From 76edcd227e4b2349935b25818f190f872de018d6 Mon Sep 17 00:00:00 2001 From: Scott Murphy Heiberg Date: Tue, 7 Oct 2025 12:53:34 -0700 Subject: [PATCH 4/4] Remove mongo db upgrade path --- UPGRADE7.md | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/UPGRADE7.md b/UPGRADE7.md index c12b044a199..b60513c24b2 100644 --- a/UPGRADE7.md +++ b/UPGRADE7.md @@ -43,19 +43,10 @@ Experienced while upgrading modules for Grails 7 } } -## Mongo DB -- `Instant` persistence switched from epoch milliseconds (BSON int64) to BSON DateTime (same BSON type as `java.util.Date`); `LocalDateTime` continues to be converted to BSON DateTime using the configured zone. If you currently using domain objects with property type `Instant`, you will need to convert them prior to upgrading. For more info, see [#1511](https://github.com/apache/grails-core/pull/15111) - -``` -db.Example.updateMany( - { created: { $type: "long" } }, - [ { $set: { created: { $toDate: "$created" } } } ] -); -``` ## NOTE: This document is a draft and the explanations are only highlights and will be expanded further prior to release of 7.0. ### Cool New Features - Hello Exterminator, Good by bugs! Lot's of things started working... and working well! For instance, use of controller namespaces now work seemlessly. - Massive decoupling of dependencies and cleanup between modules. -- Works with Spring Security 6 out of the box. No plugin needed! +- Works with Spring Security 6 out of the box. No plugin needed! \ No newline at end of file