|
|
|
@ -238,14 +238,14 @@ class QueryBlocks { |
|
|
|
if (StringUtils.hasText(source.getQuery().getFieldsString())) { |
|
|
|
if (StringUtils.hasText(source.getQuery().getFieldsString())) { |
|
|
|
|
|
|
|
|
|
|
|
VariableSnippet fields = Snippet.declare(builder).variable(Document.class, context.localVariable("fields")) |
|
|
|
VariableSnippet fields = Snippet.declare(builder).variable(Document.class, context.localVariable("fields")) |
|
|
|
.of(MongoCodeBlocks.asDocument(source.getQuery().getFieldsString(), queryParameters.get())); |
|
|
|
.of(MongoCodeBlocks.asDocument(context.getExpressionMarker(), source.getQuery().getFieldsString(), queryParameters.get())); |
|
|
|
builder.addStatement("$L.setFieldsObject($L)", queryVariableName, fields.getVariableName()); |
|
|
|
builder.addStatement("$L.setFieldsObject($L)", queryVariableName, fields.getVariableName()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (StringUtils.hasText(source.getQuery().getSortString())) { |
|
|
|
if (StringUtils.hasText(source.getQuery().getSortString())) { |
|
|
|
|
|
|
|
|
|
|
|
VariableSnippet sort = Snippet.declare(builder).variable(Document.class, context.localVariable("sort")) |
|
|
|
VariableSnippet sort = Snippet.declare(builder).variable(Document.class, context.localVariable("sort")) |
|
|
|
.of(MongoCodeBlocks.asDocument(source.getQuery().getSortString(), getQueryParameters())); |
|
|
|
.of(MongoCodeBlocks.asDocument(context.getExpressionMarker(), source.getQuery().getSortString(), getQueryParameters())); |
|
|
|
builder.addStatement("$L.setSortObject($L)", queryVariableName, sort.getVariableName()); |
|
|
|
builder.addStatement("$L.setSortObject($L)", queryVariableName, sort.getVariableName()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -306,12 +306,12 @@ class QueryBlocks { |
|
|
|
|
|
|
|
|
|
|
|
if (getQueryParameters().isEmpty()) { |
|
|
|
if (getQueryParameters().isEmpty()) { |
|
|
|
builder.addStatement( |
|
|
|
builder.addStatement( |
|
|
|
"$L.collation(collationOf(evaluate(ExpressionMarker.class.getEnclosingMethod(), $S)))", |
|
|
|
"$L.collation(collationOf(evaluate($L, $S)))", |
|
|
|
queryVariableName, collationString); |
|
|
|
queryVariableName, context.getExpressionMarker().enclosingMethod(), collationString); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
builder.addStatement( |
|
|
|
builder.addStatement( |
|
|
|
"$L.collation(collationOf(evaluate(ExpressionMarker.class.getEnclosingMethod(), $S, $L)))", |
|
|
|
"$L.collation(collationOf(evaluate($L, $S, $L)))", |
|
|
|
queryVariableName, collationString, getQueryParameters()); |
|
|
|
queryVariableName, context.getExpressionMarker().enclosingMethod(), collationString, getQueryParameters()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -337,9 +337,9 @@ class QueryBlocks { |
|
|
|
} else if (MongoCodeBlocks.containsPlaceholder(source)) { |
|
|
|
} else if (MongoCodeBlocks.containsPlaceholder(source)) { |
|
|
|
Builder builder = CodeBlock.builder(); |
|
|
|
Builder builder = CodeBlock.builder(); |
|
|
|
if (getQueryParameters().isEmpty()) { |
|
|
|
if (getQueryParameters().isEmpty()) { |
|
|
|
builder.add("createQuery(ExpressionMarker.class.getEnclosingMethod(), $S)", source); |
|
|
|
builder.add("createQuery($L, $S)", context.getExpressionMarker().enclosingMethod(), source); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
builder.add("createQuery(ExpressionMarker.class.getEnclosingMethod(), $S, $L)", source, getQueryParameters()); |
|
|
|
builder.add("createQuery($L, $S, $L)", context.getExpressionMarker().enclosingMethod(), source, getQueryParameters()); |
|
|
|
} |
|
|
|
} |
|
|
|
return builder.build(); |
|
|
|
return builder.build(); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|