fix: add filter by control-id on list endpoint#293
Conversation
Signed-off-by: Gustavo Carvalho <gustavo.carvalho@container-solutions.com>
There was a problem hiding this comment.
Pull request overview
This PR adds the ability to filter the list of filters by a specific control ID through a new query parameter on the /filters endpoint.
Key Changes:
- Adds a
controlIdquery parameter to the List endpoint for filtering filters by associated control - Implements conditional query building with manual JOIN operations when the controlId parameter is provided
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Gustavo Carvalho <gustavo.carvalho@container-solutions.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
internal/api/handler/filter.go
Outdated
| if controlID != "" { | ||
| query = query. | ||
| Joins("JOIN filter_controls ON filter_controls.filter_id = filters.id"). | ||
| Joins("JOIN controls ON controls.catalog_id = uuid(filter_controls.control_catalog_id) AND controls.id = filter_controls.control_id"). |
There was a problem hiding this comment.
The uuid() function is not a standard PostgreSQL function. In PostgreSQL, you should use the cast operator :: instead. Replace uuid(filter_controls.control_catalog_id) with filter_controls.control_catalog_id::uuid to properly cast the value to UUID type.
| Joins("JOIN controls ON controls.catalog_id = uuid(filter_controls.control_catalog_id) AND controls.id = filter_controls.control_id"). | |
| Joins("JOIN controls ON controls.catalog_id = filter_controls.control_catalog_id::uuid AND controls.id = filter_controls.control_id"). |
Signed-off-by: Gustavo Carvalho <gustavo.carvalho@container-solutions.com>
No description provided.