diff --git a/posthog/hogql_queries/legacy_compatibility/clean_properties.py b/posthog/hogql_queries/legacy_compatibility/clean_properties.py index 06f1f67cc1e2f..27e400d8c99e3 100644 --- a/posthog/hogql_queries/legacy_compatibility/clean_properties.py +++ b/posthog/hogql_queries/legacy_compatibility/clean_properties.py @@ -1,6 +1,3 @@ -from posthog.schema import PropertyGroupFilter - - def clean_global_properties(properties: dict | list[dict] | None): if properties is None or len(properties) == 0: # empty properties @@ -12,14 +9,14 @@ def clean_global_properties(properties: dict | list[dict] | None): "type": "AND", "values": [{"type": "AND", "values": properties}], } - return PropertyGroupFilter(**clean_property_group_filter(properties)) + return clean_property_group_filter(properties) elif isinstance(properties, list): # list of property filters properties = { "type": "AND", "values": [{"type": "AND", "values": properties}], } - return PropertyGroupFilter(**clean_property_group_filter(properties)) + return clean_property_group_filter(properties) elif ( isinstance(properties, dict) and properties.get("type") in ["AND", "OR"] @@ -30,10 +27,10 @@ def clean_global_properties(properties: dict | list[dict] | None): "type": "AND", "values": [properties], } - return PropertyGroupFilter(**clean_property_group_filter(properties)) + return clean_property_group_filter(properties) else: # property group filter - return PropertyGroupFilter(**clean_property_group_filter(properties)) + return clean_property_group_filter(properties) def clean_entity_properties(properties: list[dict] | dict | None): diff --git a/posthog/hogql_queries/legacy_compatibility/test/test_clean_properties.py b/posthog/hogql_queries/legacy_compatibility/test/test_clean_properties.py index 8585d4372bb83..e3e5fd91acd7b 100644 --- a/posthog/hogql_queries/legacy_compatibility/test/test_clean_properties.py +++ b/posthog/hogql_queries/legacy_compatibility/test/test_clean_properties.py @@ -1,12 +1,4 @@ from posthog.hogql_queries.legacy_compatibility.clean_properties import clean_entity_properties, clean_global_properties -from posthog.schema import ( - CohortPropertyFilter, - EventPropertyFilter, - FilterLogicalOperator, - PropertyGroupFilter, - PropertyGroupFilterValue, - PropertyOperator, -) from posthog.test.base import BaseTest @@ -25,17 +17,15 @@ def test_handles_old_style_properties(self): self.assertEqual( result, - PropertyGroupFilter( - type=FilterLogicalOperator.AND, - values=[ - PropertyGroupFilterValue( - type=FilterLogicalOperator.AND, - values=[ - EventPropertyFilter(key="utm_medium", value="email", operator=PropertyOperator.icontains) - ], - ) + { + "type": "AND", + "values": [ + { + "type": "AND", + "values": [{"key": "utm_medium", "operator": "icontains", "type": "event", "value": "email"}], + } ], - ), + }, ) def test_handles_property_filter_lists(self): @@ -45,15 +35,15 @@ def test_handles_property_filter_lists(self): self.assertEqual( result, - PropertyGroupFilter( - type=FilterLogicalOperator.AND, - values=[ - PropertyGroupFilterValue( - type=FilterLogicalOperator.AND, - values=[CohortPropertyFilter(key="id", value=636)], - ) + { + "type": "AND", + "values": [ + { + "type": "AND", + "values": [{"key": "id", "type": "cohort", "value": 636}], + } ], - ), + }, ) def test_handles_property_group_filters(self): @@ -66,15 +56,15 @@ def test_handles_property_group_filters(self): self.assertEqual( result, - PropertyGroupFilter( - type=FilterLogicalOperator.AND, - values=[ - PropertyGroupFilterValue( - type=FilterLogicalOperator.AND, - values=[CohortPropertyFilter(key="id", value=850)], - ) + { + "type": "AND", + "values": [ + { + "type": "AND", + "values": [{"key": "id", "type": "cohort", "value": 850}], + } ], - ), + }, ) def test_handles_property_group_filters_values(self): @@ -87,15 +77,15 @@ def test_handles_property_group_filters_values(self): self.assertEqual( result, - PropertyGroupFilter( - type=FilterLogicalOperator.AND, - values=[ - PropertyGroupFilterValue( - type=FilterLogicalOperator.AND, - values=[CohortPropertyFilter(key="id", value=850)], - ) + { + "type": "AND", + "values": [ + { + "type": "AND", + "values": [{"key": "id", "type": "cohort", "value": 850}], + } ], - ), + }, ) diff --git a/posthog/hogql_queries/legacy_compatibility/test/test_filter_to_query.py b/posthog/hogql_queries/legacy_compatibility/test/test_filter_to_query.py index 9421ac41be854..9abc0f3506b8c 100644 --- a/posthog/hogql_queries/legacy_compatibility/test/test_filter_to_query.py +++ b/posthog/hogql_queries/legacy_compatibility/test/test_filter_to_query.py @@ -1167,7 +1167,7 @@ def test_series_properties(self): self.assertEqual( query.series, [ - EventsNode(event="$pageview", name="$pageview", properties=[]), + EventsNode(event="$pageview", name="$pageview", properties=None), EventsNode( event="$pageview", name="$pageview",