Skip to content

Commit baef9b9

Browse files
committed
Merge branch 'v0.9.x' into dev
2 parents 4d70a25 + 3536bed commit baef9b9

File tree

4 files changed

+35
-5
lines changed

4 files changed

+35
-5
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.4"
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/conditions/in.rs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,28 @@ where
3232
B: Condition<'a>,
3333
{
3434
fn build(&self, mut builder: ConditionBuilder<'_, 'a>) {
35+
let bool_fallback;
36+
let collection_operator;
37+
let binary_operator;
38+
match self.operator {
39+
InOperator::In => {
40+
bool_fallback = false;
41+
collection_operator = CollectionOperator::Or;
42+
binary_operator = BinaryOperator::Equals;
43+
}
44+
InOperator::NotIn => {
45+
bool_fallback = true;
46+
collection_operator = CollectionOperator::And;
47+
binary_operator = BinaryOperator::NotEquals;
48+
}
49+
}
50+
3551
if self.snd_arg.is_empty() {
36-
Value::Bool(false).build(builder);
52+
Value::Bool(bool_fallback).build(builder);
3753
} else {
38-
builder.push_condition(FlatCondition::StartCollection(CollectionOperator::Or));
54+
builder.push_condition(FlatCondition::StartCollection(collection_operator));
3955
for snd_arg in self.snd_arg.iter() {
40-
builder.push_condition(FlatCondition::BinaryCondition(BinaryOperator::Equals));
56+
builder.push_condition(FlatCondition::BinaryCondition(binary_operator));
4157
self.fst_arg.build(builder.reborrow());
4258
snd_arg.build(builder.reborrow());
4359
}

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)