File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed
src/CouchDB.Driver/ExpressionVisitors
tests/CouchDB.Driver.UnitTests/Find Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,16 @@ protected override Expression VisitMethodCall(MethodCallExpression m)
2020 return base . VisitMethodCall ( m ) ;
2121 }
2222
23+ protected override Expression VisitBinary ( BinaryExpression expression )
24+ {
25+ if ( expression . Right is ConstantExpression c && c . Type == typeof ( bool ) &&
26+ ( expression . NodeType == ExpressionType . Equal || expression . NodeType == ExpressionType . NotEqual ) )
27+ {
28+ return expression ;
29+ }
30+ return base . VisitBinary ( expression ) ;
31+ }
32+
2333 protected override Expression VisitMember ( MemberExpression expression )
2434 {
2535 if ( IsWhereBooleanExpression ( expression ) )
Original file line number Diff line number Diff line change @@ -98,5 +98,17 @@ public void Variable_Bool_ExplicitFalse()
9898 var json = rebels . Where ( r => r . IsJedi == false ) . OrderBy ( r => r . IsJedi ) . ToString ( ) ;
9999 Assert . Equal ( @"{""selector"":{""isJedi"":false},""sort"":[""isJedi""]}" , json ) ;
100100 }
101+ [ Fact ]
102+ public void Variable_Bool_ExplicitNotTrue ( )
103+ {
104+ var json = rebels . Where ( r => r . IsJedi != true ) . OrderBy ( r => r . IsJedi ) . ToString ( ) ;
105+ Assert . Equal ( @"{""selector"":{""isJedi"":{""$ne"":true}},""sort"":[""isJedi""]}" , json ) ;
106+ }
107+ [ Fact ]
108+ public void Variable_Bool_ExplicitNotFalse ( )
109+ {
110+ var json = rebels . Where ( r => r . IsJedi != false ) . OrderBy ( r => r . IsJedi ) . ToString ( ) ;
111+ Assert . Equal ( @"{""selector"":{""isJedi"":{""$ne"":false}},""sort"":[""isJedi""]}" , json ) ;
112+ }
101113 }
102114}
You can’t perform that action at this time.
0 commit comments