@ -239,14 +239,16 @@ 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 ( context . getExpressionMarker ( ) , 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 ( context . getExpressionMarker ( ) , 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 ( ) ) ;
}
}
@ -312,13 +314,11 @@ class QueryBlocks {
} else {
} else {
if ( getQueryParameters ( ) . isEmpty ( ) ) {
if ( getQueryParameters ( ) . isEmpty ( ) ) {
builder . addStatement (
builder . addStatement ( "$L.collation(collationOf(evaluate($L, $S)))" , queryVariableName ,
"$L.collation(collationOf(evaluate($L, $S)))" ,
context . getExpressionMarker ( ) . enclosingMethod ( ) , collationString ) ;
queryVariableName , context . getExpressionMarker ( ) . enclosingMethod ( ) , collationString ) ;
} else {
} else {
builder . addStatement (
builder . addStatement ( "$L.collation(collationOf(evaluate($L, $S, $L)))" , queryVariableName ,
"$L.collation(collationOf(evaluate($L, $S, $L)))" ,
context . getExpressionMarker ( ) . enclosingMethod ( ) , collationString , getQueryParameters ( ) ) ;
queryVariableName , context . getExpressionMarker ( ) . enclosingMethod ( ) , collationString , getQueryParameters ( ) ) ;
}
}
}
}
}
}
@ -346,7 +346,8 @@ class QueryBlocks {
if ( getQueryParameters ( ) . isEmpty ( ) ) {
if ( getQueryParameters ( ) . isEmpty ( ) ) {
builder . add ( "createQuery($L, $S)" , context . getExpressionMarker ( ) . enclosingMethod ( ) , source ) ;
builder . add ( "createQuery($L, $S)" , context . getExpressionMarker ( ) . enclosingMethod ( ) , source ) ;
} else {
} else {
builder . add ( "createQuery($L, $S, $L)" , context . getExpressionMarker ( ) . enclosingMethod ( ) , source , getQueryParameters ( ) ) ;
builder . add ( "createQuery($L, $S, $L)" , context . getExpressionMarker ( ) . enclosingMethod ( ) , source ,
getQueryParameters ( ) ) ;
}
}
return builder . build ( ) ;
return builder . build ( ) ;
} else {
} else {