Skip to content

Commit

Permalink
Merge pull request #44 from groveco/PAO-2479-updating-django-package
Browse files Browse the repository at this point in the history
updating django package.
  • Loading branch information
rrajputgrove authored May 29, 2024
2 parents 897a646 + b1bdfce commit 9a90da9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions segments/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import redis

from django.db import connections
from django.db.models.query_utils import InvalidQuery
from django.core.exceptions import FieldError

from segments import app_settings

Expand Down Expand Up @@ -247,7 +247,7 @@ def execute_raw_user_query(self, sql):
Helper that returns an array containing a RawQuerySet of user ids and their total count.
"""
if sql is None or not isinstance(sql, str) or "select" not in sql.lower():
raise InvalidQuery
raise FieldError

with connections[app_settings.SEGMENTS_EXEC_CONNECTION].cursor() as cursor:
# Fetch the raw queryset of ids and count them
Expand Down
4 changes: 2 additions & 2 deletions segments/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging

from django.db import models, DatabaseError, OperationalError
from django.db.models.query_utils import InvalidQuery
from django.core.exceptions import FieldError
from django.conf import settings
from django.db.models import signals
from django.utils import timezone
Expand All @@ -27,7 +27,7 @@ def _wrapper(*args, **kwargs):
try:
return fn(*args, **kwargs)

except InvalidQuery:
except FieldError:
raise SegmentExecutionError(
"SQL definition must include the primary key of the %s model"
% settings.AUTH_USER_MODEL
Expand Down
4 changes: 2 additions & 2 deletions segments/tests/test_helpers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import fakeredis
from django.db.models.query_utils import InvalidQuery
from django.core.exceptions import FieldError
from django.db.utils import OperationalError
from django.test import TestCase

Expand Down Expand Up @@ -96,7 +96,7 @@ def setUp(self):
def test_invalid_raw_user_query_raises_exception(self):
empty_queries = ["", None, 1, True, "any string that does not contain s.elect"]
for query in empty_queries:
with self.assertRaises(InvalidQuery, msg=f'Passed query: "{query}"') as cm:
with self.assertRaises(FieldError, msg=f'Passed query: "{query}"') as cm:
generator = self.helper.execute_raw_user_query(query)
for _ in generator:
pass
Expand Down

0 comments on commit 9a90da9

Please sign in to comment.