Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider null value settings for types with custom conversion #4728

Closed
wants to merge 5 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Polishing.
  • Loading branch information
mp911de committed Aug 28, 2024

Verified

This commit was signed with the committer’s verified signature.
ssbarnea Sorin Sbarnea
commit 67b1c759c2efa5c622aa9afe1bb2ca1bb9736623
Original file line number Diff line number Diff line change
@@ -280,6 +280,7 @@ public void setCodecRegistryProvider(@Nullable CodecRegistryProvider codecRegist
this.codecRegistryProvider = codecRegistryProvider;
}

@Override
public MappingContext<? extends MongoPersistentEntity<?>, MongoPersistentProperty> getMappingContext() {
return mappingContext;
}
@@ -432,6 +433,7 @@ public Map<String, Object> getBean() {
}
}

@Override
public <S extends Object> S read(Class<S> clazz, Bson bson) {
return read(TypeInformation.of(clazz), bson);
}
@@ -729,6 +731,7 @@ private Object readUnwrapped(ConversionContext context, DocumentAccessor documen
return null;
}

@Override
public DBRef toDBRef(Object object, @Nullable MongoPersistentProperty referringProperty) {

org.springframework.data.mongodb.core.mapping.DBRef annotation;
@@ -795,6 +798,7 @@ DocumentPointer<?> createDocumentPointer(Object source, @Nullable MongoPersisten
*
* @see org.springframework.data.mongodb.core.convert.MongoWriter#write(java.lang.Object, java.lang.Object)
*/
@Override
public void write(Object obj, Bson bson) {

if (null == obj) {
@@ -933,6 +937,7 @@ private void writeAssociation(Association<MongoPersistentProperty> association,
writePropertyInternal(value, dbObjectAccessor, inverseProp, accessor);
}

// TODO: Documentaccessor is package-private
@SuppressWarnings({ "unchecked" })
protected void writePropertyInternal(@Nullable Object obj, DocumentAccessor accessor, MongoPersistentProperty prop,
PersistentPropertyAccessor<?> persistentPropertyAccessor) {
@@ -1610,7 +1615,7 @@ public Object convertToMongoType(@Nullable Object obj, @Nullable TypeInformation
}

@Override
public Object convertToMongoType(@Nullable Object obj, MongoPersistentEntity entity) {
public Object convertToMongoType(@Nullable Object obj, MongoPersistentEntity<?> entity) {
Document newDocument = new Document();
writeInternal(obj, newDocument, entity);
return newDocument;
@@ -1948,6 +1953,7 @@ static class MongoDbPropertyValueProvider implements PropertyValueProvider<Mongo
this.spELContext = spELContext;
}

@Override
@Nullable
@SuppressWarnings("unchecked")
public <T> T getPropertyValue(MongoPersistentProperty property) {
@@ -2261,6 +2267,7 @@ default <S> S findContextualEntity(MongoPersistentEntity<S> entity, Document doc
return null;
}

// TODO: ObjectPath is package-private
ObjectPath getPath();

CustomConversions getCustomConversions();
@@ -2421,6 +2428,7 @@ public ConversionContext withPath(ObjectPath currentPath) {
collectionConverter, mapConverter, dbRefConverter, elementConverter);
}

// TODO: ObjectPath is package-private
@Override
public ObjectPath getPath() {
return path;