Skip to content

Commit

Permalink
Fix psycopg3 issues
Browse files Browse the repository at this point in the history
  • Loading branch information
webjunkie committed Nov 17, 2023
1 parent 9c9bcb4 commit 677d38a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions posthog/api/property_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def with_properties_to_filter(self, properties_to_filter: Optional[str]) -> "Que
return dataclasses.replace(
self,
name_filter="AND name = ANY(%(names)s)",
params={**self.params, "names": tuple(properties_to_filter.split(","))},
params={**self.params, "names": properties_to_filter.split(",")},
)
else:
return self
Expand Down Expand Up @@ -227,7 +227,7 @@ def with_event_property_filter(
event_name_join_filter=event_name_join_filter,
event_name_filter=event_name_filter,
event_property_join_type="INNER JOIN" if filter_by_event_names else "LEFT JOIN",
params={**self.params, "event_names": tuple(event_names or [])},
params={**self.params, "event_names": event_names or []},
)

def with_search(self, search_query: str, search_kwargs: Dict) -> "QueryContext":
Expand All @@ -241,7 +241,7 @@ def with_excluded_properties(self, excluded_properties: Optional[str], type: str
if excluded_properties:
excluded_properties = json.loads(excluded_properties)

excluded_list = tuple(
excluded_list = list(
set.union(
set(excluded_properties or []),
EVENTS_HIDDEN_PROPERTY_DEFINITIONS if type == "event" else [],
Expand Down
2 changes: 1 addition & 1 deletion posthog/tasks/usage_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from django.db import connection
from django.db.models import Count, Q
from posthoganalytics.client import Client
from psycopg2 import sql
from psycopg import sql
from sentry_sdk import capture_exception

from posthog import version_requirement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from typing import TypedDict
from uuid import UUID, uuid4

import psycopg2
import psycopg
import pytest
from django.conf import settings
from freezegun.api import freeze_time
Expand Down Expand Up @@ -794,8 +794,8 @@ def django_db_setup_fixture():

@pytest.fixture
def pg_connection():
"""Manage a Postgres connection with psycopg2."""
conn = psycopg2.connect(
"""Manage a Postgres connection with psycopg."""
conn = psycopg.connect(
dbname=settings.DATABASES["default"]["NAME"],
user=settings.DATABASES["default"]["USER"],
password=settings.DATABASES["default"]["PASSWORD"],
Expand Down
4 changes: 2 additions & 2 deletions posthog/temporal/workflows/squash_person_overrides.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from typing import AsyncIterator, Iterable, NamedTuple
from uuid import UUID

import psycopg2
import psycopg
from temporalio import activity, workflow
from temporalio.common import RetryPolicy

Expand Down Expand Up @@ -446,7 +446,7 @@ async def delete_squashed_person_overrides_from_postgres(inputs: QueryInputs) ->
from django.conf import settings

activity.logger.info("Deleting squashed persons from Postgres")
with psycopg2.connect(
with psycopg.connect(
dbname=settings.DATABASES["default"]["NAME"],
user=settings.DATABASES["default"]["USER"],
password=settings.DATABASES["default"]["PASSWORD"],
Expand Down

0 comments on commit 677d38a

Please sign in to comment.