Skip to content

Commit 3536bed

Browse files
committed
Added set_if to non-empty UpdateBuilder
1 parent 4fd7294 commit 3536bed

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ members = [
1111

1212
[package]
1313
name = "rorm"
14-
version = "0.9.5"
14+
version = "0.9.6"
1515
edition = "2021"
1616
repository = "https://github.com/rorm-orm/rorm"
1717
authors = ["gammelalf", "myOmikron <[email protected]>"]

changelog.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Since 0.9.4
1+
Since 0.9.6
22
-----------
33

44
Notes for publishing

src/crud/update.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,20 @@ where
229229
));
230230
self
231231
}
232+
233+
/// Add a column to update if `value` is `Some`
234+
///
235+
/// Can be called multiple times.
236+
pub fn set_if<I>(self, field: FieldProxy<I>, value: Option<<I::Field as Field>::Type>) -> Self
237+
where
238+
I: FieldProxyImpl<Field: SingleColumnField, Path = M>,
239+
{
240+
if let Some(value) = value {
241+
self.set(field, value)
242+
} else {
243+
self
244+
}
245+
}
232246
}
233247

234248
impl<'ex, 'rf, E, M> UpdateBuilder<'rf, E, M, columns::NonEmpty>

0 commit comments

Comments
 (0)