From 506ce695198b49ef2b1a37d81d66e488c8f0250c Mon Sep 17 00:00:00 2001 From: Neil Kakkar Date: Fri, 26 Apr 2024 13:36:28 +0100 Subject: [PATCH] clean --- posthog/api/feature_flag.py | 5 ----- posthog/models/feature_flag/flag_matching.py | 9 ++++++++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/posthog/api/feature_flag.py b/posthog/api/feature_flag.py index 40c0632a1b275..4d7e7e220cd0c 100644 --- a/posthog/api/feature_flag.py +++ b/posthog/api/feature_flag.py @@ -265,11 +265,6 @@ def properties_all_match(predicate): return filters def check_flag_evaluation(self, data): - # this is a very rough simulation of the actual query that will be run. - # Only reason we do it this way is to catch any DB level errors that will bork at runtime - # but aren't caught by above validation, like a regex valid according to re2 but not postgresql. - # We also randomly query for 20 people sans distinct id to make sure the query is valid. - # TODO: Once we move to no DB level evaluation, can get rid of this. temporary_flag = FeatureFlag(**data) diff --git a/posthog/models/feature_flag/flag_matching.py b/posthog/models/feature_flag/flag_matching.py index 890a61a96974d..1686810abd876 100644 --- a/posthog/models/feature_flag/flag_matching.py +++ b/posthog/models/feature_flag/flag_matching.py @@ -1067,10 +1067,17 @@ def check_pure_is_not_operator_condition(condition: dict) -> bool: def check_flag_evaluation_query_is_ok(feature_flag: FeatureFlag, team_id: int) -> bool: # TRICKY: There are some cases where the regex is valid re2 syntax, but postgresql doesn't like it. - # This function tries to validate such cases. + # This function tries to validate such cases. See `test_cant_create_flag_with_data_that_fails_to_query` for an example. # It however doesn't catch all cases, like when the property doesn't exist on any person, which shortcircuits regex evaluation # so it's not a guarantee that the query will work. + # This is a very rough simulation of the actual query that will be run. + # Only reason we do it this way is to catch any DB level errors that will bork at runtime + # but aren't caught by above validation, like a regex valid according to re2 but not postgresql. + # We also randomly query for 20 people sans distinct id to make sure the query is valid. + + # TODO: Once we move to no DB level evaluation, can get rid of this. + group_type_index = feature_flag.aggregation_group_type_index base_query: QuerySet = (