In Model/lib/wdk/model/questions/queries/pathwayQueries.xml, the any_or_all_pathway "all" branch does not implement "all". It is a no-op in at least one search and probably close to one in the others.
The defect
Take PathwaysByGeneList:
GROUP BY tp.pathway_source_id, tp.pathway_source, tp.gene_source_id, tp.ec_number_gene, tp.ec_number_pathway
HAVING (
('$$any_or_all_pathway$$' = 'any')
OR (count(*) <= (SELECT count (*)
FROM apidbtuning.TranscriptPathway tp , dsGene ds
WHERE tp.gene_source_id = ds.gene
)
))
The GROUP BY includes tp.gene_source_id, so each group is one gene in one pathway with one EC pair — count(*) per group is typically 1. The subquery counts every pathway-gene row for the entire input list. So the comparison is roughly 1 <= (large number), which is true for every group. The all branch filters nothing.
For "pathways containing all of these genes", the comparison needs to be at the pathway level — something like count(distinct gene_source_id) = <number of input genes> after grouping by pathway alone, not per gene.
Evidence
EXPLAIN ANALYZE of PathwaysByGeneList against genomicsdb_071n, 5-gene input (PF3D7_0103700, PF3D7_0109500, PF3D7_0109850, PF3D7_0110600, PF3D7_0202900), pathways_source=1, exclude_incomplete_ec=0, exact_match_only=0:
| mode |
rows out |
any |
3687 |
all |
3687 |
Identical. With any the planner constant-folds ('any' = 'any') and drops the subquery entirely; with all it evaluates it as an InitPlan and every group still passes.
Affected sites
| Query |
Line (approx) |
Comparison |
PathwaysByGeneList |
~234 |
count(*) <= — never filters |
PathwaysByGeneIds |
~414 |
count(*) = — same grouping problem, also grouped per gene |
PathwaysByCompounds |
~307 |
count(*) = — same shape, worth checking against compound grouping |
The <= in PathwaysByGeneList is the most clearly wrong; the = variants may filter something, but not the intended thing, since the group is still per-gene.
Why this wasn't caught
It fails open. "All" silently returns the "any" result set, which is a superset containing the correct answer — so results look plausible and nothing errors. Only a count comparison between the two modes reveals it.
Not in scope of #227
Noticed while fixing the gene-alias resolution in these same queries (#227), and deliberately left untouched there — it is pre-existing and needs a semantics decision, not a mechanical fix. Someone should confirm what "all" is meant to mean in the UI before rewriting the grouping.
🤖 Generated with Claude Code
In
Model/lib/wdk/model/questions/queries/pathwayQueries.xml, theany_or_all_pathway"all" branch does not implement "all". It is a no-op in at least one search and probably close to one in the others.The defect
Take
PathwaysByGeneList:The
GROUP BYincludestp.gene_source_id, so each group is one gene in one pathway with one EC pair —count(*)per group is typically 1. The subquery counts every pathway-gene row for the entire input list. So the comparison is roughly1 <= (large number), which is true for every group. Theallbranch filters nothing.For "pathways containing all of these genes", the comparison needs to be at the pathway level — something like
count(distinct gene_source_id) = <number of input genes>after grouping by pathway alone, not per gene.Evidence
EXPLAIN ANALYZEofPathwaysByGeneListagainstgenomicsdb_071n, 5-gene input (PF3D7_0103700,PF3D7_0109500,PF3D7_0109850,PF3D7_0110600,PF3D7_0202900),pathways_source=1,exclude_incomplete_ec=0,exact_match_only=0:anyallIdentical. With
anythe planner constant-folds('any' = 'any')and drops the subquery entirely; withallit evaluates it as an InitPlan and every group still passes.Affected sites
PathwaysByGeneListcount(*) <=— never filtersPathwaysByGeneIdscount(*) =— same grouping problem, also grouped per genePathwaysByCompoundscount(*) =— same shape, worth checking against compound groupingThe
<=inPathwaysByGeneListis the most clearly wrong; the=variants may filter something, but not the intended thing, since the group is still per-gene.Why this wasn't caught
It fails open. "All" silently returns the "any" result set, which is a superset containing the correct answer — so results look plausible and nothing errors. Only a count comparison between the two modes reveals it.
Not in scope of #227
Noticed while fixing the gene-alias resolution in these same queries (#227), and deliberately left untouched there — it is pre-existing and needs a semantics decision, not a mechanical fix. Someone should confirm what "all" is meant to mean in the UI before rewriting the grouping.
🤖 Generated with Claude Code