use either::Either;
use prisma_value::PrismaValue;
use crate::{DefaultKind, DefaultValue, TableColumnId, TableColumnWalker, TableDefaultValueId, Walker};
use super::DefaultValueWalker;
pub type TableDefaultValueWalker<'a> = Walker<'a, TableDefaultValueId>;
impl<'a> TableDefaultValueWalker<'a> {
pub fn coarsen(self) -> DefaultValueWalker<'a> {
self.walk(Either::Left(self.id))
}
pub fn column(self) -> TableColumnWalker<'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()
}
pub fn inner(self) -> &'a DefaultValue {
self.coarsen().value()
}
fn get(self) -> &'a (TableColumnId, DefaultValue) {
&self.schema.table_default_values[self.id.0 as usize]
}
}