12
12
import logging
13
13
import json
14
14
15
- import django
16
15
from django .utils import timezone
17
16
from django .conf import settings
18
17
from django .core .exceptions import FieldDoesNotExist , ImproperlyConfigured
@@ -142,26 +141,14 @@ def distinct_sql(self, fields, *args):
142
141
)
143
142
return super (DatabaseOperations , self ).distinct_sql (fields , * args )
144
143
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
157
146
158
- def insert_statement (self , on_conflict = None ):
159
- return "INSERT INTO"
147
+ def insert_statement (self , on_conflict = None ):
148
+ return "INSERT INTO"
160
149
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 ""
165
152
166
153
# copy from djang 5.0 postgresql/operations.py
167
154
def prepare_join_on_clause (self , lhs_table , lhs_field , rhs_table , rhs_field ):
@@ -1357,21 +1344,19 @@ def get_table_list(self, cursor):
1357
1344
if row [0 ] not in self .ignored_tables
1358
1345
]
1359
1346
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
1375
1360
1376
1361
1377
1362
class DatabaseWrapper (BasePGDatabaseWrapper ):
@@ -1385,9 +1370,7 @@ class DatabaseWrapper(BasePGDatabaseWrapper):
1385
1370
def __init__ (self , * args , ** kwargs ):
1386
1371
super (DatabaseWrapper , self ).__init__ (* args , ** kwargs )
1387
1372
1388
- if django .VERSION >= (4 , 2 ):
1389
- self .atomic_blocks = []
1390
-
1373
+ self .atomic_blocks = []
1391
1374
self .features = DatabaseFeatures (self )
1392
1375
self .ops = DatabaseOperations (self )
1393
1376
self .client = DatabaseClient (self )
0 commit comments