Skip to content
  • Jamie Tanna's avatar
    Add `RetrievePackageAdvisoriesLike` · 08a8af9a
    Jamie Tanna authored
    As part of #151, indicated in !75, we need to introduce a new query for
    package advisories that match various criteria.
    
    We can add this query separately as a means to simplify the
    implementation.
    
    We can take advantage of the `sqlc.arg` directive to enforce the naming
    of the struct, otherwise we end up with:
    
        type RetrievePackageAdvisoriesLikeParams struct {
    	   Platform       string
    	   Organisation   string
    	   Repo           string
    	   Owner          string
    	   Platform_2     string
    	   Organisation_2 string
    	   Repo_2         string
    	   Owner_2        string
    	   Platform_3     string
    	   Organisation_3 string
    	   Repo_3         string
    	   Owner_3        string
        }
    
    This does unfortunately mean that we can't as easily copy-paste the
    query, but hopefully it's trivial to tweak it.
    
    This requires we create a constructor for the
    `RetrievePackageAdvisoriesLikeParams` method to correctly, as we're
    unable to use a `case` statement due to [0].
    
    We also need to make sure we target out `owner` lookups better with
    a rather large `where` statement, as otherwise we can't correctly filter
    by the `owner`.
    
    [0]: https://github.com/sqlc-dev/sqlc/issues/2736
    08a8af9a