Skip to content

Commit 5f24cd2

Browse files
committed
feat(dao): Use the package with the lowest id in findByPackage
When searching for an identical packages, always return the match with the lowest id. This helps with the deduplication logic introduced in a later commit, as the deduplication will also keep the package with the lowest id. Signed-off-by: Martin Nonnenmacher <[email protected]>
1 parent 33db173 commit 5f24cd2

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

dao/src/main/kotlin/tables/runs/analyzer/PackagesTable.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import org.jetbrains.exposed.dao.LongEntity
3333
import org.jetbrains.exposed.dao.LongEntityClass
3434
import org.jetbrains.exposed.dao.id.EntityID
3535
import org.jetbrains.exposed.dao.id.LongIdTable
36+
import org.jetbrains.exposed.sql.SortOrder
3637
import org.jetbrains.exposed.sql.and
3738

3839
/**
@@ -64,7 +65,7 @@ class PackageDao(id: EntityID<Long>) : LongEntity(id) {
6465
(PackagesTable.homepageUrl eq pkg.homepageUrl) and
6566
(PackagesTable.isMetadataOnly eq pkg.isMetadataOnly) and
6667
(PackagesTable.isModified eq pkg.isModified)
67-
}.firstOrNull {
68+
}.orderBy(PackagesTable.id to SortOrder.ASC).firstOrNull {
6869
it.identifier.mapToModel() == pkg.identifier &&
6970
mapAndCompare(it.authors, pkg.authors, AuthorDao::name) &&
7071
mapAndCompare(it.declaredLicenses, pkg.declaredLicenses, DeclaredLicenseDao::name) &&

0 commit comments

Comments
 (0)