Skip to content

Commit 4afac06

Browse files
committed
Remove the code that supports Django-4.0 or earlier.
1 parent a4fe7f5 commit 4afac06

File tree

1 file changed

+20
-37
lines changed

1 file changed

+20
-37
lines changed

django_redshift_backend/base.py

+20-37
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import logging
1313
import json
1414

15-
import django
1615
from django.utils import timezone
1716
from django.conf import settings
1817
from django.core.exceptions import FieldDoesNotExist, ImproperlyConfigured
@@ -142,26 +141,14 @@ def distinct_sql(self, fields, *args):
142141
)
143142
return super(DatabaseOperations, self).distinct_sql(fields, *args)
144143

145-
if django.VERSION < (4, 2):
146-
147-
def insert_statement(self, ignore_conflicts=False):
148-
return "INSERT INTO"
149-
150-
def ignore_conflicts_suffix_sql(self, ignore_conflicts=None):
151-
return ""
152-
153-
else: # for >= dj42
154-
155-
def adapt_integerfield_value(self, value, internal_type):
156-
return value
144+
def adapt_integerfield_value(self, value, internal_type):
145+
return value
157146

158-
def insert_statement(self, on_conflict=None):
159-
return "INSERT INTO"
147+
def insert_statement(self, on_conflict=None):
148+
return "INSERT INTO"
160149

161-
def on_conflict_suffix_sql(
162-
self, fields, on_conflict, update_fields, unique_fields
163-
):
164-
return ""
150+
def on_conflict_suffix_sql(self, fields, on_conflict, update_fields, unique_fields):
151+
return ""
165152

166153
# copy from djang 5.0 postgresql/operations.py
167154
def prepare_join_on_clause(self, lhs_table, lhs_field, rhs_table, rhs_field):
@@ -1357,21 +1344,19 @@ def get_table_list(self, cursor):
13571344
if row[0] not in self.ignored_tables
13581345
]
13591346

1360-
if django.VERSION >= (4, 2):
1361-
1362-
def get_primary_key_column(self, cursor, table_name):
1363-
"""
1364-
Return the name of the primary key column for the given table.
1365-
"""
1366-
columns = self.get_primary_key_columns(cursor, table_name)
1367-
return columns[0] if columns else None
1368-
1369-
def get_primary_key_columns(self, cursor, table_name):
1370-
"""Return a list of primary key columns for the given table."""
1371-
for constraint in self.get_constraints(cursor, table_name).values():
1372-
if constraint["primary_key"]:
1373-
return constraint["columns"]
1374-
return None
1347+
def get_primary_key_column(self, cursor, table_name):
1348+
"""
1349+
Return the name of the primary key column for the given table.
1350+
"""
1351+
columns = self.get_primary_key_columns(cursor, table_name)
1352+
return columns[0] if columns else None
1353+
1354+
def get_primary_key_columns(self, cursor, table_name):
1355+
"""Return a list of primary key columns for the given table."""
1356+
for constraint in self.get_constraints(cursor, table_name).values():
1357+
if constraint["primary_key"]:
1358+
return constraint["columns"]
1359+
return None
13751360

13761361

13771362
class DatabaseWrapper(BasePGDatabaseWrapper):
@@ -1385,9 +1370,7 @@ class DatabaseWrapper(BasePGDatabaseWrapper):
13851370
def __init__(self, *args, **kwargs):
13861371
super(DatabaseWrapper, self).__init__(*args, **kwargs)
13871372

1388-
if django.VERSION >= (4, 2):
1389-
self.atomic_blocks = []
1390-
1373+
self.atomic_blocks = []
13911374
self.features = DatabaseFeatures(self)
13921375
self.ops = DatabaseOperations(self)
13931376
self.client = DatabaseClient(self)

0 commit comments

Comments
 (0)