Skip to content

Commit

Permalink
adjust nits
Browse files Browse the repository at this point in the history
  • Loading branch information
shimizukawa committed Feb 14, 2022
1 parent 4578939 commit f515272
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions django_redshift_backend/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
DatabaseIntrospection as BasePGDatabaseIntrospection,
)
from django.db.models import Index

from django.db.utils import NotSupportedError

from django_redshift_backend.distkey import DistKey
Expand Down Expand Up @@ -566,7 +565,6 @@ class DatabaseCreation(BasePGDatabaseCreation):


class DatabaseIntrospection(BasePGDatabaseIntrospection):
pass

def get_table_description(self, cursor, table_name):
"""
Expand All @@ -579,6 +577,8 @@ def get_table_description(self, cursor, table_name):

# This function is based on the version from the Django postgres backend
# from before support for collations were introduced in Django 3.2
# https://github.com/django/django/blob/3.1.14/django/db/backends/
# postgresql/introspection.py#L66-L94
cursor.execute("""
SELECT
a.attname AS column_name,
Expand Down Expand Up @@ -624,6 +624,8 @@ def get_constraints(self, cursor, table_name):
indexes.
"""
# Based on code from Django 3.2
# https://github.com/django/django/blob/3.2.12/django/db/backends/
# postgresql/introspection.py#L148-L182
constraints = {}
# Loop over the key table, collecting things as constraints. The column
# array must return column names in the same order in which they were
Expand Down Expand Up @@ -666,6 +668,8 @@ def get_constraints(self, cursor, table_name):

# Now get indexes
# Based on code from Django 1.7
# https://github.com/django/django/blob/1.7.11/django/db/backends/
# postgresql_psycopg2/introspection.py#L182-L207
cursor.execute("""
SELECT
c2.relname,
Expand Down

0 comments on commit f515272

Please sign in to comment.