pub enum WriteOp {
Set(FilterValue),
Increment(FilterValue),
Decrement(FilterValue),
Multiply(FilterValue),
Divide(FilterValue),
Unset,
}Expand description
One scalar update operator applied to a column.
Mirrors the *FieldUpdate wrapper structs in
crate::inputs::scalar_update. Each wrapper lowers exactly one
of its set-only / increment / decrement / multiply / divide / unset
fields to the matching variant here.
Variants§
Set(FilterValue)
col = value — the default form.
Increment(FilterValue)
col = col + value — numeric scalars only.
Decrement(FilterValue)
col = col - value — numeric scalars only.
Multiply(FilterValue)
col = col * value — numeric scalars only.
Divide(FilterValue)
col = col / value — numeric scalars only.
Unset
col = NULL — nullable scalars only.
Implementations§
Source§impl WriteOp
impl WriteOp
Sourcepub fn is_arithmetic(&self) -> bool
pub fn is_arithmetic(&self) -> bool
True when the operator targets a numeric column.
Used by the SQL emitter to pick between col = $n (Set/Unset)
and col = col <op> $n (the arithmetic variants).
Sourcepub fn to_set_fragment(
&self,
column: &str,
placeholder: &str,
) -> (String, Option<FilterValue>)
pub fn to_set_fragment( &self, column: &str, placeholder: &str, ) -> (String, Option<FilterValue>)
Render this operator as a SET-clause fragment.
Given the column name and a 1.. placeholder offset, returns
the textual fragment (col = $1, col = col + $1, col = NULL)
and the value to push to the parameter list. Unset returns
None for the value — the caller skips the parameter slot.