Skip to content

Commit 41a9f53

Browse files
KSH-codemp911de
authored andcommitted
Add sort to query debug logging.
Closes #4686 Original pull request: #4679
1 parent d19b978 commit 41a9f53

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoTemplate.java

+6-4
Original file line numberDiff line numberDiff line change
@@ -2551,10 +2551,11 @@ protected <S, T> List<T> doFind(String collectionName,
25512551
QueryContext queryContext = queryOperations.createQueryContext(new BasicQuery(query, fields));
25522552
Document mappedFields = queryContext.getMappedFields(entity, EntityProjection.nonProjecting(entityClass));
25532553
Document mappedQuery = queryContext.getMappedQuery(entity);
2554+
Document mappedSort = getMappedSortObject(query, entityClass);
25542555

25552556
if (LOGGER.isDebugEnabled()) {
2556-
LOGGER.debug(String.format("find using query: %s fields: %s for class: %s in collection: %s",
2557-
serializeToJsonSafely(mappedQuery), mappedFields, entityClass, collectionName));
2557+
LOGGER.debug(String.format("find using query: %s fields: %s sort: %s for class: %s in collection: %s",
2558+
serializeToJsonSafely(mappedQuery), mappedSort, mappedFields, entityClass, collectionName));
25582559
}
25592560

25602561
return executeFindMultiInternal(new FindCallback(collectionPreparer, mappedQuery, mappedFields, null),
@@ -2576,10 +2577,11 @@ <S, T> List<T> doFind(CollectionPreparer<MongoCollection<Document>> collectionPr
25762577
QueryContext queryContext = queryOperations.createQueryContext(new BasicQuery(query, fields));
25772578
Document mappedFields = queryContext.getMappedFields(entity, projection);
25782579
Document mappedQuery = queryContext.getMappedQuery(entity);
2580+
Document mappedSort = getMappedSortObject(query, sourceClass);
25792581

25802582
if (LOGGER.isDebugEnabled()) {
2581-
LOGGER.debug(String.format("find using query: %s fields: %s for class: %s in collection: %s",
2582-
serializeToJsonSafely(mappedQuery), mappedFields, sourceClass, collectionName));
2583+
LOGGER.debug(String.format("find using query: %s fields: %s sort: %s for class: %s in collection: %s",
2584+
serializeToJsonSafely(mappedQuery), mappedSort, mappedFields, sourceClass, collectionName));
25832585
}
25842586

25852587
return executeFindMultiInternal(new FindCallback(collectionPreparer, mappedQuery, mappedFields, null), preparer,

0 commit comments

Comments
 (0)