use super::{unsupported, Binder, BoundExpr};
use crate::ast::{ExprId, RaiseAction};
use crate::diagnostic::ParseError;
use crate::lexer::Span;
impl Binder<'_> {
pub(super) fn bind_raise(
&mut self,
action: RaiseAction,
message: Option<ExprId>,
span: Span,
) -> Result<BoundExpr, ParseError> {
if self.row_aliases.is_none() {
return Err(unsupported("RAISE outside a trigger", span));
}
let bound = match message {
Some(id) => Some(self.bind_expr(id)?),
None => None,
};
let (message, computed) = match bound {
Some(BoundExpr::Text(text)) => (Some(text), None),
Some(other) => (None, Some(Box::new(other))),
None => (None, None),
};
Ok(BoundExpr::Raise {
action,
message,
computed,
foreign_key: false,
})
}
}