mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-24 20:51:02 +02:00
Tests pass
This commit is contained in:
parent
ae4ef7161b
commit
57c0e47ac4
2 changed files with 16 additions and 4 deletions
|
|
@ -188,6 +188,7 @@ class TestObjectsGraphQLQueryLogic:
|
||||||
processor.connect_cassandra = MagicMock()
|
processor.connect_cassandra = MagicMock()
|
||||||
processor.sanitize_name = Processor.sanitize_name.__get__(processor, Processor)
|
processor.sanitize_name = Processor.sanitize_name.__get__(processor, Processor)
|
||||||
processor.sanitize_table = Processor.sanitize_table.__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)
|
processor.query_cassandra = Processor.query_cassandra.__get__(processor, Processor)
|
||||||
|
|
||||||
# Mock session execute to capture the query
|
# Mock session execute to capture the query
|
||||||
|
|
|
||||||
|
|
@ -158,8 +158,11 @@ class Processor(FlowProcessor):
|
||||||
safe_name = 'o_' + safe_name
|
safe_name = 'o_' + safe_name
|
||||||
return safe_name.lower()
|
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"""
|
"""Parse GraphQL filter key into field name and operator"""
|
||||||
|
if not filter_key:
|
||||||
|
return ("", "eq")
|
||||||
|
|
||||||
# Support common GraphQL filter patterns:
|
# Support common GraphQL filter patterns:
|
||||||
# field_name -> (field_name, "eq")
|
# field_name -> (field_name, "eq")
|
||||||
# field_name_gt -> (field_name, "gt")
|
# field_name_gt -> (field_name, "gt")
|
||||||
|
|
@ -174,10 +177,10 @@ class Processor(FlowProcessor):
|
||||||
if filter_key.endswith(op_suffix):
|
if filter_key.endswith(op_suffix):
|
||||||
field_name = filter_key[:-len(op_suffix)]
|
field_name = filter_key[:-len(op_suffix)]
|
||||||
operator = op_suffix[1:] # Remove the leading underscore
|
operator = op_suffix[1:] # Remove the leading underscore
|
||||||
return field_name, operator
|
return (field_name, operator)
|
||||||
|
|
||||||
# Default to equality if no operator suffix found
|
# Default to equality if no operator suffix found
|
||||||
return filter_key, "eq"
|
return (filter_key, "eq")
|
||||||
|
|
||||||
async def on_schema_config(self, config, version):
|
async def on_schema_config(self, config, version):
|
||||||
"""Handle schema configuration updates"""
|
"""Handle schema configuration updates"""
|
||||||
|
|
@ -475,7 +478,15 @@ class Processor(FlowProcessor):
|
||||||
for filter_key, value in filters.items():
|
for filter_key, value in filters.items():
|
||||||
if value is not None:
|
if value is not None:
|
||||||
# Parse field name and operator from filter key
|
# 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
|
# Find the field in schema
|
||||||
schema_field = None
|
schema_field = None
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue