From ccba43953c750ab1341c257c9ded0714279127ae Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 17 Nov 2023 15:25:37 +0000 Subject: [PATCH] Update query snapshots --- .../test/__snapshots__/test_feature_flag.ambr | 14 - .../test/__snapshots__/test_feature_flag.ambr | 456 ++++++++++-------- 2 files changed, 249 insertions(+), 221 deletions(-) diff --git a/posthog/api/test/__snapshots__/test_feature_flag.ambr b/posthog/api/test/__snapshots__/test_feature_flag.ambr index 26fd3b9ec6741..8c4f598901c96 100644 --- a/posthog/api/test/__snapshots__/test_feature_flag.ambr +++ b/posthog/api/test/__snapshots__/test_feature_flag.ambr @@ -444,8 +444,6 @@ --- # name: TestResiliency.test_feature_flags_v3_with_experience_continuity_working_slow_db.5 ' - SELECT pg_sleep(1); - WITH target_person_ids AS (SELECT team_id, person_id @@ -475,8 +473,6 @@ --- # name: TestResiliency.test_feature_flags_v3_with_experience_continuity_working_slow_db.6 ' - SELECT pg_sleep(1); - SELECT "posthog_persondistinctid"."person_id", "posthog_persondistinctid"."distinct_id" FROM "posthog_persondistinctid" @@ -487,8 +483,6 @@ --- # name: TestResiliency.test_feature_flags_v3_with_experience_continuity_working_slow_db.7 ' - SELECT pg_sleep(1); - SELECT "posthog_persondistinctid"."person_id", "posthog_persondistinctid"."distinct_id" FROM "posthog_persondistinctid" @@ -498,8 +492,6 @@ --- # name: TestResiliency.test_feature_flags_v3_with_group_properties_and_slow_db ' - SELECT pg_sleep(1); - SELECT "posthog_grouptypemapping"."id", "posthog_grouptypemapping"."team_id", "posthog_grouptypemapping"."group_type", @@ -512,8 +504,6 @@ --- # name: TestResiliency.test_feature_flags_v3_with_group_properties_and_slow_db.1 ' - SELECT pg_sleep(1); - SELECT "posthog_grouptypemapping"."id", "posthog_grouptypemapping"."team_id", "posthog_grouptypemapping"."group_type", @@ -526,8 +516,6 @@ --- # name: TestResiliency.test_feature_flags_v3_with_group_properties_and_slow_db.2 ' - SELECT pg_sleep(1); - SELECT "posthog_grouptypemapping"."id", "posthog_grouptypemapping"."team_id", "posthog_grouptypemapping"."group_type", @@ -540,8 +528,6 @@ --- # name: TestResiliency.test_feature_flags_v3_with_slow_db_doesnt_try_to_compute_conditions_again ' - SELECT pg_sleep(1); - SELECT (("posthog_person"."properties" -> 'email') = '"tim@posthog.com"'::jsonb AND "posthog_person"."properties" ? 'email' AND NOT (("posthog_person"."properties" -> 'email') = 'null'::jsonb)) AS "flag_X_condition_0", diff --git a/posthog/test/__snapshots__/test_feature_flag.ambr b/posthog/test/__snapshots__/test_feature_flag.ambr index 05f9873311799..a8ba2f564d1ee 100644 --- a/posthog/test/__snapshots__/test_feature_flag.ambr +++ b/posthog/test/__snapshots__/test_feature_flag.ambr @@ -1,41 +1,41 @@ # name: TestFeatureFlagMatcher.test_coercion_of_booleans_with_is_not_operator ' - SELECT NOT ((("posthog_person"."properties" -> 'disabled') = 'false' - OR ("posthog_person"."properties" -> 'disabled') = '"false"') + SELECT NOT ((("posthog_person"."properties" -> 'disabled') = 'false'::jsonb + OR ("posthog_person"."properties" -> 'disabled') = '"false"'::jsonb) AND "posthog_person"."properties" ? 'disabled' - AND NOT (("posthog_person"."properties" -> 'disabled') = 'null')) AS "flag_X_condition_0", - NOT ((("posthog_person"."properties" -> 'disabled') = 'false' - OR ("posthog_person"."properties" -> 'disabled') = '"false"') + AND NOT (("posthog_person"."properties" -> 'disabled') = 'null'::jsonb)) AS "flag_X_condition_0", + NOT ((("posthog_person"."properties" -> 'disabled') = 'false'::jsonb + OR ("posthog_person"."properties" -> 'disabled') = '"false"'::jsonb) AND "posthog_person"."properties" ? 'disabled' - AND NOT (("posthog_person"."properties" -> 'disabled') = 'null')) AS "flag_X_condition_1", - NOT ((("posthog_person"."properties" -> 'disabled') = 'false' - OR ("posthog_person"."properties" -> 'disabled') = '"false"') + AND NOT (("posthog_person"."properties" -> 'disabled') = 'null'::jsonb)) AS "flag_X_condition_1", + NOT ((("posthog_person"."properties" -> 'disabled') = 'false'::jsonb + OR ("posthog_person"."properties" -> 'disabled') = '"false"'::jsonb) AND "posthog_person"."properties" ? 'disabled' - AND NOT (("posthog_person"."properties" -> 'disabled') = 'null')) AS "flag_X_condition_2", - NOT ((("posthog_person"."properties" -> 'disabled') = 'false' - OR ("posthog_person"."properties" -> 'disabled') = '"false"') + AND NOT (("posthog_person"."properties" -> 'disabled') = 'null'::jsonb)) AS "flag_X_condition_2", + NOT ((("posthog_person"."properties" -> 'disabled') = 'false'::jsonb + OR ("posthog_person"."properties" -> 'disabled') = '"false"'::jsonb) AND "posthog_person"."properties" ? 'disabled' - AND NOT (("posthog_person"."properties" -> 'disabled') = 'null')) AS "flag_X_condition_3", - NOT ((("posthog_person"."properties" -> 'disabled') = 'false' - OR ("posthog_person"."properties" -> 'disabled') = '"false"') + AND NOT (("posthog_person"."properties" -> 'disabled') = 'null'::jsonb)) AS "flag_X_condition_3", + NOT ((("posthog_person"."properties" -> 'disabled') = 'false'::jsonb + OR ("posthog_person"."properties" -> 'disabled') = '"false"'::jsonb) AND "posthog_person"."properties" ? 'disabled' - AND NOT (("posthog_person"."properties" -> 'disabled') = 'null')) AS "flag_X_condition_4", - NOT ((("posthog_person"."properties" -> 'string_disabled') = 'false' - OR ("posthog_person"."properties" -> 'string_disabled') = '"false"') + AND NOT (("posthog_person"."properties" -> 'disabled') = 'null'::jsonb)) AS "flag_X_condition_4", + NOT ((("posthog_person"."properties" -> 'string_disabled') = 'false'::jsonb + OR ("posthog_person"."properties" -> 'string_disabled') = '"false"'::jsonb) AND "posthog_person"."properties" ? 'string_disabled' - AND NOT (("posthog_person"."properties" -> 'string_disabled') = 'null')) AS "flag_X_condition_5", - NOT ((("posthog_person"."properties" -> 'string_disabled') = 'false' - OR ("posthog_person"."properties" -> 'string_disabled') = '"false"') + AND NOT (("posthog_person"."properties" -> 'string_disabled') = 'null'::jsonb)) AS "flag_X_condition_5", + NOT ((("posthog_person"."properties" -> 'string_disabled') = 'false'::jsonb + OR ("posthog_person"."properties" -> 'string_disabled') = '"false"'::jsonb) AND "posthog_person"."properties" ? 'string_disabled' - AND NOT (("posthog_person"."properties" -> 'string_disabled') = 'null')) AS "flag_X_condition_6", - NOT ((("posthog_person"."properties" -> 'string_disabled') = 'false' - OR ("posthog_person"."properties" -> 'string_disabled') = '"false"') + AND NOT (("posthog_person"."properties" -> 'string_disabled') = 'null'::jsonb)) AS "flag_X_condition_6", + NOT ((("posthog_person"."properties" -> 'string_disabled') = 'false'::jsonb + OR ("posthog_person"."properties" -> 'string_disabled') = '"false"'::jsonb) AND "posthog_person"."properties" ? 'string_disabled' - AND NOT (("posthog_person"."properties" -> 'string_disabled') = 'null')) AS "flag_X_condition_7", - NOT ((("posthog_person"."properties" -> 'string_disabled') = 'false' - OR ("posthog_person"."properties" -> 'string_disabled') = '"false"') + AND NOT (("posthog_person"."properties" -> 'string_disabled') = 'null'::jsonb)) AS "flag_X_condition_7", + NOT ((("posthog_person"."properties" -> 'string_disabled') = 'false'::jsonb + OR ("posthog_person"."properties" -> 'string_disabled') = '"false"'::jsonb) AND "posthog_person"."properties" ? 'string_disabled' - AND NOT (("posthog_person"."properties" -> 'string_disabled') = 'null')) AS "flag_X_condition_8" + AND NOT (("posthog_person"."properties" -> 'string_disabled') = 'null'::jsonb)) AS "flag_X_condition_8" FROM "posthog_person" INNER JOIN "posthog_persondistinctid" ON ("posthog_person"."id" = "posthog_persondistinctid"."person_id") WHERE ("posthog_persondistinctid"."distinct_id" = '307' @@ -45,20 +45,20 @@ --- # name: TestFeatureFlagMatcher.test_coercion_of_strings_and_numbers_with_is_not_operator ' - SELECT (NOT ((("posthog_person"."properties" -> 'Organizer Id') IN ('"307"') - OR ("posthog_person"."properties" -> 'Organizer Id') IN ('307')) + SELECT (NOT ((("posthog_person"."properties" -> 'Organizer Id') IN ('"307"'::jsonb) + OR ("posthog_person"."properties" -> 'Organizer Id') IN ('307'::jsonb)) AND "posthog_person"."properties" ? 'Organizer Id' - AND NOT (("posthog_person"."properties" -> 'Organizer Id') = 'null')) - AND NOT (("posthog_person"."properties" -> 'Organizer Id') IN ('307') + AND NOT (("posthog_person"."properties" -> 'Organizer Id') = 'null'::jsonb)) + AND NOT (("posthog_person"."properties" -> 'Organizer Id') IN ('307'::jsonb) AND "posthog_person"."properties" ? 'Organizer Id' - AND NOT (("posthog_person"."properties" -> 'Organizer Id') = 'null')) - AND NOT ((("posthog_person"."properties" -> 'Organizer Id') = '"307"' - OR ("posthog_person"."properties" -> 'Organizer Id') = '307') + AND NOT (("posthog_person"."properties" -> 'Organizer Id') = 'null'::jsonb)) + AND NOT ((("posthog_person"."properties" -> 'Organizer Id') = '"307"'::jsonb + OR ("posthog_person"."properties" -> 'Organizer Id') = '307'::jsonb) AND "posthog_person"."properties" ? 'Organizer Id' - AND NOT (("posthog_person"."properties" -> 'Organizer Id') = 'null')) - AND NOT (("posthog_person"."properties" -> 'Organizer Id') = '307' + AND NOT (("posthog_person"."properties" -> 'Organizer Id') = 'null'::jsonb)) + AND NOT (("posthog_person"."properties" -> 'Organizer Id') = '307'::jsonb AND "posthog_person"."properties" ? 'Organizer Id' - AND NOT (("posthog_person"."properties" -> 'Organizer Id') = 'null'))) AS "flag_X_condition_0" + AND NOT (("posthog_person"."properties" -> 'Organizer Id') = 'null'::jsonb))) AS "flag_X_condition_0" FROM "posthog_person" INNER JOIN "posthog_persondistinctid" ON ("posthog_person"."id" = "posthog_persondistinctid"."person_id") WHERE ("posthog_persondistinctid"."distinct_id" = '307' @@ -68,20 +68,20 @@ --- # name: TestFeatureFlagMatcher.test_coercion_of_strings_and_numbers_with_is_not_operator.1 ' - SELECT NOT ((("posthog_person"."properties" -> 'Distinct Id') IN ('"307"') - OR ("posthog_person"."properties" -> 'Distinct Id') IN ('307')) + SELECT NOT ((("posthog_person"."properties" -> 'Distinct Id') IN ('"307"'::jsonb) + OR ("posthog_person"."properties" -> 'Distinct Id') IN ('307'::jsonb)) AND "posthog_person"."properties" ? 'Distinct Id' - AND NOT (("posthog_person"."properties" -> 'Distinct Id') = 'null')) AS "flag_X_condition_0", - NOT (("posthog_person"."properties" -> 'Distinct Id') IN ('307') + AND NOT (("posthog_person"."properties" -> 'Distinct Id') = 'null'::jsonb)) AS "flag_X_condition_0", + NOT (("posthog_person"."properties" -> 'Distinct Id') IN ('307'::jsonb) AND "posthog_person"."properties" ? 'Distinct Id' - AND NOT (("posthog_person"."properties" -> 'Distinct Id') = 'null')) AS "flag_X_condition_1", - NOT ((("posthog_person"."properties" -> 'Distinct Id') = '"307"' - OR ("posthog_person"."properties" -> 'Distinct Id') = '307') + AND NOT (("posthog_person"."properties" -> 'Distinct Id') = 'null'::jsonb)) AS "flag_X_condition_1", + NOT ((("posthog_person"."properties" -> 'Distinct Id') = '"307"'::jsonb + OR ("posthog_person"."properties" -> 'Distinct Id') = '307'::jsonb) AND "posthog_person"."properties" ? 'Distinct Id' - AND NOT (("posthog_person"."properties" -> 'Distinct Id') = 'null')) AS "flag_X_condition_2", - NOT (("posthog_person"."properties" -> 'Distinct Id') = '307' + AND NOT (("posthog_person"."properties" -> 'Distinct Id') = 'null'::jsonb)) AS "flag_X_condition_2", + NOT (("posthog_person"."properties" -> 'Distinct Id') = '307'::jsonb AND "posthog_person"."properties" ? 'Distinct Id' - AND NOT (("posthog_person"."properties" -> 'Distinct Id') = 'null')) AS "flag_X_condition_3" + AND NOT (("posthog_person"."properties" -> 'Distinct Id') = 'null'::jsonb)) AS "flag_X_condition_3" FROM "posthog_person" INNER JOIN "posthog_persondistinctid" ON ("posthog_person"."id" = "posthog_persondistinctid"."person_id") WHERE ("posthog_persondistinctid"."distinct_id" = '307' @@ -217,10 +217,10 @@ --- # name: TestFeatureFlagMatcher.test_db_matches_independent_of_string_or_number_type.4 ' - SELECT ((("posthog_person"."properties" -> 'Distinct Id') IN ('"307"') - OR ("posthog_person"."properties" -> 'Distinct Id') IN ('307')) + SELECT ((("posthog_person"."properties" -> 'Distinct Id') IN ('"307"'::jsonb) + OR ("posthog_person"."properties" -> 'Distinct Id') IN ('307'::jsonb)) AND "posthog_person"."properties" ? 'Distinct Id' - AND NOT (("posthog_person"."properties" -> 'Distinct Id') = 'null')) AS "flag_X_condition_0" + AND NOT (("posthog_person"."properties" -> 'Distinct Id') = 'null'::jsonb)) AS "flag_X_condition_0" FROM "posthog_person" INNER JOIN "posthog_persondistinctid" ON ("posthog_person"."id" = "posthog_persondistinctid"."person_id") WHERE ("posthog_persondistinctid"."distinct_id" = '307' @@ -230,9 +230,9 @@ --- # name: TestFeatureFlagMatcher.test_db_matches_independent_of_string_or_number_type.5 ' - SELECT (("posthog_person"."properties" -> 'Distinct Id') IN ('307') + SELECT (("posthog_person"."properties" -> 'Distinct Id') IN ('307'::jsonb) AND "posthog_person"."properties" ? 'Distinct Id' - AND NOT (("posthog_person"."properties" -> 'Distinct Id') = 'null')) AS "flag_X_condition_0" + AND NOT (("posthog_person"."properties" -> 'Distinct Id') = 'null'::jsonb)) AS "flag_X_condition_0" FROM "posthog_person" INNER JOIN "posthog_persondistinctid" ON ("posthog_person"."id" = "posthog_persondistinctid"."person_id") WHERE ("posthog_persondistinctid"."distinct_id" = '307' @@ -242,9 +242,9 @@ --- # name: TestFeatureFlagMatcher.test_db_matches_independent_of_string_or_number_type.6 ' - SELECT (("posthog_person"."properties" -> 'Distinct Id') = '307' + SELECT (("posthog_person"."properties" -> 'Distinct Id') = '307'::jsonb AND "posthog_person"."properties" ? 'Distinct Id' - AND NOT (("posthog_person"."properties" -> 'Distinct Id') = 'null')) AS "flag_X_condition_0" + AND NOT (("posthog_person"."properties" -> 'Distinct Id') = 'null'::jsonb)) AS "flag_X_condition_0" FROM "posthog_person" INNER JOIN "posthog_persondistinctid" ON ("posthog_person"."id" = "posthog_persondistinctid"."person_id") WHERE ("posthog_persondistinctid"."distinct_id" = '307' @@ -266,9 +266,9 @@ --- # name: TestFeatureFlagMatcher.test_multiple_flags.1 ' - SELECT (("posthog_person"."properties" -> 'email') = '"test@posthog.com"' + SELECT (("posthog_person"."properties" -> 'email') = '"test@posthog.com"'::jsonb AND "posthog_person"."properties" ? 'email' - AND NOT (("posthog_person"."properties" -> 'email') = 'null')) AS "flag_X_condition_0", + AND NOT (("posthog_person"."properties" -> 'email') = 'null'::jsonb)) AS "flag_X_condition_0", (true) AS "flag_X_condition_1", (true) AS "flag_X_condition_0", (true) AS "flag_X_condition_0", @@ -292,12 +292,12 @@ --- # name: TestFeatureFlagMatcher.test_multiple_flags.3 ' - SELECT (("posthog_group"."group_properties" -> 'name') IN ('"foo.inc"') + SELECT (("posthog_group"."group_properties" -> 'name') IN ('"foo.inc"'::jsonb) AND "posthog_group"."group_properties" ? 'name' - AND NOT (("posthog_group"."group_properties" -> 'name') = 'null')) AS "flag_X_condition_0", - (("posthog_group"."group_properties" -> 'name') IN ('"foo2.inc"') + AND NOT (("posthog_group"."group_properties" -> 'name') = 'null'::jsonb)) AS "flag_X_condition_0", + (("posthog_group"."group_properties" -> 'name') IN ('"foo2.inc"'::jsonb) AND "posthog_group"."group_properties" ? 'name' - AND NOT (("posthog_group"."group_properties" -> 'name') = 'null')) AS "flag_X_condition_0" + AND NOT (("posthog_group"."group_properties" -> 'name') = 'null'::jsonb)) AS "flag_X_condition_0" FROM "posthog_group" WHERE ("posthog_group"."team_id" = 2 AND "posthog_group"."group_key" = 'foo' @@ -318,9 +318,9 @@ --- # name: TestFeatureFlagMatcher.test_multiple_flags.5 ' - SELECT (("posthog_person"."properties" -> 'email') = '"test@posthog.com"' + SELECT (("posthog_person"."properties" -> 'email') = '"test@posthog.com"'::jsonb AND "posthog_person"."properties" ? 'email' - AND NOT (("posthog_person"."properties" -> 'email') = 'null')) AS "flag_X_condition_0", + AND NOT (("posthog_person"."properties" -> 'email') = 'null'::jsonb)) AS "flag_X_condition_0", (true) AS "flag_X_condition_1", (true) AS "flag_X_condition_0", (true) AS "flag_X_condition_0", @@ -334,12 +334,12 @@ --- # name: TestFeatureFlagMatcher.test_multiple_flags.6 ' - SELECT (("posthog_group"."group_properties" -> 'name') IN ('"foo.inc"') + SELECT (("posthog_group"."group_properties" -> 'name') IN ('"foo.inc"'::jsonb) AND "posthog_group"."group_properties" ? 'name' - AND NOT (("posthog_group"."group_properties" -> 'name') = 'null')) AS "flag_X_condition_0", - (("posthog_group"."group_properties" -> 'name') IN ('"foo2.inc"') + AND NOT (("posthog_group"."group_properties" -> 'name') = 'null'::jsonb)) AS "flag_X_condition_0", + (("posthog_group"."group_properties" -> 'name') IN ('"foo2.inc"'::jsonb) AND "posthog_group"."group_properties" ? 'name' - AND NOT (("posthog_group"."group_properties" -> 'name') = 'null')) AS "flag_X_condition_0" + AND NOT (("posthog_group"."group_properties" -> 'name') = 'null'::jsonb)) AS "flag_X_condition_0" FROM "posthog_group" WHERE ("posthog_group"."team_id" = 2 AND "posthog_group"."group_key" = 'foo2' @@ -371,30 +371,30 @@ --- # name: TestFeatureFlagMatcher.test_numeric_operator_with_cohorts_and_nested_cohorts.1 ' - SELECT (((("posthog_person"."properties" -> 'number') > '"100"' + SELECT (((("posthog_person"."properties" -> 'number') > '"100"'::jsonb AND JSONB_TYPEOF(("posthog_person"."properties" -> 'number')) = ('string')) - OR (("posthog_person"."properties" -> 'number') > '100.0' + OR (("posthog_person"."properties" -> 'number') > '100.0'::jsonb AND JSONB_TYPEOF(("posthog_person"."properties" -> 'number')) = ('number'))) AND "posthog_person"."properties" ? 'number' - AND NOT (("posthog_person"."properties" -> 'number') = 'null')) AS "flag_X_condition_0", - (((("posthog_person"."properties" -> 'version') > '"1.05"' + AND NOT (("posthog_person"."properties" -> 'number') = 'null'::jsonb)) AS "flag_X_condition_0", + (((("posthog_person"."properties" -> 'version') > '"1.05"'::jsonb AND JSONB_TYPEOF(("posthog_person"."properties" -> 'version')) = ('string')) - OR (("posthog_person"."properties" -> 'version') > '1.05' + OR (("posthog_person"."properties" -> 'version') > '1.05'::jsonb AND JSONB_TYPEOF(("posthog_person"."properties" -> 'version')) = ('number'))) AND "posthog_person"."properties" ? 'version' - AND NOT (("posthog_person"."properties" -> 'version') = 'null')) AS "flag_X_condition_0", - (((("posthog_person"."properties" -> 'number') < '"31"' + AND NOT (("posthog_person"."properties" -> 'version') = 'null'::jsonb)) AS "flag_X_condition_0", + (((("posthog_person"."properties" -> 'number') < '"31"'::jsonb AND JSONB_TYPEOF(("posthog_person"."properties" -> 'number')) = ('string')) - OR (("posthog_person"."properties" -> 'number') < '31.0' + OR (("posthog_person"."properties" -> 'number') < '31.0'::jsonb AND JSONB_TYPEOF(("posthog_person"."properties" -> 'number')) = ('number'))) AND "posthog_person"."properties" ? 'number' - AND NOT (("posthog_person"."properties" -> 'number') = 'null') - AND ((("posthog_person"."properties" -> 'nested_prop') > '"20"' + AND NOT (("posthog_person"."properties" -> 'number') = 'null'::jsonb) + AND ((("posthog_person"."properties" -> 'nested_prop') > '"20"'::jsonb AND JSONB_TYPEOF(("posthog_person"."properties" -> 'nested_prop')) = ('string')) - OR (("posthog_person"."properties" -> 'nested_prop') > '20.0' + OR (("posthog_person"."properties" -> 'nested_prop') > '20.0'::jsonb AND JSONB_TYPEOF(("posthog_person"."properties" -> 'nested_prop')) = ('number'))) AND "posthog_person"."properties" ? 'nested_prop' - AND NOT (("posthog_person"."properties" -> 'nested_prop') = 'null')) AS "flag_X_condition_0" + AND NOT (("posthog_person"."properties" -> 'nested_prop') = 'null'::jsonb)) AS "flag_X_condition_0" FROM "posthog_person" INNER JOIN "posthog_persondistinctid" ON ("posthog_person"."id" = "posthog_persondistinctid"."person_id") WHERE ("posthog_persondistinctid"."distinct_id" = '307' @@ -416,12 +416,12 @@ --- # name: TestFeatureFlagMatcher.test_numeric_operator_with_groups_and_person_flags.1 ' - SELECT (((("posthog_person"."properties" -> 'number') >= '"20"' + SELECT (((("posthog_person"."properties" -> 'number') >= '"20"'::jsonb AND JSONB_TYPEOF(("posthog_person"."properties" -> 'number')) = ('string')) - OR (("posthog_person"."properties" -> 'number') >= '20.0' + OR (("posthog_person"."properties" -> 'number') >= '20.0'::jsonb AND JSONB_TYPEOF(("posthog_person"."properties" -> 'number')) = ('number'))) AND "posthog_person"."properties" ? 'number' - AND NOT (("posthog_person"."properties" -> 'number') = 'null')) AS "flag_X_condition_0" + AND NOT (("posthog_person"."properties" -> 'number') = 'null'::jsonb)) AS "flag_X_condition_0" FROM "posthog_person" INNER JOIN "posthog_persondistinctid" ON ("posthog_person"."id" = "posthog_persondistinctid"."person_id") WHERE ("posthog_persondistinctid"."distinct_id" = '307' @@ -431,12 +431,12 @@ --- # name: TestFeatureFlagMatcher.test_numeric_operator_with_groups_and_person_flags.2 ' - SELECT (((("posthog_group"."group_properties" -> 'number') > '"100"' + SELECT (((("posthog_group"."group_properties" -> 'number') > '"100"'::jsonb AND JSONB_TYPEOF(("posthog_group"."group_properties" -> 'number')) = ('string')) - OR (("posthog_group"."group_properties" -> 'number') > '100.0' + OR (("posthog_group"."group_properties" -> 'number') > '100.0'::jsonb AND JSONB_TYPEOF(("posthog_group"."group_properties" -> 'number')) = ('number'))) AND "posthog_group"."group_properties" ? 'number' - AND NOT (("posthog_group"."group_properties" -> 'number') = 'null')) AS "flag_X_condition_0" + AND NOT (("posthog_group"."group_properties" -> 'number') = 'null'::jsonb)) AS "flag_X_condition_0" FROM "posthog_group" WHERE ("posthog_group"."team_id" = 2 AND "posthog_group"."group_key" = 'foo' @@ -445,9 +445,9 @@ --- # name: TestFeatureFlagMatcher.test_numeric_operator_with_groups_and_person_flags.3 ' - SELECT (("posthog_group"."group_properties" -> 'number') > '"100b2c"' + SELECT (("posthog_group"."group_properties" -> 'number') > '"100b2c"'::jsonb AND "posthog_group"."group_properties" ? 'number' - AND NOT (("posthog_group"."group_properties" -> 'number') = 'null')) AS "flag_X_condition_0" + AND NOT (("posthog_group"."group_properties" -> 'number') = 'null'::jsonb)) AS "flag_X_condition_0" FROM "posthog_group" WHERE ("posthog_group"."team_id" = 2 AND "posthog_group"."group_key" = 'foo-project' @@ -456,17 +456,17 @@ --- # name: TestFeatureFlagMatcher.test_super_condition_matches_string ' - SELECT ((("posthog_person"."properties" -> 'is_enabled') = 'true' - OR ("posthog_person"."properties" -> 'is_enabled') = '"true"') + SELECT ((("posthog_person"."properties" -> 'is_enabled') = 'true'::jsonb + OR ("posthog_person"."properties" -> 'is_enabled') = '"true"'::jsonb) AND "posthog_person"."properties" ? 'is_enabled' - AND NOT (("posthog_person"."properties" -> 'is_enabled') = 'null')) AS "flag_X_super_condition", ("posthog_person"."properties" -> 'is_enabled') IS NOT NULL AS "flag_X_super_condition_is_set", - (("posthog_person"."properties" -> 'email') = '"fake@posthog.com"' - AND "posthog_person"."properties" ? 'email' - AND NOT (("posthog_person"."properties" -> 'email') = 'null')) AS "flag_X_condition_0", - (("posthog_person"."properties" -> 'email') = '"test@posthog.com"' - AND "posthog_person"."properties" ? 'email' - AND NOT (("posthog_person"."properties" -> 'email') = 'null')) AS "flag_X_condition_1", - (true) AS "flag_X_condition_2" + AND NOT (("posthog_person"."properties" -> 'is_enabled') = 'null'::jsonb)) AS "flag_X_super_condition", ("posthog_person"."properties" -> 'is_enabled') IS NOT NULL AS "flag_X_super_condition_is_set", + (("posthog_person"."properties" -> 'email') = '"fake@posthog.com"'::jsonb + AND "posthog_person"."properties" ? 'email' + AND NOT (("posthog_person"."properties" -> 'email') = 'null'::jsonb)) AS "flag_X_condition_0", + (("posthog_person"."properties" -> 'email') = '"test@posthog.com"'::jsonb + AND "posthog_person"."properties" ? 'email' + AND NOT (("posthog_person"."properties" -> 'email') = 'null'::jsonb)) AS "flag_X_condition_1", + (true) AS "flag_X_condition_2" FROM "posthog_person" INNER JOIN "posthog_persondistinctid" ON ("posthog_person"."id" = "posthog_persondistinctid"."person_id") WHERE ("posthog_persondistinctid"."distinct_id" = 'test_id' @@ -579,34 +579,34 @@ --- # name: TestFeatureFlagMatcher.test_with_sql_injection_properties_and_other_aliases.3 ' - SELECT (((("posthog_person"."properties" -> 'number space') > '"100"' + SELECT (((("posthog_person"."properties" -> 'number space') > '"100"'::jsonb AND JSONB_TYPEOF(("posthog_person"."properties" -> 'number space')) = ('string')) - OR (("posthog_person"."properties" -> 'number space') > '100.0' + OR (("posthog_person"."properties" -> 'number space') > '100.0'::jsonb AND JSONB_TYPEOF(("posthog_person"."properties" -> 'number space')) = ('number'))) AND "posthog_person"."properties" ? 'number space' - AND NOT (("posthog_person"."properties" -> 'number space') = 'null') + AND NOT (("posthog_person"."properties" -> 'number space') = 'null'::jsonb) AND ((JSONB_TYPEOF(("posthog_person"."properties" -> ';''" SELECT 1; DROP TABLE posthog_featureflag;')) = ('string') - AND ("posthog_person"."properties" -> ';''" SELECT 1; DROP TABLE posthog_featureflag;') > '"100"') + AND ("posthog_person"."properties" -> ';''" SELECT 1; DROP TABLE posthog_featureflag;') > '"100"'::jsonb) OR (JSONB_TYPEOF(("posthog_person"."properties" -> ';''" SELECT 1; DROP TABLE posthog_featureflag;')) = ('number') - AND ("posthog_person"."properties" -> ';''" SELECT 1; DROP TABLE posthog_featureflag;') > '100.0')) + AND ("posthog_person"."properties" -> ';''" SELECT 1; DROP TABLE posthog_featureflag;') > '100.0'::jsonb)) AND "posthog_person"."properties" ? ';''" SELECT 1; DROP TABLE posthog_featureflag;' - AND NOT (("posthog_person"."properties" -> ';''" SELECT 1; DROP TABLE posthog_featureflag;') = 'null')) AS "flag_X_condition_0", + AND NOT (("posthog_person"."properties" -> ';''" SELECT 1; DROP TABLE posthog_featureflag;') = 'null'::jsonb)) AS "flag_X_condition_0", (((JSONB_TYPEOF(("posthog_person"."properties" -> ';''" SELECT 1; DROP TABLE posthog_featureflag;')) = ('string') - AND ("posthog_person"."properties" -> ';''" SELECT 1; DROP TABLE posthog_featureflag;') > '"100"') + AND ("posthog_person"."properties" -> ';''" SELECT 1; DROP TABLE posthog_featureflag;') > '"100"'::jsonb) OR (JSONB_TYPEOF(("posthog_person"."properties" -> ';''" SELECT 1; DROP TABLE posthog_featureflag;')) = ('number') - AND ("posthog_person"."properties" -> ';''" SELECT 1; DROP TABLE posthog_featureflag;') > '100.0')) + AND ("posthog_person"."properties" -> ';''" SELECT 1; DROP TABLE posthog_featureflag;') > '100.0'::jsonb)) AND "posthog_person"."properties" ? ';''" SELECT 1; DROP TABLE posthog_featureflag;' - AND NOT (("posthog_person"."properties" -> ';''" SELECT 1; DROP TABLE posthog_featureflag;') = 'null')) AS "flag_X_condition_1", - (((("posthog_person"."properties" -> 'version!!!') > '"1.05"' + AND NOT (("posthog_person"."properties" -> ';''" SELECT 1; DROP TABLE posthog_featureflag;') = 'null'::jsonb)) AS "flag_X_condition_1", + (((("posthog_person"."properties" -> 'version!!!') > '"1.05"'::jsonb AND JSONB_TYPEOF(("posthog_person"."properties" -> 'version!!!')) = ('string')) - OR (("posthog_person"."properties" -> 'version!!!') > '1.05' + OR (("posthog_person"."properties" -> 'version!!!') > '1.05'::jsonb AND JSONB_TYPEOF(("posthog_person"."properties" -> 'version!!!')) = ('number'))) AND "posthog_person"."properties" ? 'version!!!' - AND NOT (("posthog_person"."properties" -> 'version!!!') = 'null')) AS "flag_X_condition_2", - ((("posthog_person"."properties" -> 'nested_prop --random #comment //test') = '"21"' - OR ("posthog_person"."properties" -> 'nested_prop --random #comment //test') = '21') + AND NOT (("posthog_person"."properties" -> 'version!!!') = 'null'::jsonb)) AS "flag_X_condition_2", + ((("posthog_person"."properties" -> 'nested_prop --random #comment //test') = '"21"'::jsonb + OR ("posthog_person"."properties" -> 'nested_prop --random #comment //test') = '21'::jsonb) AND "posthog_person"."properties" ? 'nested_prop --random #comment //test' - AND NOT (("posthog_person"."properties" -> 'nested_prop --random #comment //test') = 'null')) AS "flag_X_condition_3" + AND NOT (("posthog_person"."properties" -> 'nested_prop --random #comment //test') = 'null'::jsonb)) AS "flag_X_condition_3" FROM "posthog_person" INNER JOIN "posthog_persondistinctid" ON ("posthog_person"."id" = "posthog_persondistinctid"."person_id") WHERE ("posthog_persondistinctid"."distinct_id" = '307' @@ -615,20 +615,103 @@ ' --- # name: TestHashKeyOverridesRaceConditions.test_hash_key_overrides_with_simulated_error_race_conditions_on_person_merging + 'BEGIN' +--- +# name: TestHashKeyOverridesRaceConditions.test_hash_key_overrides_with_simulated_error_race_conditions_on_person_merging.1 ' SET LOCAL statement_timeout = 2 ' --- -# name: TestHashKeyOverridesRaceConditions.test_hash_key_overrides_with_simulated_error_race_conditions_on_person_merging.1 +# name: TestHashKeyOverridesRaceConditions.test_hash_key_overrides_with_simulated_error_race_conditions_on_person_merging.10 + ' + WITH target_person_ids AS + (SELECT team_id, + person_id + FROM posthog_persondistinctid + WHERE team_id = 2 + AND distinct_id = ANY('{other_id,example_id}') ), + existing_overrides AS + (SELECT team_id, + person_id, + feature_flag_key, + hash_key + FROM posthog_featureflaghashkeyoverride + WHERE team_id = 2 + AND person_id IN + (SELECT person_id + FROM target_person_ids) ), + flags_to_override AS + (SELECT key + FROM posthog_featureflag + WHERE team_id = 2 + AND ensure_experience_continuity = TRUE + AND active = TRUE + AND deleted = FALSE + AND key NOT IN + (SELECT feature_flag_key + FROM existing_overrides) ) + INSERT INTO posthog_featureflaghashkeyoverride (team_id, person_id, feature_flag_key, hash_key) + SELECT team_id, + person_id, + key, + 'example_id' + FROM flags_to_override, + target_person_ids + WHERE EXISTS + (SELECT 1 + FROM posthog_person + WHERE id = person_id + AND team_id = 2) ON CONFLICT DO NOTHING + ' +--- +# name: TestHashKeyOverridesRaceConditions.test_hash_key_overrides_with_simulated_error_race_conditions_on_person_merging.11 + 'ROLLBACK' +--- +# name: TestHashKeyOverridesRaceConditions.test_hash_key_overrides_with_simulated_error_race_conditions_on_person_merging.12 + 'BEGIN' +--- +# name: TestHashKeyOverridesRaceConditions.test_hash_key_overrides_with_simulated_error_race_conditions_on_person_merging.13 + ' + + SET LOCAL statement_timeout = 2 + ' +--- +# name: TestHashKeyOverridesRaceConditions.test_hash_key_overrides_with_simulated_error_race_conditions_on_person_merging.14 + ' + SELECT "posthog_persondistinctid"."person_id", + "posthog_persondistinctid"."distinct_id" + FROM "posthog_persondistinctid" + WHERE ("posthog_persondistinctid"."distinct_id" IN ('other_id', + 'example_id') + AND "posthog_persondistinctid"."team_id" = 2) + ' +--- +# name: TestHashKeyOverridesRaceConditions.test_hash_key_overrides_with_simulated_error_race_conditions_on_person_merging.15 + ' + SELECT "posthog_featureflaghashkeyoverride"."feature_flag_key", + "posthog_featureflaghashkeyoverride"."hash_key", + "posthog_featureflaghashkeyoverride"."person_id" + FROM "posthog_featureflaghashkeyoverride" + WHERE ("posthog_featureflaghashkeyoverride"."person_id" IN (1, + 2, + 3, + 4, + 5 /* ... */) + AND "posthog_featureflaghashkeyoverride"."team_id" = 2) + ' +--- +# name: TestHashKeyOverridesRaceConditions.test_hash_key_overrides_with_simulated_error_race_conditions_on_person_merging.16 + 'COMMIT' +--- +# name: TestHashKeyOverridesRaceConditions.test_hash_key_overrides_with_simulated_error_race_conditions_on_person_merging.2 ' WITH target_person_ids AS (SELECT team_id, person_id FROM posthog_persondistinctid WHERE team_id = 2 - AND distinct_id IN ('other_id', - 'example_id') ), + AND distinct_id = ANY('{other_id,example_id}') ), existing_overrides AS (SELECT team_id, person_id, @@ -650,21 +733,26 @@ FROM existing_overrides) ' --- -# name: TestHashKeyOverridesRaceConditions.test_hash_key_overrides_with_simulated_error_race_conditions_on_person_merging.2 +# name: TestHashKeyOverridesRaceConditions.test_hash_key_overrides_with_simulated_error_race_conditions_on_person_merging.3 + 'COMMIT' +--- +# name: TestHashKeyOverridesRaceConditions.test_hash_key_overrides_with_simulated_error_race_conditions_on_person_merging.4 + 'BEGIN' +--- +# name: TestHashKeyOverridesRaceConditions.test_hash_key_overrides_with_simulated_error_race_conditions_on_person_merging.5 ' SET LOCAL statement_timeout = 2 ' --- -# name: TestHashKeyOverridesRaceConditions.test_hash_key_overrides_with_simulated_error_race_conditions_on_person_merging.3 +# name: TestHashKeyOverridesRaceConditions.test_hash_key_overrides_with_simulated_error_race_conditions_on_person_merging.6 ' WITH target_person_ids AS (SELECT team_id, person_id FROM posthog_persondistinctid WHERE team_id = 2 - AND distinct_id IN ('other_id', - 'example_id') ), + AND distinct_id = ANY('{other_id,example_id}') ), existing_overrides AS (SELECT team_id, person_id, @@ -699,21 +787,35 @@ AND team_id = 2) ON CONFLICT DO NOTHING ' --- -# name: TestHashKeyOverridesRaceConditions.test_hash_key_overrides_with_simulated_error_race_conditions_on_person_merging.4 +# name: TestHashKeyOverridesRaceConditions.test_hash_key_overrides_with_simulated_error_race_conditions_on_person_merging.7 + 'ROLLBACK' +--- +# name: TestHashKeyOverridesRaceConditions.test_hash_key_overrides_with_simulated_error_race_conditions_on_person_merging.8 + 'BEGIN' +--- +# name: TestHashKeyOverridesRaceConditions.test_hash_key_overrides_with_simulated_error_race_conditions_on_person_merging.9 ' SET LOCAL statement_timeout = 2 ' --- -# name: TestHashKeyOverridesRaceConditions.test_hash_key_overrides_with_simulated_error_race_conditions_on_person_merging.5 +# name: TestHashKeyOverridesRaceConditions.test_hash_key_overrides_with_simulated_race_conditions_on_person_merging + 'BEGIN' +--- +# name: TestHashKeyOverridesRaceConditions.test_hash_key_overrides_with_simulated_race_conditions_on_person_merging.1 + ' + + SET LOCAL statement_timeout = 2 + ' +--- +# name: TestHashKeyOverridesRaceConditions.test_hash_key_overrides_with_simulated_race_conditions_on_person_merging.10 ' WITH target_person_ids AS (SELECT team_id, person_id FROM posthog_persondistinctid WHERE team_id = 2 - AND distinct_id IN ('other_id', - 'example_id') ), + AND distinct_id = ANY('{other_id,example_id}') ), existing_overrides AS (SELECT team_id, person_id, @@ -748,13 +850,19 @@ AND team_id = 2) ON CONFLICT DO NOTHING ' --- -# name: TestHashKeyOverridesRaceConditions.test_hash_key_overrides_with_simulated_error_race_conditions_on_person_merging.6 +# name: TestHashKeyOverridesRaceConditions.test_hash_key_overrides_with_simulated_race_conditions_on_person_merging.11 + 'COMMIT' +--- +# name: TestHashKeyOverridesRaceConditions.test_hash_key_overrides_with_simulated_race_conditions_on_person_merging.12 + 'BEGIN' +--- +# name: TestHashKeyOverridesRaceConditions.test_hash_key_overrides_with_simulated_race_conditions_on_person_merging.13 ' SET LOCAL statement_timeout = 2 ' --- -# name: TestHashKeyOverridesRaceConditions.test_hash_key_overrides_with_simulated_error_race_conditions_on_person_merging.7 +# name: TestHashKeyOverridesRaceConditions.test_hash_key_overrides_with_simulated_race_conditions_on_person_merging.14 ' SELECT "posthog_persondistinctid"."person_id", "posthog_persondistinctid"."distinct_id" @@ -764,7 +872,7 @@ AND "posthog_persondistinctid"."team_id" = 2) ' --- -# name: TestHashKeyOverridesRaceConditions.test_hash_key_overrides_with_simulated_error_race_conditions_on_person_merging.8 +# name: TestHashKeyOverridesRaceConditions.test_hash_key_overrides_with_simulated_race_conditions_on_person_merging.15 ' SELECT "posthog_featureflaghashkeyoverride"."feature_flag_key", "posthog_featureflaghashkeyoverride"."hash_key", @@ -778,21 +886,17 @@ AND "posthog_featureflaghashkeyoverride"."team_id" = 2) ' --- -# name: TestHashKeyOverridesRaceConditions.test_hash_key_overrides_with_simulated_race_conditions_on_person_merging - ' - - SET LOCAL statement_timeout = 2 - ' +# name: TestHashKeyOverridesRaceConditions.test_hash_key_overrides_with_simulated_race_conditions_on_person_merging.16 + 'COMMIT' --- -# name: TestHashKeyOverridesRaceConditions.test_hash_key_overrides_with_simulated_race_conditions_on_person_merging.1 +# name: TestHashKeyOverridesRaceConditions.test_hash_key_overrides_with_simulated_race_conditions_on_person_merging.2 ' WITH target_person_ids AS (SELECT team_id, person_id FROM posthog_persondistinctid WHERE team_id = 2 - AND distinct_id IN ('other_id', - 'example_id') ), + AND distinct_id = ANY('{other_id,example_id}') ), existing_overrides AS (SELECT team_id, person_id, @@ -814,70 +918,26 @@ FROM existing_overrides) ' --- -# name: TestHashKeyOverridesRaceConditions.test_hash_key_overrides_with_simulated_race_conditions_on_person_merging.2 - ' - - SET LOCAL statement_timeout = 2 - ' ---- # name: TestHashKeyOverridesRaceConditions.test_hash_key_overrides_with_simulated_race_conditions_on_person_merging.3 - ' - WITH target_person_ids AS - (SELECT team_id, - person_id - FROM posthog_persondistinctid - WHERE team_id = 2 - AND distinct_id IN ('other_id', - 'example_id') ), - existing_overrides AS - (SELECT team_id, - person_id, - feature_flag_key, - hash_key - FROM posthog_featureflaghashkeyoverride - WHERE team_id = 2 - AND person_id IN - (SELECT person_id - FROM target_person_ids) ), - flags_to_override AS - (SELECT key - FROM posthog_featureflag - WHERE team_id = 2 - AND ensure_experience_continuity = TRUE - AND active = TRUE - AND deleted = FALSE - AND key NOT IN - (SELECT feature_flag_key - FROM existing_overrides) ) - INSERT INTO posthog_featureflaghashkeyoverride (team_id, person_id, feature_flag_key, hash_key) - SELECT team_id, - person_id, - key, - 'example_id' - FROM flags_to_override, - target_person_ids - WHERE EXISTS - (SELECT 1 - FROM posthog_person - WHERE id = person_id - AND team_id = 2) ON CONFLICT DO NOTHING - ' + 'COMMIT' --- # name: TestHashKeyOverridesRaceConditions.test_hash_key_overrides_with_simulated_race_conditions_on_person_merging.4 + 'BEGIN' +--- +# name: TestHashKeyOverridesRaceConditions.test_hash_key_overrides_with_simulated_race_conditions_on_person_merging.5 ' SET LOCAL statement_timeout = 2 ' --- -# name: TestHashKeyOverridesRaceConditions.test_hash_key_overrides_with_simulated_race_conditions_on_person_merging.5 +# name: TestHashKeyOverridesRaceConditions.test_hash_key_overrides_with_simulated_race_conditions_on_person_merging.6 ' WITH target_person_ids AS (SELECT team_id, person_id FROM posthog_persondistinctid WHERE team_id = 2 - AND distinct_id IN ('other_id', - 'example_id') ), + AND distinct_id = ANY('{other_id,example_id}') ), existing_overrides AS (SELECT team_id, person_id, @@ -912,33 +972,15 @@ AND team_id = 2) ON CONFLICT DO NOTHING ' --- -# name: TestHashKeyOverridesRaceConditions.test_hash_key_overrides_with_simulated_race_conditions_on_person_merging.6 - ' - - SET LOCAL statement_timeout = 2 - ' ---- # name: TestHashKeyOverridesRaceConditions.test_hash_key_overrides_with_simulated_race_conditions_on_person_merging.7 - ' - SELECT "posthog_persondistinctid"."person_id", - "posthog_persondistinctid"."distinct_id" - FROM "posthog_persondistinctid" - WHERE ("posthog_persondistinctid"."distinct_id" IN ('other_id', - 'example_id') - AND "posthog_persondistinctid"."team_id" = 2) - ' + 'ROLLBACK' --- # name: TestHashKeyOverridesRaceConditions.test_hash_key_overrides_with_simulated_race_conditions_on_person_merging.8 + 'BEGIN' +--- +# name: TestHashKeyOverridesRaceConditions.test_hash_key_overrides_with_simulated_race_conditions_on_person_merging.9 ' - SELECT "posthog_featureflaghashkeyoverride"."feature_flag_key", - "posthog_featureflaghashkeyoverride"."hash_key", - "posthog_featureflaghashkeyoverride"."person_id" - FROM "posthog_featureflaghashkeyoverride" - WHERE ("posthog_featureflaghashkeyoverride"."person_id" IN (1, - 2, - 3, - 4, - 5 /* ... */) - AND "posthog_featureflaghashkeyoverride"."team_id" = 2) + + SET LOCAL statement_timeout = 2 ' ---