@@ -3313,4 +3313,53 @@ public void TestNumericLogicalOperatorsInDialect4()
33133313 Assert . Equal ( 1 , ft . Search ( index , new Query ( "@version:[123 123] | @id:[456 7890]" ) ) . TotalResults ) ;
33143314 Assert . Equal ( 1 , ft . Search ( index , new Query ( "@version==123 @id==456" ) . Dialect ( 4 ) ) . TotalResults ) ;
33153315 }
3316+
3317+ [ Fact ]
3318+ public void TestDocumentLoad_Issue352 ( )
3319+ {
3320+ Document d = Document . Load ( "1" , 0.5 , null , new RedisValue [ ] { RedisValue . Null } ) ;
3321+ Assert . Empty ( d . GetProperties ( ) . ToList ( ) ) ;
3322+ }
3323+
3324+ [ Fact ]
3325+ public void TestDocumentLoadWithDB_Issue352 ( )
3326+ {
3327+ IDatabase db = redisFixture . Redis . GetDatabase ( ) ;
3328+ db . Execute ( "FLUSHALL" ) ;
3329+ var ft = db . FT ( ) ;
3330+
3331+ Schema sc = new Schema ( ) . AddTextField ( "first" , 1.0 ) . AddTextField ( "last" , 1.0 ) . AddNumericField ( "age" ) ;
3332+ Assert . True ( ft . Create ( index , FTCreateParams . CreateParams ( ) , sc ) ) ;
3333+
3334+ Document droppedDocument = null ;
3335+ int numberOfAttempts = 0 ;
3336+ do
3337+ {
3338+ db . HashSet ( "student:1111" , new HashEntry [ ] { new ( "first" , "Joe" ) , new ( "last" , "Dod" ) , new ( "age" , 18 ) } ) ;
3339+
3340+ Assert . True ( db . KeyExpire ( "student:1111" , TimeSpan . FromMilliseconds ( 500 ) ) ) ;
3341+
3342+ Boolean cancelled = false ;
3343+ Task searchTask = Task . Run ( ( ) =>
3344+ {
3345+ for ( int i = 0 ; i < 100000 ; i ++ )
3346+ {
3347+ SearchResult result = ft . Search ( index , new Query ( ) ) ;
3348+ List < Document > docs = result . Documents ;
3349+ if ( docs . Count == 0 || cancelled )
3350+ {
3351+ break ;
3352+ }
3353+ else if ( docs [ 0 ] . GetProperties ( ) . ToList ( ) . Count == 0 )
3354+ {
3355+ droppedDocument = docs [ 0 ] ;
3356+ }
3357+ }
3358+ } ) ;
3359+ Task . WhenAny ( searchTask , Task . Delay ( 1000 ) ) . GetAwaiter ( ) . GetResult ( ) ;
3360+ Assert . True ( searchTask . IsCompletedSuccessfully ) ;
3361+ Assert . Null ( searchTask . Exception ) ;
3362+ cancelled = true ;
3363+ } while ( droppedDocument == null && numberOfAttempts ++ < 3 ) ;
3364+ }
33163365}
0 commit comments