File tree Expand file tree Collapse file tree 3 files changed +33
-3
lines changed
tests/unit/rql/query_builder Expand file tree Collapse file tree 3 files changed +33
-3
lines changed Original file line number Diff line number Diff line change 1- from mpt_api_client .rql .query_builder import RQLQuery
1+ from mpt_api_client .rql .query_builder import RQLQuery , Literal
22
3- __all__ = ["RQLQuery" ] # noqa: WPS410
3+ __all__ = ["RQLQuery" , "Literal" ] # noqa: WPS410
Original file line number Diff line number Diff line change 66
77Numeric = int | float | Decimal
88
9- QueryValue = str | bool | dt .date | dt .datetime | Numeric
9+ class Literal :
10+ def __init__ (self , value ):
11+ self .value = value
1012
13+ def __str__ (self ):
14+ return f"'{ self .value } '"
15+
16+
17+ QueryValue = str | bool | dt .date | dt .datetime | Numeric | Literal
1118
1219def parse_kwargs (query_dict : dict [str , QueryValue ]) -> list [str ]: # noqa: WPS231
1320 """
@@ -71,6 +78,7 @@ def query_value_str(value: QueryValue) -> str:
7178
7279 if isinstance (value , dt .date | dt .datetime ):
7380 return value .isoformat ()
81+
7482 # Matching: if isinstance(value, int | float | Decimal):
7583 return str (value )
7684
Original file line number Diff line number Diff line change 1+ from mpt_api_client .rql import RQLQuery , Literal
2+
3+ def test_compare_property ():
4+ query = RQLQuery (agreement__product__id = "order.product.id" )
5+
6+ result = str (query )
7+
8+ assert result == "eq(agreement.product.id,order.product.id)"
9+
10+ def test_compare_quoted ():
11+ query = RQLQuery (agreement__product__id = Literal ("order.product.id" ))
12+
13+ result = str (query )
14+
15+ assert result == "eq(agreement.product.id,'order.product.id')"
16+
17+ def test_ne_quoted ():
18+ query = RQLQuery ("agreement.product.id" )
19+
20+ result = str (query .ne (Literal ("order.product.id" )))
21+
22+ assert result == "ne(agreement.product.id,'order.product.id')"
You can’t perform that action at this time.
0 commit comments