@@ -1323,6 +1323,46 @@ def search_request(condition_size: int = 2):
13231323 assert not search_fail .ok
13241324
13251325
1326+ def test_strict_mode_formula_expression (collection_name ):
1327+
1328+ def query_request ():
1329+ expression = {
1330+ "sum" : [
1331+ "discount_price" ,
1332+ "$score" ,
1333+ ]
1334+ }
1335+
1336+ return request_with_validation (
1337+ api = '/collections/{collection_name}/points/query' ,
1338+ method = "POST" ,
1339+ path_params = {'collection_name' : collection_name },
1340+ body = {
1341+ "prefetch" : {
1342+ "query" : [0.1 , 0.2 , 0.3 , 0.4 ],
1343+ },
1344+ "query" : {
1345+ "formula" : expression ,
1346+ "defaults" : { "discount_price" : 0 } # Even with default, it should still be restricted
1347+ }
1348+ }
1349+ )
1350+ # No restriction, query succeeds
1351+ query_ok = query_request ()
1352+ assert query_ok .ok
1353+
1354+ set_strict_mode (collection_name , {
1355+ "enabled" : True ,
1356+ "unindexed_filtering_retrieve" : False ,
1357+ })
1358+
1359+ # Now it should fail
1360+ query_fail = query_request ()
1361+ assert not query_fail .ok
1362+ assert "discount_price" in query_fail .json ()['status' ]['error' ]
1363+ assert "formula expression" in query_fail .json ()['status' ]['error' ]
1364+
1365+
13261366def test_strict_mode_read_rate_limiting_small_replenish (collection_name ):
13271367 """
13281368 If our read rate limit capacity is larger, test that when exhausting it
@@ -1418,4 +1458,4 @@ def test_strict_mode_unset_rate_limiting_config(collection_name):
14181458 assert new_strict_mode_config ['enabled' ]
14191459 assert new_strict_mode_config ['read_rate_limit' ] == 2
14201460 # assert write rate limit is not unset because it is currently not supported
1421- assert new_strict_mode_config ['write_rate_limit' ] == 1
1461+ assert new_strict_mode_config ['write_rate_limit' ] == 1
0 commit comments