use super::WildcardOwners;
impl WildcardOwners {
fn first_child_depth(&self) -> Option<usize> {
let mut queries = self.queries.iter();
let mut owner = queries.next()?;
for query in queries {
if owner.wrapped_body != Some(query.query) {
return Some(query.depth);
}
owner = query;
}
None
}
pub(in crate::statements::keyed_lookups) fn qualifier_is_at_root(
&self,
qualifier: &str,
) -> Option<bool> {
let child_depth = self.first_child_depth()?;
self.local
.iter()
.rposition(|scope| scope.inputs.qualifiers.contains_key(qualifier))
.map(|owner| owner < child_depth)
}
pub(in crate::statements::keyed_lookups) fn column_is_at_root(
&self,
column: &str,
allow_unknown_root: bool,
) -> Option<bool> {
let child_depth = self.first_child_depth()?;
for (position, scope) in self.local.iter().enumerate().rev() {
let root = position < child_depth;
if scope.inputs.columns.contains(column) {
return Some(root);
}
if scope.inputs.unknown_columns && (root || !allow_unknown_root) {
return (allow_unknown_root && root).then_some(true);
}
}
None
}
}