File tree 1 file changed +19
-1
lines changed
1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,24 @@ impl Condition {
46
46
///
47
47
/// If it's an [`Condition::any`], it will be separated from the others by an `" OR "` in the query. If it's
48
48
/// an [`Condition::all`], it will be separated by an `" AND "`.
49
+ ///
50
+ /// ```
51
+ /// use sea_query::{tests_cfg::*, *};
52
+ ///
53
+ /// let statement = sea_query::Query::select()
54
+ /// .column(Glyph::Id)
55
+ /// .from(Glyph::Table)
56
+ /// .cond_where(
57
+ /// Cond::all()
58
+ /// .add(Expr::col(Glyph::Aspect).eq(0).into_condition().not())
59
+ /// .add(Expr::col(Glyph::Id).eq(0).into_condition().not()),
60
+ /// )
61
+ /// .to_string(PostgresQueryBuilder);
62
+ /// assert_eq!(
63
+ /// statement,
64
+ /// r#"SELECT "id" FROM "glyph" WHERE (NOT ("aspect" = 0)) AND (NOT ("id" = 0))"#
65
+ /// );
66
+ /// ```
49
67
#[ allow( clippy:: should_implement_trait) ]
50
68
pub fn add < C > ( mut self , condition : C ) -> Self
51
69
where
@@ -58,7 +76,7 @@ impl Condition {
58
76
return self ;
59
77
}
60
78
// Skip the junction if there is only one.
61
- if c. conditions . len ( ) == 1 {
79
+ if c. conditions . len ( ) == 1 && !c . negate {
62
80
expr = c. conditions . pop ( ) . unwrap ( ) ;
63
81
}
64
82
}
You can’t perform that action at this time.
0 commit comments