GH-3121 Throw PropertyReferenceException for whitespace-starting Prop…#3321
GH-3121 Throw PropertyReferenceException for whitespace-starting Prop…#3321mipo256 wants to merge 1 commit intospring-projects:mainfrom
Conversation
…e-starting PropertyPath Signed-off-by: mipo256 <mikhailpolivakha@gmail.com>
|
I'll add the Integration test for mongodb to make sure that this case works |
|
One issue is that MongoDB uses an abstraction that isn't fully applicable to how MongoDB represents paths. Accepting property paths that start with a whitespace is indeed odd, and we should look forward to reject these unless there's a good reason to keep them. Java properties cannot start with a whitespace, however, other JVM languages can create method names containing whitespace. |
I agree. I think the separate issue can be created for this in Spring Data MongoDB to think about the design around it. Since
Well, yeah, that is true and it is a valid concern. Just my 2 cents 😄 : If Spring Data decide to consider the whitespace starting paths in general, that means we need to differentiate between hypothetical Apart from that, it seems that the Kotlin Language, the one that is most often used apart from Java with Spring applications, does not permit the identifier to start with whitespace, see specification: So, my humble opinion is that it is not worth it to consider the paths that start with a whitespace. But I might be wrong. CC: @odrotbohm @mp911de |
646e077 to
6ac5cf8
Compare
Closes #3121
So, actually, the situation that is described in the original ticket is quite flawed in many ways.
My basic assumption is that
PropertyPathcannot hold whitespace holding properties. Now, the way it works withproperties. keyas the PropertyPath in spring data mongodb - it actually don't, we still were unable to parse thePropertyPath, but we handed the exception - thePropertyReferenceException.The mongodb can handles property references like
properties. key, so the spring-data-mongodb just passed it literally asand the mongodb engine would figure it out.
Therefore, I think, that the only correct fix that can be applied here is to just throw a correct exception, which is
PropertyReferenceException. Theproperties. keyandproperties. Keyshould not be considered validPropertyPathinstances.CC: @christophstrobl @mp911de