diff options
Diffstat (limited to 'sonar-db')
-rw-r--r-- | sonar-db/src/main/java/org/sonar/db/component/ComponentTreeQuery.java | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/sonar-db/src/main/java/org/sonar/db/component/ComponentTreeQuery.java b/sonar-db/src/main/java/org/sonar/db/component/ComponentTreeQuery.java index 749c21e3aff..7fe84cd77c1 100644 --- a/sonar-db/src/main/java/org/sonar/db/component/ComponentTreeQuery.java +++ b/sonar-db/src/main/java/org/sonar/db/component/ComponentTreeQuery.java @@ -54,7 +54,7 @@ public class ComponentTreeQuery { this.page = builder.page; this.pageSize = builder.pageSize; this.baseSnapshot = builder.baseSnapshot; - this.baseSnapshotPath = buildLikeValue(baseSnapshot.getPath() + baseSnapshot.getId() + ".", WildcardPosition.AFTER); + this.baseSnapshotPath = buildBaseSnapshotPath(baseSnapshot); this.direction = builder.asc ? "ASC" : "DESC"; this.sqlSort = sortFieldsToSqlSort(builder.sortFields, direction); } @@ -112,6 +112,11 @@ public class ComponentTreeQuery { return Joiner.on(", ").join(sqlSortFields); } + private String buildBaseSnapshotPath(SnapshotDto baseSnapshot) { + String existingSnapshotPath = baseSnapshot.getPath() == null ? "" : baseSnapshot.getPath(); + return buildLikeValue(existingSnapshotPath + baseSnapshot.getId() + ".", WildcardPosition.AFTER); + } + public static class Builder { @CheckForNull private String nameOrKeyQuery; |