Browse Source

Polishing.

Original Pull Request: #4822
4.4.x
Christoph Strobl 1 year ago
parent
commit
101481737b
No known key found for this signature in database
GPG Key ID: E6054036D0C37A4B
  1. 7
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/BindableMongoExpression.java

7
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/BindableMongoExpression.java

@ -81,7 +81,7 @@ public class BindableMongoExpression implements MongoExpression {
Assert.notNull(expression, "Expression must not be null"); Assert.notNull(expression, "Expression must not be null");
this.expressionString = expression.trim(); this.expressionString = expression;
this.codecRegistryProvider = codecRegistryProvider; this.codecRegistryProvider = codecRegistryProvider;
this.args = args; this.args = args;
this.target = Lazy.of(this::parse); this.target = Lazy.of(this::parse);
@ -139,10 +139,11 @@ public class BindableMongoExpression implements MongoExpression {
private static String wrapJsonIfNecessary(String json) { private static String wrapJsonIfNecessary(String json) {
if (StringUtils.hasText(json) && (json.startsWith("{") && json.endsWith("}"))) { if(!StringUtils.hasText(json)) {
return json; return json;
} }
return "{" + json + "}"; String raw = json.trim();
return (raw.startsWith("{") && raw.endsWith("}")) ? raw : "{%s}".formatted(raw);
} }
} }

Loading…
Cancel
Save