Provides support to increase developer productivity in Java when using MongoDB. Uses familiar Spring concepts such as a template classes for core API usage and lightweight repository style data access.
BindableMongoExpression#wrapJsonIfNecessary detects if the input expression already contains the opening and closing braces, and if not they are added. This is useful for one-liners, but it doesn't work as well in other situations.
When using text blocks, it is common to put the closing delimiter on a new line (see the examples in JEP 378 and varioustests in this repository), which means the last character of the string will be a line terminator. BindableMongoExpression checks only the last character for }, and if it doesn't match the whole expression is wrapped as { + json + }.
Thank you for bringing this to our attention. If you have time to work on a PR we're happy to help with that. Please make sure to follow our Contribution Guidelines.
BindableMongoExpression#wrapJsonIfNecessary detects if the input expression already contains the opening and closing braces, and if not they are added. This is useful for one-liners, but it doesn't work as well in other situations.
When using text blocks, it is common to put the closing delimiter on a new line (see the examples in JEP 378 and various tests in this repository), which means the last character of the string will be a line terminator. BindableMongoExpression checks only the last character for
}
, and if it doesn't match the whole expression is wrapped as{
+ json +}
.This results in the following:
to be parsed as:
which is obviously not a valid json. Trimming could be applied to the input expression to avoid this problem.
If the issue is accepted, I can submit a PR.