@@ -364,3 +364,49 @@ def test_set_parameter_alias():
364364 query .set_parameter_alias_vector_f32 ("nearest_neighbour_filter" , [4.9 , 4.9 ])
365365 assert query .count () == 3
366366 assert query .find_ids () == sorted ([5 , 4 , 3 ])
367+
368+
369+ def test_set_parameter_alias_advanced ():
370+ """ Tests set_parameter_alias in a complex scenario (i.e. multiple query conditions/logical aggregations). """
371+ db = create_test_objectbox ()
372+
373+ # Setup 1
374+ box = objectbox .Box (db , TestEntity )
375+ box .put (TestEntity (str = "Apple" , bool = False , int64 = 47 , int32 = 70 ))
376+ box .put (TestEntity (str = "applE" , bool = True , int64 = 253 , int32 = 798 ))
377+ box .put (TestEntity (str = "APPLE" , bool = False , int64 = 3456 , int32 = 123 ))
378+ box .put (TestEntity (str = "Orange" , bool = False , int64 = 2345 , int32 = 53 ))
379+ box .put (TestEntity (str = "orange" , bool = True , int64 = 546 , int32 = 5678 ))
380+ box .put (TestEntity (str = "ORANGE" , bool = True , int64 = 78 , int32 = 798 ))
381+ box .put (TestEntity (str = "oRANGE" , bool = True , int64 = 89 , int32 = 1234 ))
382+ box .put (TestEntity (str = "Zucchini" , bool = False , int64 = 1234 , int32 = 9 ))
383+ assert box .count () == 8
384+
385+ str_prop = TestEntity .get_property ("str" )
386+ bool_prop = TestEntity .get_property ("bool" )
387+ int32_prop = TestEntity .get_property ("int32" )
388+ int64_prop = TestEntity .get_property ("int64" )
389+
390+ query = box .query (
391+ str_prop .equals ("Dummy" , case_sensitive = False ).alias ("str_filter" )
392+ .and_ (bool_prop .equals (False ).alias ("bool_filter" ))
393+ .and_ (
394+ int64_prop .greater_than (0 ).alias ("int64_filter" )
395+ .or_ (int32_prop .less_than (100 ).alias ("int32_filter" ))
396+ )
397+ ).build ()
398+ assert len (query .find_ids ()) == 0
399+
400+ # TODO currently we don't support set_parameter_* for int32/bool/other types...
401+
402+ query .set_parameter_alias_string ("str_filter" , "Apple" )
403+ query .set_parameter_alias_int ("int64_filter" , 300 )
404+ assert len (query .find_ids ()) == 2 # Apple, APPLE
405+
406+ query .set_parameter_alias_string ("str_filter" , "orange" )
407+ query .set_parameter_alias_int ("int64_filter" , 1000 )
408+ assert len (query .find_ids ()) == 1 # Orange
409+
410+ query .set_parameter_alias_string ("str_filter" , "Zucchini" )
411+ assert len (query .find_ids ()) == 1 # Zucchini
412+
0 commit comments