From 57c0e47ac4dfeacb24c30815de512ec22a435656 Mon Sep 17 00:00:00 2001 From: Cyber MacGeddon Date: Wed, 3 Sep 2025 23:26:05 +0100 Subject: [PATCH] Tests pass --- .../test_objects_cassandra_query.py | 1 + .../query/objects/cassandra/service.py | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/tests/unit/test_query/test_objects_cassandra_query.py b/tests/unit/test_query/test_objects_cassandra_query.py index 77de06e5..ab11d5a1 100644 --- a/tests/unit/test_query/test_objects_cassandra_query.py +++ b/tests/unit/test_query/test_objects_cassandra_query.py @@ -188,6 +188,7 @@ class TestObjectsGraphQLQueryLogic: processor.connect_cassandra = MagicMock() processor.sanitize_name = Processor.sanitize_name.__get__(processor, Processor) processor.sanitize_table = Processor.sanitize_table.__get__(processor, Processor) + processor.parse_filter_key = Processor.parse_filter_key.__get__(processor, Processor) processor.query_cassandra = Processor.query_cassandra.__get__(processor, Processor) # Mock session execute to capture the query diff --git a/trustgraph-flow/trustgraph/query/objects/cassandra/service.py b/trustgraph-flow/trustgraph/query/objects/cassandra/service.py index 9df19f04..b71b0f06 100644 --- a/trustgraph-flow/trustgraph/query/objects/cassandra/service.py +++ b/trustgraph-flow/trustgraph/query/objects/cassandra/service.py @@ -158,8 +158,11 @@ class Processor(FlowProcessor): safe_name = 'o_' + safe_name return safe_name.lower() - def parse_filter_key(self, filter_key: str) -> tuple: + def parse_filter_key(self, filter_key: str) -> tuple[str, str]: """Parse GraphQL filter key into field name and operator""" + if not filter_key: + return ("", "eq") + # Support common GraphQL filter patterns: # field_name -> (field_name, "eq") # field_name_gt -> (field_name, "gt") @@ -174,10 +177,10 @@ class Processor(FlowProcessor): if filter_key.endswith(op_suffix): field_name = filter_key[:-len(op_suffix)] operator = op_suffix[1:] # Remove the leading underscore - return field_name, operator + return (field_name, operator) # Default to equality if no operator suffix found - return filter_key, "eq" + return (filter_key, "eq") async def on_schema_config(self, config, version): """Handle schema configuration updates""" @@ -475,7 +478,15 @@ class Processor(FlowProcessor): for filter_key, value in filters.items(): if value is not None: # Parse field name and operator from filter key - field_name, operator = self.parse_filter_key(filter_key) + logger.debug(f"Parsing filter key: '{filter_key}' (type: {type(filter_key)})") + result = self.parse_filter_key(filter_key) + logger.debug(f"parse_filter_key returned: {result} (type: {type(result)}, len: {len(result) if hasattr(result, '__len__') else 'N/A'})") + + if not result or len(result) != 2: + logger.error(f"parse_filter_key returned invalid result: {result}") + continue # Skip this filter + + field_name, operator = result # Find the field in schema schema_field = None