Skip to content

Commit 9de197b

Browse files
committed
fix sql
1 parent b42f27c commit 9de197b

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/cls/ZPM/Package.cls

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -521,11 +521,16 @@ ClassMethod GetLatest(searchTerms As %DynamicArray = "", Output pStatus As %Stat
521521
}
522522
Set searchCondition = searchCondition_ " ) "
523523
}
524-
Set sql = "SELECT name, repository, description "_
525-
"FROM ZPM.Package p1 "_
526-
"WHERE "_ searchCondition _
527-
"GROUP BY name "_
528-
"ORDER BY name"
524+
set sql = "SELECT name, repository, version, description" _
525+
" FROM ZPM.Package p1 "_
526+
" WHERE "_
527+
" version= ( "_
528+
" SELECT TOP 1 version FROM ZPM.Package p2 WHERE p1.name=p2.name "_
529+
" ORDER BY versionMajor DESC, versionMinor DESC, versionPatch DESC, versionPrerelease DESC, versionBuildmetadata DESC ) "_
530+
" AND "_searchCondition_" "_
531+
" GROUP BY name ORDER BY name"
532+
w sql
533+
529534
Set tStatement = ##class(%SQL.Statement).%New()
530535
Set tStatus = tStatement.%Prepare(sql)
531536
If ($$$ISERR(tStatus)) {
@@ -541,9 +546,9 @@ ClassMethod GetLatest(searchTerms As %DynamicArray = "", Output pStatus As %Stat
541546
While tResult.%Next() {
542547
Set tPkgInfo = {
543548
"name": (tResult.name),
544-
"description": (tResult.Description),
549+
"description": (tResult.description),
545550
"repository": (tResult.repository),
546-
"versions": [(..GetTopVersion(tResult.name))]
551+
"versions": [(tResult.version)]
547552
}
548553
do tList.%Push(tPkgInfo)
549554
}

0 commit comments

Comments
 (0)