11
11
from django .core .exceptions import SuspiciousOperation
12
12
from django .db .models import Expression , Model , Q
13
13
from django .db .models .fields .related import RelatedField
14
- from django .db .models .sql .compiler import (
15
- SQLAggregateCompiler ,
16
- SQLCompiler ,
17
- SQLDeleteCompiler ,
18
- SQLInsertCompiler ,
19
- SQLUpdateCompiler ,
20
- )
14
+ from django .db .models .sql import compiler as django_compiler
21
15
from django .db .utils import ProgrammingError
22
16
23
17
from .expressions import HStoreValue
@@ -77,25 +71,25 @@ def append_caller_to_sql(sql):
77
71
return sql
78
72
79
73
80
- class PostgresCompiler ( SQLCompiler ):
74
+ class SQLCompiler ( django_compiler . SQLCompiler ):
81
75
def as_sql (self , * args , ** kwargs ):
82
76
sql , params = super ().as_sql (* args , ** kwargs )
83
77
return append_caller_to_sql (sql ), params
84
78
85
79
86
- class PostgresDeleteCompiler ( SQLDeleteCompiler ):
80
+ class SQLDeleteCompiler ( django_compiler . SQLDeleteCompiler ):
87
81
def as_sql (self , * args , ** kwargs ):
88
82
sql , params = super ().as_sql (* args , ** kwargs )
89
83
return append_caller_to_sql (sql ), params
90
84
91
85
92
- class PostgresAggregateCompiler ( SQLAggregateCompiler ):
86
+ class SQLAggregateCompiler ( django_compiler . SQLAggregateCompiler ):
93
87
def as_sql (self , * args , ** kwargs ):
94
88
sql , params = super ().as_sql (* args , ** kwargs )
95
89
return append_caller_to_sql (sql ), params
96
90
97
91
98
- class PostgresUpdateCompiler ( SQLUpdateCompiler ):
92
+ class SQLUpdateCompiler ( django_compiler . SQLUpdateCompiler ):
99
93
"""Compiler for SQL UPDATE statements that allows us to use expressions
100
94
inside HStore values.
101
95
@@ -152,7 +146,7 @@ def _does_dict_contain_expression(data: dict) -> bool:
152
146
return False
153
147
154
148
155
- class PostgresInsertCompiler ( SQLInsertCompiler ):
149
+ class SQLInsertCompiler ( django_compiler . SQLInsertCompiler ):
156
150
"""Compiler for SQL INSERT statements."""
157
151
158
152
def as_sql (self , * args , ** kwargs ):
@@ -165,7 +159,7 @@ def as_sql(self, *args, **kwargs):
165
159
return queries
166
160
167
161
168
- class PostgresInsertOnConflictCompiler (SQLInsertCompiler ):
162
+ class PostgresInsertOnConflictCompiler (django_compiler . SQLInsertCompiler ):
169
163
"""Compiler for SQL INSERT statements."""
170
164
171
165
def __init__ (self , * args , ** kwargs ):
@@ -407,7 +401,7 @@ def _format_field_value(self, field_name) -> str:
407
401
if isinstance (field , RelatedField ) and isinstance (value , Model ):
408
402
value = value .pk
409
403
410
- return SQLInsertCompiler .prepare_value (
404
+ return django_compiler . SQLInsertCompiler .prepare_value (
411
405
self ,
412
406
field ,
413
407
# Note: this deliberately doesn't use `pre_save_val` as we don't
0 commit comments