Updates references in the `ColumnMap` for use in a nested scope. The provided `arity` must specify the arity of the current scope.
(&self, arity: usize)
| 93 | /// Updates references in the `ColumnMap` for use in a nested scope. The |
| 94 | /// provided `arity` must specify the arity of the current scope. |
| 95 | fn enter_scope(&self, arity: usize) -> ColumnMap { |
| 96 | // From the perspective of the nested scope, all existing column |
| 97 | // references will be one level greater. |
| 98 | let existing = self |
| 99 | .inner |
| 100 | .clone() |
| 101 | .into_iter() |
| 102 | .update(|(col, _i)| col.level += 1); |
| 103 | |
| 104 | // All columns in the current scope become explicit entries in the |
| 105 | // immediate parent scope. |
| 106 | let new = (0..arity).map(|i| { |
| 107 | ( |
| 108 | ColumnRef { |
| 109 | level: 1, |
| 110 | column: i, |
| 111 | }, |
| 112 | self.len() + i, |
| 113 | ) |
| 114 | }); |
| 115 | |
| 116 | ColumnMap::new(existing.chain(new).collect()) |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | /// Map with the CTEs currently in scope. |