Skip to content

fix: add filter by control-id on list endpoint#293

Merged
gusfcarvalho merged 3 commits intomainfrom
gc-fix-filter-endpoints
Dec 23, 2025
Merged

fix: add filter by control-id on list endpoint#293
gusfcarvalho merged 3 commits intomainfrom
gc-fix-filter-endpoints

Conversation

@gusfcarvalho
Copy link
Contributor

No description provided.

Signed-off-by: Gustavo Carvalho <gustavo.carvalho@container-solutions.com>
Copilot AI review requested due to automatic review settings December 23, 2025 10:24
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 controlId query 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>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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").
Copy link

Copilot AI Dec 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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").

Copilot uses AI. Check for mistakes.
Signed-off-by: Gustavo Carvalho <gustavo.carvalho@container-solutions.com>
@gusfcarvalho gusfcarvalho enabled auto-merge (squash) December 23, 2025 10:43
@gusfcarvalho gusfcarvalho merged commit af49e73 into main Dec 23, 2025
4 checks passed
@gusfcarvalho gusfcarvalho deleted the gc-fix-filter-endpoints branch December 23, 2025 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants