use crate::{
TypeMeta, Untyped,
expression::{Column, Expression},
lower::LowerCtx,
};
#[derive(Debug, Clone, Copy)]
pub struct As<T> {
pub table: &'static str,
pub inner: T,
}
#[qraft_expression_macro::as_expression]
impl<M, T: TypeMeta> Expression for As<Column<M, T>> {
type Type = T;
fn lower(&self, ctx: &mut LowerCtx) -> usize {
ctx.lower_column(Some(self.table), self.inner.name)
}
}
#[qraft_expression_macro::as_expression]
impl Expression for As<&'static str> {
type Type = Untyped;
fn lower(&self, ctx: &mut LowerCtx) -> usize {
ctx.lower_column(Some(self.table), self.inner)
}
}