Skip to content

Commit

Permalink
Polishing.
Browse files Browse the repository at this point in the history
Original Pull Request: #4822
  • Loading branch information
christophstrobl committed Jan 16, 2025
1 parent 486bf84 commit 1014817
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public BindableMongoExpression(String expression, @Nullable CodecRegistryProvide

Assert.notNull(expression, "Expression must not be null");

this.expressionString = expression.trim();
this.expressionString = expression;
this.codecRegistryProvider = codecRegistryProvider;
this.args = args;
this.target = Lazy.of(this::parse);
Expand Down Expand Up @@ -139,10 +139,11 @@ private Document parse() {

private static String wrapJsonIfNecessary(String json) {

if (StringUtils.hasText(json) && (json.startsWith("{") && json.endsWith("}"))) {
if(!StringUtils.hasText(json)) {
return json;
}

return "{" + json + "}";
String raw = json.trim();
return (raw.startsWith("{") && raw.endsWith("}")) ? raw : "{%s}".formatted(raw);
}
}

0 comments on commit 1014817

Please sign in to comment.