mirror of
https://github.com/PostHog/posthog.git
synced 2024-11-24 09:14:46 +01:00
f36495bec6
* Don't colorize sql for output * Handle setting array props as values * Handle arrays exact/is_not property filters Also updates tests to use parameterization * Avoid autoclosing PropertyFilter popup As key changes, old one got removed from DOM * Improve filter UX Don't allow filter to become multi-line and keep inputs the same size. Previous flex={1} was doing flex: 1 1 auto which was messing things up * Fix typescript issue * Handle array lookups in postgres * Update types * Fix fixture to recreate tables * Make replace spaces logic consistent with what was there before * Handle list filtering better in postgres * Update frontend tests * Handle edge case: Switching between multi operator and single operators
86 lines
2.3 KiB
Python
86 lines
2.3 KiB
Python
import pytest
|
|
from infi.clickhouse_orm import Database
|
|
|
|
from ee.clickhouse.client import sync_execute
|
|
from ee.clickhouse.models.person import Person
|
|
from posthog.settings import (
|
|
CLICKHOUSE_DATABASE,
|
|
CLICKHOUSE_HTTP_URL,
|
|
CLICKHOUSE_PASSWORD,
|
|
CLICKHOUSE_USER,
|
|
CLICKHOUSE_VERIFY,
|
|
)
|
|
|
|
|
|
@pytest.fixture(scope="package")
|
|
def django_db_setup(django_db_setup, django_db_keepdb):
|
|
database = Database(
|
|
CLICKHOUSE_DATABASE,
|
|
db_url=CLICKHOUSE_HTTP_URL,
|
|
username=CLICKHOUSE_USER,
|
|
password=CLICKHOUSE_PASSWORD,
|
|
verify_ssl_cert=CLICKHOUSE_VERIFY,
|
|
)
|
|
|
|
if not django_db_keepdb:
|
|
try:
|
|
database.drop_database()
|
|
except:
|
|
pass
|
|
|
|
if not django_db_keepdb or not database.db_exists:
|
|
database.create_database()
|
|
|
|
database.migrate("ee.clickhouse.migrations")
|
|
# Make DELETE / UPDATE synchronous to avoid flaky tests
|
|
sync_execute("SET mutations_sync = 1")
|
|
|
|
yield
|
|
|
|
if not django_db_keepdb:
|
|
try:
|
|
database.drop_database()
|
|
except:
|
|
pass
|
|
|
|
|
|
@pytest.fixture
|
|
def db(db):
|
|
from ee.clickhouse.sql.events import (
|
|
DROP_EVENTS_TABLE_SQL,
|
|
DROP_EVENTS_WITH_ARRAY_PROPS_TABLE_SQL,
|
|
EVENTS_TABLE_SQL,
|
|
EVENTS_WITH_PROPS_TABLE_SQL,
|
|
)
|
|
from ee.clickhouse.sql.person import (
|
|
DROP_PERSON_DISTINCT_ID_TABLE_SQL,
|
|
DROP_PERSON_STATIC_COHORT_TABLE_SQL,
|
|
DROP_PERSON_TABLE_SQL,
|
|
PERSON_STATIC_COHORT_TABLE_SQL,
|
|
PERSONS_DISTINCT_ID_TABLE_SQL,
|
|
PERSONS_TABLE_SQL,
|
|
)
|
|
from ee.clickhouse.sql.session_recording_events import (
|
|
DROP_SESSION_RECORDING_EVENTS_TABLE_SQL,
|
|
SESSION_RECORDING_EVENTS_TABLE_SQL,
|
|
)
|
|
|
|
yield
|
|
|
|
try:
|
|
sync_execute(DROP_EVENTS_TABLE_SQL)
|
|
sync_execute(DROP_EVENTS_WITH_ARRAY_PROPS_TABLE_SQL)
|
|
sync_execute(DROP_PERSON_TABLE_SQL)
|
|
sync_execute(DROP_PERSON_DISTINCT_ID_TABLE_SQL)
|
|
sync_execute(DROP_PERSON_STATIC_COHORT_TABLE_SQL)
|
|
sync_execute(DROP_SESSION_RECORDING_EVENTS_TABLE_SQL)
|
|
|
|
sync_execute(EVENTS_TABLE_SQL)
|
|
sync_execute(EVENTS_WITH_PROPS_TABLE_SQL)
|
|
sync_execute(SESSION_RECORDING_EVENTS_TABLE_SQL)
|
|
sync_execute(PERSONS_TABLE_SQL)
|
|
sync_execute(PERSONS_DISTINCT_ID_TABLE_SQL)
|
|
sync_execute(PERSON_STATIC_COHORT_TABLE_SQL)
|
|
except:
|
|
pass
|