Просмотр исходного кода

ref: remove obsolete sentry.db.postgres.creation (#64577)

made obsolete in
https://github.com/django/django/commit/3cafb783f3f711c7413ba2b8d7c8ff750bd4d6e1
(4.2a1)

<!-- Describe your PR here. -->
anthony sottile 1 год назад
Родитель
Сommit
5a2b9ee123
3 измененных файлов с 0 добавлено и 33 удалено
  1. 0 1
      pyproject.toml
  2. 0 2
      src/sentry/db/postgres/base.py
  3. 0 30
      src/sentry/db/postgres/creation.py

+ 0 - 1
pyproject.toml

@@ -268,7 +268,6 @@ module = [
     "sentry.db.models.query",
     "sentry.db.models.utils",
     "sentry.db.postgres.base",
-    "sentry.db.postgres.creation",
     "sentry.db.router",
     "sentry.digests.notifications",
     "sentry.discover.endpoints.discover_key_transactions",

+ 0 - 2
src/sentry/db/postgres/base.py

@@ -7,7 +7,6 @@ from django.db.backends.postgresql.operations import DatabaseOperations
 
 from sentry.utils.strings import strip_lone_surrogates
 
-from .creation import SentryDatabaseCreation
 from .decorators import (
     auto_reconnect_connection,
     auto_reconnect_cursor,
@@ -93,7 +92,6 @@ class CursorWrapper:
 
 
 class DatabaseWrapper(DjangoDatabaseWrapper):
-    creation_class = SentryDatabaseCreation
     SchemaEditorClass = DatabaseSchemaEditorProxy
 
     def __init__(self, *args, **kwargs):

+ 0 - 30
src/sentry/db/postgres/creation.py

@@ -1,30 +0,0 @@
-import sys
-
-from django.db.backends.postgresql.creation import DatabaseCreation
-from psycopg2 import errorcodes
-
-
-class SentryDatabaseCreation(DatabaseCreation):
-    def _execute_create_test_db(self, cursor, parameters, keepdb=False):
-        """
-        This is just copied from the base class and should behave the same. The only difference is
-        that as well as checking `pgcode` we also do string matching on the Exception. This is to
-        work around an issue where `pgcode` is missing when we run tests.
-        """
-        try:
-            # Explicitly skip the overridden `_execute_create_test_db` and just call the one from
-            # its superclass
-            super(DatabaseCreation, self)._execute_create_test_db(cursor, parameters, keepdb)
-        except Exception as e:
-            if (
-                getattr(e.__cause__, "pgcode", "") != errorcodes.DUPLICATE_DATABASE
-                and "DuplicateDatabase" not in str(e)
-                and "already exists" not in str(e)
-            ):
-                # All errors except "database already exists" cancel tests.
-                sys.stderr.write("Got an error creating the test database: %s\n" % e)
-                sys.exit(2)
-            elif not keepdb:
-                # If the database should be kept, ignore "database already
-                # exists".
-                raise