{
  "db_name": "PostgreSQL",
  "query": "\n        WITH incoming AS (\n            SELECT *\n            FROM unnest($1::bigint[], $2::text[]) WITH ORDINALITY\n                AS u(detail_id, verdict, ord)\n        ),\n        resolved AS (\n            SELECT\n                i.ord,\n                didws.project_id,\n                didws.key AS detail_key,\n                i.verdict::delphi_report_issue_status AS verdict\n            FROM incoming i\n            INNER JOIN delphi_issue_details_with_statuses didws ON didws.id = i.detail_id\n            INNER JOIN delphi_report_issues dri ON dri.id = didws.issue_id\n            WHERE\n                -- see delphi.rs todo comment\n                dri.issue_type != '__dummy'\n        ),\n        validated AS (\n            SELECT\n                (SELECT COUNT(*) FROM incoming) AS incoming_count,\n                (SELECT COUNT(*) FROM resolved) AS resolved_count\n        ),\n        upserted AS (\n            INSERT INTO delphi_issue_detail_verdicts (\n                project_id,\n                detail_key,\n                verdict\n            )\n            SELECT DISTINCT ON (project_id, detail_key)\n                project_id,\n                detail_key,\n                verdict\n            FROM resolved\n            ORDER BY project_id, detail_key, ord DESC\n            ON CONFLICT (project_id, detail_key)\n            DO UPDATE SET verdict = EXCLUDED.verdict\n            RETURNING 1\n        )\n        SELECT\n            (v.incoming_count = v.resolved_count) AS \"all_found!\",\n            (SELECT COUNT(*) FROM upserted) AS \"upserted_count!\"\n        FROM validated v\n        ",
  "describe": {
    "columns": [
      {
        "ordinal": 0,
        "name": "all_found!",
        "type_info": "Bool"
      },
      {
        "ordinal": 1,
        "name": "upserted_count!",
        "type_info": "Int8"
      }
    ],
    "parameters": {
      "Left": [
        "Int8Array",
        "TextArray"
      ]
    },
    "nullable": [
      null,
      null
    ]
  },
  "hash": "ccedb120b05ff47ddc15bb4570025a8e8249050c12f7036d936f9a01f939db1f"
}
