Skip to content

MPT-18065 Fix backward incompatible issues related to RQL: Support of property comparison#210

Open
jentyk wants to merge 1 commit intomainfrom
fix/MPT-18028
Open

MPT-18065 Fix backward incompatible issues related to RQL: Support of property comparison#210
jentyk wants to merge 1 commit intomainfrom
fix/MPT-18028

Conversation

@jentyk
Copy link
Contributor

@jentyk jentyk commented Feb 13, 2026

Closes MPT-18028

Changes

  • Added public helper function quote_rql_value(value: str) -> str to properly escape single quotes and wrap values in single quotes for RQL comparisons
  • Updated parse_kwargs to quote string-encoded values for string lookups and comparison operators (COMP)
  • Updated RQLQuery._bin to quote encoded values for comparison operators before building expressions
  • Updated all test expectations across the test suite to reflect the new quoted string formatting in RQL expressions
    • String literals in RQL comparisons now appear with single quotes (e.g., eq(status,'active') instead of eq(status,active))
    • This includes nested expressions and all comparison operators

@coderabbitai
Copy link

coderabbitai bot commented Feb 13, 2026

📝 Walkthrough

Walkthrough

This PR introduces automatic quoting of string values in RQL query expressions. A new public helper function quote_rql_value() was added to escape and wrap strings in single quotes. The parsing and query building logic was updated to quote string literals in RQL comparisons across various operators. All related tests were updated to reflect the new string formatting behavior.

Changes

Cohort / File(s) Summary
Core RQL Implementation
mpt_api_client/rql/query_builder.py
Added new public helper function quote_rql_value() to escape and wrap strings in single quotes. Updated parse_kwargs() to quote string values for single-token lookups and non-keyword operators. Updated RQLQuery._bin() to quote string values for comparison operators.
HTTP Integration Tests
tests/unit/http/mixins/test_collection_mixin.py, tests/unit/http/test_base_service.py, tests/unit/http/test_query_state.py
Updated test expectations to reflect quoted string values in equality filters. Changed eq(status,active) to eq(status,'active') across multiple test cases for fetch and query operations.
RQL Query Builder Tests
tests/unit/rql/query_builder/test_create_rql.py, tests/unit/rql/query_builder/test_multiple_ops.py, tests/unit/rql/query_builder/test_rql.py, tests/unit/rql/query_builder/test_rql_all_any.py, tests/unit/rql/query_builder/test_rql_dot_path.py, tests/unit/rql/query_builder/test_rql_from_str.py, tests/unit/rql/query_builder/test_rql_parse_kwargs.py
Updated all test expectations to wrap string literals, numeric values, booleans, and date/time strings in single quotes within RQL expression representations. Changes are consistent across nested expressions and various comparison operators.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Jira Issue Key In Title ✅ Passed The PR title contains the Jira issue key MPT-18065 in the correct format at the beginning.
Test Coverage Required ✅ Passed PR modifies 1 code file and includes test file changes across 10 test modules, meeting the test coverage requirement.
Single Commit Required ✅ Passed The PR contains exactly one commit (51fd78e), which meets the requirement of having a single commit for a clean git history.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@jentyk jentyk marked this pull request as ready for review February 16, 2026 13:57
@jentyk jentyk requested a review from a team as a code owner February 16, 2026 13:57
@jentyk jentyk requested review from d3rky and svazquezco February 16, 2026 13:57
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
tests/unit/rql/query_builder/test_rql_dot_path.py (1)

33-34: Remove unused noqa directives.

Static analysis indicates that FBT003 is not enabled in the linting configuration, making these noqa comments unnecessary.

🧹 Suggested cleanup
-    assert str(result(True)) == f"{op}(asset.id,'true')"  # noqa: FBT003
-    assert str(result(False)) == f"{op}(asset.id,'false')"  # noqa: FBT003
+    assert str(result(True)) == f"{op}(asset.id,'true')"
+    assert str(result(False)) == f"{op}(asset.id,'false')"

@jentyk jentyk changed the title MPT-18028 Fix backward incompatible issues related to RQL: Support of property comparison MPT-18065 Fix backward incompatible issues related to RQL: Support of property comparison Feb 16, 2026
@jentyk jentyk marked this pull request as draft February 16, 2026 15:08
@jentyk jentyk marked this pull request as ready for review February 17, 2026 09:54
@sonarqubecloud
Copy link

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@mpt_api_client/rql/query_builder.py`:
- Line 18: The trailing noqa comment on the parse_kwargs function signature is
invalid/unused; edit the parse_kwargs definition (function name: parse_kwargs)
to remove the "# noqa: WPS231 C901" directive so linters (ruff/flake8) can apply
configured rules correctly, then run the linting suite to confirm no remaining
rule suppressions are needed or add specific, valid noqa codes only if genuinely
required and documented.

In `@tests/unit/rql/query_builder/test_rql_dot_path.py`:
- Around line 32-34: The two assertions in test_rql_dot_path.py that read assert
str(result(True)) == f"{op}(asset.id,'true')"  # noqa: FBT003 and assert
str(result(False)) == f"{op}(asset.id,'false')"  # noqa: FBT003 should have the
unused noqa directives removed; edit the test to drop the " # noqa: FBT003"
suffixes so the lines are simply the assertions using result and op, leaving
other lines untouched.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant