use super::{BuiltIn, SqlWriter};
use crate::role::Role;
use crate::spec::TableSpec;
use crate::statement::Param;
impl<D> SqlWriter<'_, D>
where
D: BuiltIn + ?Sized,
{
pub(crate) fn settled_row(&mut self, spec: &TableSpec<'_>) -> &mut Self {
self.push(" WHERE ")
.ident(spec.id().name())
.push(" = ")
.param(Param::Id)
.held(spec)
}
pub(crate) fn held(&mut self, spec: &TableSpec<'_>) -> &mut Self {
if let Some(expiry) = spec.column(Role::LockedUntil) {
self.push(" AND ")
.ident(expiry.name())
.push(" = ")
.param(Param::Held);
}
self
}
pub(crate) fn release(&mut self, spec: &TableSpec<'_>) -> &mut Self {
if let Some(expiry) = spec.column(Role::LockedUntil) {
self.push(", ").ident(expiry.name()).push(" = NULL");
}
self
}
}