@@ -5567,25 +5567,28 @@ public void TestWhereSystemProfileInfoTimeStampGreatherThanJan12012()
5567
5567
[ Test ]
5568
5568
public void TestWhereTripleAnd ( )
5569
5569
{
5570
- // the query is a bit odd in order to force the built query to be promoted to $and form
5571
- var query = from c in _collection . AsQueryable < C > ( )
5572
- where c . X >= 0 && c . X >= 1 && c . Y == 11
5573
- select c ;
5574
-
5575
- var translatedQuery = MongoQueryTranslator . Translate ( query ) ;
5576
- Assert . IsInstanceOf < SelectQuery > ( translatedQuery ) ;
5577
- Assert . AreSame ( _collection , translatedQuery . Collection ) ;
5578
- Assert . AreSame ( typeof ( C ) , translatedQuery . DocumentType ) ;
5579
-
5580
- var selectQuery = ( SelectQuery ) translatedQuery ;
5581
- Assert . AreEqual ( "(C c) => (((c.X >= 0) && (c.X >= 1)) && (c.Y == 11))" , ExpressionFormatter . ToString ( selectQuery . Where ) ) ;
5582
- Assert . IsNull ( selectQuery . OrderBy ) ;
5583
- Assert . IsNull ( selectQuery . Projection ) ;
5584
- Assert . IsNull ( selectQuery . Skip ) ;
5585
- Assert . IsNull ( selectQuery . Take ) ;
5586
-
5587
- Assert . AreEqual ( "{ \" $and\" : [{ \" x\" : { \" $gte\" : 0 } }, { \" x\" : { \" $gte\" : 1 } }, { \" y\" : 11 }] }" , selectQuery . BuildQuery ( ) . ToJson ( ) ) ;
5588
- Assert . AreEqual ( 2 , Consume ( query ) ) ;
5570
+ if ( _server . BuildInfo . Version >= new Version ( 2 , 0 ) )
5571
+ {
5572
+ // the query is a bit odd in order to force the built query to be promoted to $and form
5573
+ var query = from c in _collection . AsQueryable < C > ( )
5574
+ where c . X >= 0 && c . X >= 1 && c . Y == 11
5575
+ select c ;
5576
+
5577
+ var translatedQuery = MongoQueryTranslator . Translate ( query ) ;
5578
+ Assert . IsInstanceOf < SelectQuery > ( translatedQuery ) ;
5579
+ Assert . AreSame ( _collection , translatedQuery . Collection ) ;
5580
+ Assert . AreSame ( typeof ( C ) , translatedQuery . DocumentType ) ;
5581
+
5582
+ var selectQuery = ( SelectQuery ) translatedQuery ;
5583
+ Assert . AreEqual ( "(C c) => (((c.X >= 0) && (c.X >= 1)) && (c.Y == 11))" , ExpressionFormatter . ToString ( selectQuery . Where ) ) ;
5584
+ Assert . IsNull ( selectQuery . OrderBy ) ;
5585
+ Assert . IsNull ( selectQuery . Projection ) ;
5586
+ Assert . IsNull ( selectQuery . Skip ) ;
5587
+ Assert . IsNull ( selectQuery . Take ) ;
5588
+
5589
+ Assert . AreEqual ( "{ \" $and\" : [{ \" x\" : { \" $gte\" : 0 } }, { \" x\" : { \" $gte\" : 1 } }, { \" y\" : 11 }] }" , selectQuery . BuildQuery ( ) . ToJson ( ) ) ;
5590
+ Assert . AreEqual ( 2 , Consume ( query ) ) ;
5591
+ }
5589
5592
}
5590
5593
5591
5594
[ Test ]
@@ -6265,70 +6268,79 @@ public void TestWhereXLessThanOrEquals1Reversed()
6265
6268
[ Test ]
6266
6269
public void TestWhereXModOneEquals0AndXModTwoEquals0 ( )
6267
6270
{
6268
- var query = from c in _collection . AsQueryable < C > ( )
6269
- where ( c . X % 1 == 0 ) && ( c . X % 2 == 0 )
6270
- select c ;
6271
-
6272
- var translatedQuery = MongoQueryTranslator . Translate ( query ) ;
6273
- Assert . IsInstanceOf < SelectQuery > ( translatedQuery ) ;
6274
- Assert . AreSame ( _collection , translatedQuery . Collection ) ;
6275
- Assert . AreSame ( typeof ( C ) , translatedQuery . DocumentType ) ;
6276
-
6277
- var selectQuery = ( SelectQuery ) translatedQuery ;
6278
- Assert . AreEqual ( "(C c) => (((c.X % 1) == 0) && ((c.X % 2) == 0))" , ExpressionFormatter . ToString ( selectQuery . Where ) ) ;
6279
- Assert . IsNull ( selectQuery . OrderBy ) ;
6280
- Assert . IsNull ( selectQuery . Projection ) ;
6281
- Assert . IsNull ( selectQuery . Skip ) ;
6282
- Assert . IsNull ( selectQuery . Take ) ;
6283
-
6284
- Assert . AreEqual ( "{ \" $and\" : [{ \" x\" : { \" $mod\" : [1, 0] } }, { \" x\" : { \" $mod\" : [2, 0] } }] }" , selectQuery . BuildQuery ( ) . ToJson ( ) ) ;
6285
- Assert . AreEqual ( 2 , Consume ( query ) ) ;
6271
+ if ( _server . BuildInfo . Version >= new Version ( 2 , 0 ) )
6272
+ {
6273
+ var query = from c in _collection . AsQueryable < C > ( )
6274
+ where ( c . X % 1 == 0 ) && ( c . X % 2 == 0 )
6275
+ select c ;
6276
+
6277
+ var translatedQuery = MongoQueryTranslator . Translate ( query ) ;
6278
+ Assert . IsInstanceOf < SelectQuery > ( translatedQuery ) ;
6279
+ Assert . AreSame ( _collection , translatedQuery . Collection ) ;
6280
+ Assert . AreSame ( typeof ( C ) , translatedQuery . DocumentType ) ;
6281
+
6282
+ var selectQuery = ( SelectQuery ) translatedQuery ;
6283
+ Assert . AreEqual ( "(C c) => (((c.X % 1) == 0) && ((c.X % 2) == 0))" , ExpressionFormatter . ToString ( selectQuery . Where ) ) ;
6284
+ Assert . IsNull ( selectQuery . OrderBy ) ;
6285
+ Assert . IsNull ( selectQuery . Projection ) ;
6286
+ Assert . IsNull ( selectQuery . Skip ) ;
6287
+ Assert . IsNull ( selectQuery . Take ) ;
6288
+
6289
+ Assert . AreEqual ( "{ \" $and\" : [{ \" x\" : { \" $mod\" : [1, 0] } }, { \" x\" : { \" $mod\" : [2, 0] } }] }" , selectQuery . BuildQuery ( ) . ToJson ( ) ) ;
6290
+ Assert . AreEqual ( 2 , Consume ( query ) ) ;
6291
+ }
6286
6292
}
6287
6293
6288
6294
[ Test ]
6289
6295
public void TestWhereXModOneEquals0AndXModTwoEquals0Not ( )
6290
6296
{
6291
- var query = from c in _collection . AsQueryable < C > ( )
6292
- where ! ( ( c . X % 1 == 0 ) && ( c . X % 2 == 0 ) )
6293
- select c ;
6294
-
6295
- var translatedQuery = MongoQueryTranslator . Translate ( query ) ;
6296
- Assert . IsInstanceOf < SelectQuery > ( translatedQuery ) ;
6297
- Assert . AreSame ( _collection , translatedQuery . Collection ) ;
6298
- Assert . AreSame ( typeof ( C ) , translatedQuery . DocumentType ) ;
6299
-
6300
- var selectQuery = ( SelectQuery ) translatedQuery ;
6301
- Assert . AreEqual ( "(C c) => !(((c.X % 1) == 0) && ((c.X % 2) == 0))" , ExpressionFormatter . ToString ( selectQuery . Where ) ) ;
6302
- Assert . IsNull ( selectQuery . OrderBy ) ;
6303
- Assert . IsNull ( selectQuery . Projection ) ;
6304
- Assert . IsNull ( selectQuery . Skip ) ;
6305
- Assert . IsNull ( selectQuery . Take ) ;
6306
-
6307
- Assert . AreEqual ( "{ \" $nor\" : [{ \" $and\" : [{ \" x\" : { \" $mod\" : [1, 0] } }, { \" x\" : { \" $mod\" : [2, 0] } }] }] }" , selectQuery . BuildQuery ( ) . ToJson ( ) ) ;
6308
- Assert . AreEqual ( 3 , Consume ( query ) ) ;
6297
+ if ( _server . BuildInfo . Version >= new Version ( 2 , 0 ) )
6298
+ {
6299
+ var query = from c in _collection . AsQueryable < C > ( )
6300
+ where ! ( ( c . X % 1 == 0 ) && ( c . X % 2 == 0 ) )
6301
+ select c ;
6302
+
6303
+ var translatedQuery = MongoQueryTranslator . Translate ( query ) ;
6304
+ Assert . IsInstanceOf < SelectQuery > ( translatedQuery ) ;
6305
+ Assert . AreSame ( _collection , translatedQuery . Collection ) ;
6306
+ Assert . AreSame ( typeof ( C ) , translatedQuery . DocumentType ) ;
6307
+
6308
+ var selectQuery = ( SelectQuery ) translatedQuery ;
6309
+ Assert . AreEqual ( "(C c) => !(((c.X % 1) == 0) && ((c.X % 2) == 0))" , ExpressionFormatter . ToString ( selectQuery . Where ) ) ;
6310
+ Assert . IsNull ( selectQuery . OrderBy ) ;
6311
+ Assert . IsNull ( selectQuery . Projection ) ;
6312
+ Assert . IsNull ( selectQuery . Skip ) ;
6313
+ Assert . IsNull ( selectQuery . Take ) ;
6314
+
6315
+ Assert . AreEqual ( "{ \" $nor\" : [{ \" $and\" : [{ \" x\" : { \" $mod\" : [1, 0] } }, { \" x\" : { \" $mod\" : [2, 0] } }] }] }" , selectQuery . BuildQuery ( ) . ToJson ( ) ) ;
6316
+ Assert . AreEqual ( 3 , Consume ( query ) ) ;
6317
+ }
6309
6318
}
6310
6319
6311
6320
[ Test ]
6312
6321
public void TestWhereXModOneEquals0AndXModTwoEquals0NotNot ( )
6313
6322
{
6314
- var query = from c in _collection . AsQueryable < C > ( )
6315
- where ! ! ( ( c . X % 1 == 0 ) && ( c . X % 2 == 0 ) )
6316
- select c ;
6317
-
6318
- var translatedQuery = MongoQueryTranslator . Translate ( query ) ;
6319
- Assert . IsInstanceOf < SelectQuery > ( translatedQuery ) ;
6320
- Assert . AreSame ( _collection , translatedQuery . Collection ) ;
6321
- Assert . AreSame ( typeof ( C ) , translatedQuery . DocumentType ) ;
6322
-
6323
- var selectQuery = ( SelectQuery ) translatedQuery ;
6324
- Assert . AreEqual ( "(C c) => !!(((c.X % 1) == 0) && ((c.X % 2) == 0))" , ExpressionFormatter . ToString ( selectQuery . Where ) ) ;
6325
- Assert . IsNull ( selectQuery . OrderBy ) ;
6326
- Assert . IsNull ( selectQuery . Projection ) ;
6327
- Assert . IsNull ( selectQuery . Skip ) ;
6328
- Assert . IsNull ( selectQuery . Take ) ;
6329
-
6330
- Assert . AreEqual ( "{ \" $or\" : [{ \" $and\" : [{ \" x\" : { \" $mod\" : [1, 0] } }, { \" x\" : { \" $mod\" : [2, 0] } }] }] }" , selectQuery . BuildQuery ( ) . ToJson ( ) ) ;
6331
- Assert . AreEqual ( 2 , Consume ( query ) ) ;
6323
+ if ( _server . BuildInfo . Version >= new Version ( 2 , 0 ) )
6324
+ {
6325
+ var query = from c in _collection . AsQueryable < C > ( )
6326
+ where ! ! ( ( c . X % 1 == 0 ) && ( c . X % 2 == 0 ) )
6327
+ select c ;
6328
+
6329
+ var translatedQuery = MongoQueryTranslator . Translate ( query ) ;
6330
+ Assert . IsInstanceOf < SelectQuery > ( translatedQuery ) ;
6331
+ Assert . AreSame ( _collection , translatedQuery . Collection ) ;
6332
+ Assert . AreSame ( typeof ( C ) , translatedQuery . DocumentType ) ;
6333
+
6334
+ var selectQuery = ( SelectQuery ) translatedQuery ;
6335
+ Assert . AreEqual ( "(C c) => !!(((c.X % 1) == 0) && ((c.X % 2) == 0))" , ExpressionFormatter . ToString ( selectQuery . Where ) ) ;
6336
+ Assert . IsNull ( selectQuery . OrderBy ) ;
6337
+ Assert . IsNull ( selectQuery . Projection ) ;
6338
+ Assert . IsNull ( selectQuery . Skip ) ;
6339
+ Assert . IsNull ( selectQuery . Take ) ;
6340
+
6341
+ Assert . AreEqual ( "{ \" $or\" : [{ \" $and\" : [{ \" x\" : { \" $mod\" : [1, 0] } }, { \" x\" : { \" $mod\" : [2, 0] } }] }] }" , selectQuery . BuildQuery ( ) . ToJson ( ) ) ;
6342
+ Assert . AreEqual ( 2 , Consume ( query ) ) ;
6343
+ }
6332
6344
}
6333
6345
6334
6346
[ Test ]
0 commit comments