Queryer: an explicit archived filter overrides the active-only default, per node
Filter keys arrive as "path/field:$op", so the override check that compared the key to the bare "archived" never matched: the hidden NOT archived clause was always added and an explicit archived filter could not return archived rows. The match is on the node's own archived path, so a root filter lifts the default for the root only — nested includes the filter never mentioned keep hiding archived rows. The two queryer fixtures that filter on archived had snapshotted the contradiction (NOT archived AND archived = $1); they now expect the filter alone. 1286 library tests pass. Pinned by api's TestArchive_CascadesDownTheTree (test/punc/lineage_test.go). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AvkGU4kQ4wsqxHFpXtZKZM
This commit is contained in:
@ -578,8 +578,20 @@ impl<'a> Compiler<'a> {
|
||||
let mut where_clauses = Vec::new();
|
||||
|
||||
// Dynamically apply the 'active-only' default ONLY if the client
|
||||
// didn't explicitly request to filter on 'archived' themselves!
|
||||
let has_archived_override = self.filter_keys.iter().any(|k| k == "archived");
|
||||
// didn't explicitly request to filter on 'archived' themselves — for THIS node.
|
||||
// Keys arrive as "path/field:$op" (extract_filters), so match this node's own archived
|
||||
// path, never the bare name: compared to "archived" alone it never matched (an explicit
|
||||
// archived filter could not return archived rows), and matched on any key it would lift
|
||||
// the default from every nested include the filter never mentioned.
|
||||
let archived_path = if node.ast_path.is_empty() {
|
||||
"archived".to_string()
|
||||
} else {
|
||||
format!("{}/archived", node.ast_path)
|
||||
};
|
||||
let has_archived_override = self
|
||||
.filter_keys
|
||||
.iter()
|
||||
.any(|k| k.split(':').next().unwrap_or(k) == archived_path);
|
||||
|
||||
if !has_archived_override {
|
||||
where_clauses.push(format!("NOT {}.archived", entity_alias));
|
||||
|
||||
Reference in New Issue
Block a user