Skip to content

Commit

Permalink
Changed SQL storage query from findLast to findFirst with a order by …
Browse files Browse the repository at this point in the history
…desc. Fixes #2361 (#2363)
  • Loading branch information
EricWittmann authored Mar 23, 2022
1 parent e726f6c commit d2b9b9c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1281,7 +1281,7 @@ public ArtifactVersionMetaDataDto getArtifactVersionMetaData(String groupId, Str
.bind(2, artifactId)
.bind(3, hash)
.map(ArtifactVersionMetaDataDtoMapper.instance)
.findLast();
.findFirst();
return res.orElseThrow(() -> new ArtifactNotFoundException(groupId, artifactId));
});
} catch (ArtifactNotFoundException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public String selectArtifactVersionMetaDataByContentHash() {
return "SELECT v.*, a.type FROM versions v "
+ "JOIN content c ON v.contentId = c.contentId AND v.tenantId = c.tenantId "
+ "JOIN artifacts a ON v.tenantId = a.tenantId AND v.groupId = a.groupId AND v.artifactId = a.artifactId "
+ "WHERE v.tenantId = ? AND v.groupId = ? AND v.artifactId = ? AND c.contentHash = ? ORDER BY v.globalId";
+ "WHERE v.tenantId = ? AND v.groupId = ? AND v.artifactId = ? AND c.contentHash = ? ORDER BY v.globalId DESC";
}

@Override
Expand All @@ -226,7 +226,7 @@ public String selectArtifactVersionMetaDataByCanonicalHash() {
return "SELECT v.*, a.type FROM versions v "
+ "JOIN content c ON v.contentId = c.contentId AND v.tenantId = c.tenantId "
+ "JOIN artifacts a ON v.tenantId = a.tenantId AND v.groupId = a.groupId AND v.artifactId = a.artifactId "
+ "WHERE v.tenantId = ? AND v.groupId = ? AND v.artifactId = ? AND c.canonicalHash = ? ORDER BY v.globalId";
+ "WHERE v.tenantId = ? AND v.groupId = ? AND v.artifactId = ? AND c.canonicalHash = ? ORDER BY v.globalId DESC";
}

/**
Expand Down

0 comments on commit d2b9b9c

Please sign in to comment.