rimashah25 commented on code in PR #7241:
URL: https://github.com/apache/trafficcontrol/pull/7241#discussion_r1049010402
##########
lib/go-tc/parameters.go:
##########
@@ -277,12 +277,15 @@ func ParamExists(id int64, tx *sql.Tx) (bool, error) {
// ParamsExist returns whether parameters exist for all the given ids, and any
error.
// TODO move to helper package.
-func ParamsExist(ids []int64, tx *sql.Tx) (bool, error) {
- count := 0
- if err := tx.QueryRow(`SELECT count(*) from parameter where id =
ANY($1)`, pq.Array(ids)).Scan(&count); err != nil {
- return false, errors.New("querying parameters existence from
id: " + err.Error())
+func ParamsExist(ids []int64, tx *sql.Tx) (bool, []int64, error) {
+ var nonExistingIDs []int64
+ if err := tx.QueryRow(`SELECT ARRAY_AGG(id) FROM UNNEST($1::INT[]) AS
id WHERE id NOT IN (SELECT id FROM parameter)`,
pq.Array(ids)).Scan(pq.Array(&nonExistingIDs)); err != nil {
+ return false, nil, errors.New("querying parameters existence
from id: " + err.Error())
Review Comment:
I understand that we shouldn't since it is a DB level. but also there is a
`TODO` to rework validation in `traffic_ops/traffic_ops_golang/api/api.go`. So,
I would do it as a separate PR.
```
// TODO: Rework validation to be able to return system-level errors
type ParseValidator interface {
Validate(tx *sql.Tx) error
}```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]