diff --git a/service/integration/subject_mappings_test.go b/service/integration/subject_mappings_test.go index a70ff0fc4f..541537e7c4 100644 --- a/service/integration/subject_mappings_test.go +++ b/service/integration/subject_mappings_test.go @@ -404,14 +404,17 @@ func (s *SubjectMappingsSuite) Test_ListSubjectMappings_NoPagination_Succeeds() for _, sm := range listed { if sm.GetId() == fixture1.ID { assertEqual(sm, fixture1) + s.Equal("https://example.com/attr/attr1/value/value1", sm.GetAttributeValue().GetFqn()) found1 = true } if sm.GetId() == fixture2.ID { assertEqual(sm, fixture2) + s.Equal("https://example.com/attr/attr1/value/value2", sm.GetAttributeValue().GetFqn()) found2 = true } if sm.GetId() == fixture3.ID { assertEqual(sm, fixture3) + s.Equal("https://example.com/attr/attr1/value/value1", sm.GetAttributeValue().GetFqn()) found3 = true } } diff --git a/service/policy/db/query.sql b/service/policy/db/query.sql index dc36dd37ac..db10abfb5f 100644 --- a/service/policy/db/query.sql +++ b/service/policy/db/query.sql @@ -839,13 +839,19 @@ SELECT 'metadata', JSON_STRIP_NULLS(JSON_BUILD_OBJECT('labels', scs.metadata->'labels', 'created_at', scs.created_at, 'updated_at', scs.updated_at)), 'subject_sets', scs.condition ) AS subject_condition_set, - JSON_BUILD_OBJECT('id', av.id,'value', av.value,'active', av.active) AS attribute_value, + JSON_BUILD_OBJECT( + 'id', av.id, + 'value', av.value, + 'active', av.active, + 'fqn', fqns.fqn + ) AS attribute_value, counted.total FROM subject_mappings sm CROSS JOIN counted LEFT JOIN attribute_values av ON sm.attribute_value_id = av.id +LEFT JOIN attribute_fqns fqns ON av.id = fqns.value_id LEFT JOIN subject_condition_set scs ON scs.id = sm.subject_condition_set_id -GROUP BY av.id, sm.id, scs.id, counted.total +GROUP BY av.id, sm.id, scs.id, counted.total, fqns.fqn LIMIT @limit_ OFFSET @offset_; diff --git a/service/policy/db/query.sql.go b/service/policy/db/query.sql.go index 3e21083c0e..acceb421fb 100644 --- a/service/policy/db/query.sql.go +++ b/service/policy/db/query.sql.go @@ -2248,13 +2248,14 @@ SELECT 'metadata', JSON_STRIP_NULLS(JSON_BUILD_OBJECT('labels', scs.metadata->'labels', 'created_at', scs.created_at, 'updated_at', scs.updated_at)), 'subject_sets', scs.condition ) AS subject_condition_set, - JSON_BUILD_OBJECT('id', av.id,'value', av.value,'active', av.active) AS attribute_value, + JSON_BUILD_OBJECT('id', av.id,'value', av.value,'active', av.active, 'fqn',fqns.fqn) AS attribute_value, counted.total FROM subject_mappings sm CROSS JOIN counted LEFT JOIN attribute_values av ON sm.attribute_value_id = av.id +LEFT JOIN attribute_fqns fqns ON av.id = fqns.value_id LEFT JOIN subject_condition_set scs ON scs.id = sm.subject_condition_set_id -GROUP BY av.id, sm.id, scs.id, counted.total +GROUP BY av.id, sm.id, scs.id, counted.total, fqns.fqn LIMIT $2 OFFSET $1 ` @@ -2290,13 +2291,14 @@ type ListSubjectMappingsRow struct { // 'metadata', JSON_STRIP_NULLS(JSON_BUILD_OBJECT('labels', scs.metadata->'labels', 'created_at', scs.created_at, 'updated_at', scs.updated_at)), // 'subject_sets', scs.condition // ) AS subject_condition_set, -// JSON_BUILD_OBJECT('id', av.id,'value', av.value,'active', av.active) AS attribute_value, +// JSON_BUILD_OBJECT('id', av.id,'value', av.value,'active', av.active, 'fqn',fqns.fqn) AS attribute_value, // counted.total // FROM subject_mappings sm // CROSS JOIN counted // LEFT JOIN attribute_values av ON sm.attribute_value_id = av.id +// LEFT JOIN attribute_fqns fqns ON av.id = fqns.value_id // LEFT JOIN subject_condition_set scs ON scs.id = sm.subject_condition_set_id -// GROUP BY av.id, sm.id, scs.id, counted.total +// GROUP BY av.id, sm.id, scs.id, counted.total, fqns.fqn // LIMIT $2 // OFFSET $1 func (q *Queries) ListSubjectMappings(ctx context.Context, arg ListSubjectMappingsParams) ([]ListSubjectMappingsRow, error) {