Skip to content

Commit

Permalink
prevent wildcard aliasing
Browse files Browse the repository at this point in the history
  • Loading branch information
MarinPostma committed Oct 29, 2022
1 parent 672bff8 commit 12bc32c
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 14 deletions.
3 changes: 0 additions & 3 deletions book/tests/prql/semantics/functions-0.prql

This file was deleted.

1 change: 0 additions & 1 deletion book/tests/prql/semantics/functions-1.prql

This file was deleted.

2 changes: 0 additions & 2 deletions book/tests/prql/semantics/name-resolving-0.prql

This file was deleted.

4 changes: 0 additions & 4 deletions book/tests/prql/semantics/name-resolving-1.prql

This file was deleted.

1 change: 0 additions & 1 deletion prql-compiler/src/semantic/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ impl Resolver {
match res {
Ok(id) => id,
Err(e) => {
dbg!(&self.context);
bail!(Error::new(Reason::Simple(e)).with_span(span))
}
}
Expand Down
13 changes: 10 additions & 3 deletions prql-compiler/src/sql/anchor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,17 @@ impl AnchorContext {
let def = self.columns_defs.get_mut(cid).unwrap();

if def.name.is_none() {
let id = self.next_col_name_id;
self.next_col_name_id += 1;
match &def.expr.kind {
ExprKind::ExternRef { variable, .. } if variable == "*" => {
def.name = Some("*".into());
}
_ => {
let id = self.next_col_name_id;
self.next_col_name_id += 1;

def.name = Some(format!("_expr_{id}"));
def.name = Some(format!("_expr_{id}"));
}
}
}

def.name.clone().unwrap()
Expand Down

0 comments on commit 12bc32c

Please sign in to comment.