The GitHub Actions job "Code Style" on 
grails-core.git/feat/mongo-objectid-default-8.0.x has failed.
Run started by GitHub user codeconsole (triggered by codeconsole).

Head commit for run:
a81e0d5ca0d3a4413730e309570405ad5b17fd93 / Scott Murphy Heiberg 
<[email protected]>
Default String id storage to ObjectId and fix association id coercion

Make `grails.mongodb.stringIds.defaultStoredAs` default to `objectid`, so a
domain declaring `String id` persists `_id` as a BSON ObjectId while keeping
String ergonomics in application code. Set it to `string` to opt out.

The default is applied via the field initializer rather than only in the
config-reading constructors, so all four MongoMappingContext constructors
register entities with the same default.

Making it the default surfaced five latent defects in the storedAs path, all
of which reproduce today by setting defaultStoredAs: objectid explicitly:

- ToOneEncoder and OneToManyEncoder wrote association references using the
  declared id type, so a reference pointed at an ObjectId _id with a BSON
  String and matched nothing from $lookup or the raw driver.
- ToOneDecoder read by the predicted type and threw
  BsonInvalidOperationException on documents whose stored type legitimately
  differs (a non-hex assigned id falls back to BSON String even under
  storedAs: ObjectId). It now reads the actual BSON type.
- OneToManyDecoder returned stored-type ids rather than the declared type.
- MongoQuery coerced only identity criteria, so a filter on a to-one
  association sent a hex String against an ObjectId foreign key; bidirectional
  one-to-many and hasOne lookups silently resolved to empty.
- MongoQuery also missed findAllById(hex), which builds Equals('id', ..)
  rather than IdEquals and so bypassed id coercion entirely, returning no
  results. findAllByIdInList was unaffected because the In handler covers it.

Report URL: https://github.com/apache/grails-core/actions/runs/33681165252

With regards,
GitHub Actions via GitBox

Reply via email to