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)
20
20
return base . VisitMethodCall ( m ) ;
21
21
}
22
22
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
+
23
33
protected override Expression VisitMember ( MemberExpression expression )
24
34
{
25
35
if ( IsWhereBooleanExpression ( expression ) )
Original file line number Diff line number Diff line change @@ -98,5 +98,17 @@ public void Variable_Bool_ExplicitFalse()
98
98
var json = rebels . Where ( r => r . IsJedi == false ) . OrderBy ( r => r . IsJedi ) . ToString ( ) ;
99
99
Assert . Equal ( @"{""selector"":{""isJedi"":false},""sort"":[""isJedi""]}" , json ) ;
100
100
}
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
+ }
101
113
}
102
114
}
You can’t perform that action at this time.
0 commit comments