Skip to content
代码片段 群组 项目
提交 bbade505 编辑于 作者: mo khan's avatar mo khan 提交者: David Fernandez
浏览文件

Fix query to remove ambiguous column reference errors

```bash
RSpec::Retry: 2nd try ./ee/spec/services/dependencies/export_serializers/group_dependencies_service_spec.rb:33
    when the group has dependencies
      example at ./ee/spec/services/dependencies/export_serializers/group_dependencies_service_spec.rb:43 (FAILED - 2)

1st Try error in ./ee/spec/services/dependencies/export_serializers/group_dependencies_service_spec.rb:43:
PG::AmbiguousColumn: ERROR:  column reference "id" is ambiguous
LINE 1: ... AND "projects"."pending_delete" = FALSE)) SELECT id FROM "o...
```

```sql
WITH "our_occurrences" AS MATERIALIZED (
  SELECT "sbom_occurrences".*
  FROM "sbom_occurrences"
  WHERE "sbom_occurrences"."project_id" IN (
    SELECT "projects"."id"
    FROM "projects"
    WHERE "projects"."namespace_id" IN (
      SELECT namespaces.traversal_ids[array_length(namespaces.traversal_ids, 1)] AS id
      FROM "namespaces"
      WHERE "namespaces"."type" = 'Group'
      AND (traversal_ids @> ('{3456}'))
    )
    AND "projects"."marked_for_deletion_at" IS NULL
    AND "projects"."pending_delete" = FALSE
  )
)
SELECT id
FROM "our_occurrences" AS "sbom_occurrences"
LEFT OUTER JOIN "projects" ON "projects"."id" = "sbom_occurrences"."project_id"
LEFT OUTER JOIN "routes" ON "routes"."source_type" = 'Project' AND "routes"."source_id" = "projects"."id"
INNER JOIN (
  SELECT component_id,
        COUNT(DISTINCT id) AS occurrence_count,
        COUNT(DISTINCT project_id) AS project_count
  FROM our_occurrences
  GROUP BY component_id
) agg_occurrences ON sbom_occurrences.component_id = agg_occurrences.component_id
ORDER BY "sbom_occurrences"."id" ASC
LIMIT 1000;
```
上级 a9f6efda
No related branches found
No related tags found
加载中
加载中
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册