dxatscale / sfpowerscripts

A build system for modular development in Salesforce
https://dxatscale.io
MIT License
207 stars 94 forks source link

Optimise number of queries for resolving package versions #1059

Open aly76 opened 2 years ago

aly76 commented 2 years ago

During Build, a single Tooling API query is made for the first occurrence of each package dependency version, to resolve the LATEST keyword. This could be further optimised by sending only a single query with all the Package2 Id's aggregated and then sorting the response by package and descending semantic version.

Pro's:

Cons:

azlam-abdulsalam commented 2 years ago

@rody Can you weigh in your thoughts here

rody commented 2 years ago

something like:

SELECT Package2.Name, MajorVersion, MinorVersion, PatchVersion, max(BuildNumber)
FROM Package2Version
WHERE (Package2.Name = 'logging' AND MajorVersion=0 AND MinorVersion=1 AND PatchVersion=0)
 OR (Package2.Name = 'async-framework' AND MajorVersion=0 AND MinorVersion=1 AND PacthVersion=0)
GROUP BY Package2Id, Package2.Name, MajorVersion, MinorVersion, PatchVersion

with a dynamic WHERE section (note that you are limited in the size of that section)

I'm assuming that we are trying to find the latest build of a declared dependency, not the absolute latest package version (i.e. MajorVersion and MinorVersion are given in sfdx-project.json)

edit: adding PatchVersion field