diff --git a/UPGRADE7.md b/UPGRADE7.md index c628675b433..b60513c24b2 100644 --- a/UPGRADE7.md +++ b/UPGRADE7.md @@ -49,4 +49,4 @@ Experienced while upgrading modules for Grails 7 ### 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 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 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