use either::Either;
use prisma_value::PrismaValue;
use crate::{DefaultKind, DefaultValue, ViewColumnId, ViewColumnWalker, ViewDefaultValueId, Walker};
use super::DefaultValueWalker;
pub type ViewDefaultValueWalker<'a> = Walker<'a, ViewDefaultValueId>;
impl<'a> ViewDefaultValueWalker<'a> {
pub fn coarsen(self) -> DefaultValueWalker<'a> {
self.walk(Either::Right(self.id))
}
pub fn column(self) -> ViewColumnWalker<'a> {
self.walk(self.get().0)
}
pub fn as_value(self) -> Option<&'a PrismaValue> {
self.coarsen().as_value()
}
pub fn as_sequence(self) -> Option<&'a str> {
self.coarsen().as_sequence()
}
pub fn is_value(&self) -> bool {
self.coarsen().is_value()
}
pub fn is_now(&self) -> bool {
self.coarsen().is_now()
}
pub fn is_sequence(&self) -> bool {
self.coarsen().is_sequence()
}
pub fn is_db_generated(&self) -> bool {
self.coarsen().is_db_generated()
}
pub fn kind(self) -> &'a DefaultKind {
self.coarsen().kind()
}
pub fn constraint_name(self) -> Option<&'a str> {
self.coarsen().constraint_name()
}
fn get(self) -> &'a (ViewColumnId, DefaultValue) {
&self.schema.view_default_values[self.id.0 as usize]
}
}