From 85fa1c6b97bf2d8b67f97f1a0cb14ade7da52f5b Mon Sep 17 00:00:00 2001 From: Albert Sola Date: Thu, 6 Nov 2025 12:28:24 +0000 Subject: [PATCH] MPT-152232 RQL Query from string --- mpt_api_client/rql/query_builder.py | 5 +++++ tests/unit/rql/query_builder/test_rql_from_str.py | 9 +++++++++ 2 files changed, 14 insertions(+) create mode 100644 tests/unit/rql/query_builder/test_rql_from_str.py diff --git a/mpt_api_client/rql/query_builder.py b/mpt_api_client/rql/query_builder.py index 29b4aec7..87c34dce 100644 --- a/mpt_api_client/rql/query_builder.py +++ b/mpt_api_client/rql/query_builder.py @@ -188,6 +188,11 @@ def new( query.expr = expr return query + @classmethod + def from_string(cls, query_string: str) -> Self: + """Create a new RQLQuery object from a string.""" + return cls.new(expr=query_string) + def __len__(self) -> int: if self.op == self.OP_EXPRESSION: if self.expr: diff --git a/tests/unit/rql/query_builder/test_rql_from_str.py b/tests/unit/rql/query_builder/test_rql_from_str.py new file mode 100644 index 00000000..29a76db8 --- /dev/null +++ b/tests/unit/rql/query_builder/test_rql_from_str.py @@ -0,0 +1,9 @@ +from mpt_api_client import RQLQuery + + +def test_rql_from_str(): + str_query = "eq(id,ID)" + + rql = RQLQuery.from_string(str_query) + + assert str(rql) == str_query