|
@@ -1,28 +1,20 @@
|
|
|
from django.core.exceptions import FieldError, FullResultSet
|
|
|
from django.db.models.expressions import Col
|
|
|
-from django.db.models.sql import compiler
|
|
|
+from django.db.models.sql.compiler import SQLAggregateCompiler, SQLCompiler
|
|
|
+from django.db.models.sql.compiler import SQLDeleteCompiler as BaseSQLDeleteCompiler
|
|
|
+from django.db.models.sql.compiler import SQLInsertCompiler
|
|
|
+from django.db.models.sql.compiler import SQLUpdateCompiler as BaseSQLUpdateCompiler
|
|
|
|
|
|
+__all__ = [
|
|
|
+ "SQLAggregateCompiler",
|
|
|
+ "SQLCompiler",
|
|
|
+ "SQLDeleteCompiler",
|
|
|
+ "SQLInsertCompiler",
|
|
|
+ "SQLUpdateCompiler",
|
|
|
+]
|
|
|
|
|
|
-class SQLCompiler(compiler.SQLCompiler):
|
|
|
- def as_subquery_condition(self, alias, columns, compiler):
|
|
|
- qn = compiler.quote_name_unless_alias
|
|
|
- qn2 = self.connection.ops.quote_name
|
|
|
- sql, params = self.as_sql()
|
|
|
- return (
|
|
|
- "(%s) IN (%s)"
|
|
|
- % (
|
|
|
- ", ".join("%s.%s" % (qn(alias), qn2(column)) for column in columns),
|
|
|
- sql,
|
|
|
- ),
|
|
|
- params,
|
|
|
- )
|
|
|
-
|
|
|
-
|
|
|
-class SQLInsertCompiler(compiler.SQLInsertCompiler, SQLCompiler):
|
|
|
- pass
|
|
|
|
|
|
-
|
|
|
-class SQLDeleteCompiler(compiler.SQLDeleteCompiler, SQLCompiler):
|
|
|
+class SQLDeleteCompiler(BaseSQLDeleteCompiler):
|
|
|
def as_sql(self):
|
|
|
# Prefer the non-standard DELETE FROM syntax over the SQL generated by
|
|
|
# the SQLDeleteCompiler's default implementation when multiple tables
|
|
@@ -52,7 +44,7 @@ class SQLDeleteCompiler(compiler.SQLDeleteCompiler, SQLCompiler):
|
|
|
return " ".join(result), tuple(params)
|
|
|
|
|
|
|
|
|
-class SQLUpdateCompiler(compiler.SQLUpdateCompiler, SQLCompiler):
|
|
|
+class SQLUpdateCompiler(BaseSQLUpdateCompiler):
|
|
|
def as_sql(self):
|
|
|
update_query, update_params = super().as_sql()
|
|
|
# MySQL and MariaDB support UPDATE ... ORDER BY syntax.
|
|
@@ -78,7 +70,3 @@ class SQLUpdateCompiler(compiler.SQLUpdateCompiler, SQLCompiler):
|
|
|
# removed in .update() and cannot be resolved.
|
|
|
pass
|
|
|
return update_query, update_params
|
|
|
-
|
|
|
-
|
|
|
-class SQLAggregateCompiler(compiler.SQLAggregateCompiler, SQLCompiler):
|
|
|
- pass
|