(
cids: Vec<CId>,
ctx: &mut Context,
span: Option<Span>,
)
| 16 | use crate::{Error, Span, WithErrorInfo}; |
| 17 | |
| 18 | pub(super) fn try_into_exprs( |
| 19 | cids: Vec<CId>, |
| 20 | ctx: &mut Context, |
| 21 | span: Option<Span>, |
| 22 | ) -> Result<Vec<sql_ast::Expr>> { |
| 23 | let (cids, excluded) = translate_wildcards(&ctx.anchor, cids); |
| 24 | |
| 25 | let mut res = Vec::new(); |
| 26 | for cid in cids { |
| 27 | let decl = ctx.anchor.column_decls.get(&cid).unwrap(); |
| 28 | |
| 29 | let ColumnDecl::RelationColumn(riid, _, RelationColumn::Wildcard) = decl else { |
| 30 | // base case |
| 31 | res.push(translate_cid(cid, ctx)?.into_ast()); |
| 32 | continue; |
| 33 | }; |
| 34 | |
| 35 | // star |
| 36 | let t = &ctx.anchor.relation_instances[riid]; |
| 37 | let table_name = t.table_ref.name.clone().map(Ident::from_name); |
| 38 | |
| 39 | let ident = translate_star(ctx, span)?; |
| 40 | if let Some(excluded) = excluded.get(&cid) { |
| 41 | if !excluded.is_empty() { |
| 42 | return Err( |
| 43 | Error::new_simple("Excluding columns not supported in this position") |
| 44 | .with_span(span), |
| 45 | ); |
| 46 | } |
| 47 | } |
| 48 | let ident = translate_ident(table_name, Some(ident), ctx); |
| 49 | |
| 50 | res.push(sql_ast::Expr::CompoundIdentifier(ident)); |
| 51 | } |
| 52 | Ok(res) |
| 53 | } |
| 54 | |
| 55 | type Excluded = HashMap<CId, HashSet<CId>>; |
| 56 |
no test coverage detected