Open boly38 opened 2 months ago
Thank you @boly38 for getting in touch. Spring Data MongoDB is mainly operating upon the java domain model and does not necessarily have the same behaviour as when using the Mongo Shell. That being said, PropertyPath
is used as an abstraction to navigate within the domain model. Therefore it is not tied to any MongoDB specifics.
The different behaviour is due to how the path is split into parts using camel case detection.
From what I understand is that you are storing data in MongoDB, using keys that contain leading whitespaces like the following right?
{
"_id": "...",
"name": "docA",
"properties": {
" Major": "blob"
}
}
I think we'll have to deal with this issue both here (path resolution) and in data-mongo (handling of fields containing whitespaces).
Hi here 👋 ,
What is the issue ?
On my project I want to update a given MongoDB document having
properties
map as subdocument.I'm using
org.springframework.data:spring-data-commons:jar:3.1.11
(and spring data mongodb 4.1.11) .I encounter
IllegalArgumentException: Name must not be null or empty
fromPropertyPath.java:82
while trying to patch a given documentproperties
.Context - How to reproduce ?
ℹ️ A usecase - I encounter no issue to set / unset a property having " " space in the beginning of a property key value with a word starting with lowercase; example :
ℹ️ B usecase - BUT now if I'm doing the same thing with a word starting with an uppercase, I encounter an issue :
stack extract
Further analysis
By debugging some test with different value, I can state that
spring-data-commons
>PropertyPath
component is processing some part of the update query and will see some field following spring data internal logic :ooo
is detected under propertiesP
and` are detected under properties, and as
` is empty, the assert exception (l82) throws an exception.With mongo Shell, I'm trying to reproduce but no issue, all is fine (usecase B too)
What did I expect
I expect the update to work like on mongo shell.
I though this is a bug at the PropertyPath layer (but not sure) Or maybe in spring data mongodb?
If this is stated as "not a bug", I would like to know the recommendation for this kind of update for the "key" value.
Example (mongo manual):
class
and_class
,.
is not autorized$
is not autorized as first character I appreciate some reference to complete this, if anyregards.