diff options
Diffstat (limited to 'django/db/models/sql')
| -rw-r--r-- | django/db/models/sql/compiler.py | 31 | ||||
| -rw-r--r-- | django/db/models/sql/datastructures.py | 3 | ||||
| -rw-r--r-- | django/db/models/sql/query.py | 3 |
3 files changed, 14 insertions, 23 deletions
diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py index 13a7ec7263..28d412e11a 100644 --- a/django/db/models/sql/compiler.py +++ b/django/db/models/sql/compiler.py @@ -94,7 +94,8 @@ class SQLCompiler: # SomeModel.objects.annotate(Count('somecol')).values('name') # GROUP BY: all cols of the model # - # SomeModel.objects.values('name', 'pk').annotate(Count('somecol')).values('pk') + # SomeModel.objects.values('name', 'pk') + # .annotate(Count('somecol')).values('pk') # GROUP BY: name, pk # # SomeModel.objects.values('name').annotate(Count('somecol')).values('pk') @@ -647,10 +648,7 @@ class SQLCompiler: result += [", ".join(out_cols), "FROM", *from_] params.extend(f_params) - if ( - self.query.select_for_update - and self.connection.features.has_select_for_update - ): + if self.query.select_for_update and features.has_select_for_update: if self.connection.get_autocommit(): raise TransactionManagementError( "select_for_update cannot be used outside of a transaction." @@ -658,7 +656,7 @@ class SQLCompiler: if ( with_limit_offset - and not self.connection.features.supports_select_for_update_with_limit + and not features.supports_select_for_update_with_limit ): raise NotSupportedError( "LIMIT/OFFSET is not supported with " @@ -671,28 +669,19 @@ class SQLCompiler: # If it's a NOWAIT/SKIP LOCKED/OF/NO KEY query but the # backend doesn't support it, raise NotSupportedError to # prevent a possible deadlock. - if ( - nowait - and not self.connection.features.has_select_for_update_nowait - ): + if nowait and not features.has_select_for_update_nowait: raise NotSupportedError( "NOWAIT is not supported on this database backend." ) - elif ( - skip_locked - and not self.connection.features.has_select_for_update_skip_locked - ): + elif skip_locked and not features.has_select_for_update_skip_locked: raise NotSupportedError( "SKIP LOCKED is not supported on this database backend." ) - elif of and not self.connection.features.has_select_for_update_of: + elif of and not features.has_select_for_update_of: raise NotSupportedError( "FOR UPDATE OF is not supported on this database backend." ) - elif ( - no_key - and not self.connection.features.has_select_for_no_key_update - ): + elif no_key and not features.has_select_for_no_key_update: raise NotSupportedError( "FOR NO KEY UPDATE is not supported on this " "database backend." @@ -704,7 +693,7 @@ class SQLCompiler: no_key=no_key, ) - if for_update_part and self.connection.features.for_update_after_from: + if for_update_part and features.for_update_after_from: result.append(for_update_part) if where: @@ -751,7 +740,7 @@ class SQLCompiler: ) ) - if for_update_part and not self.connection.features.for_update_after_from: + if for_update_part and not features.for_update_after_from: result.append(for_update_part) if self.query.subquery and extra_select: diff --git a/django/db/models/sql/datastructures.py b/django/db/models/sql/datastructures.py index f398074bf7..1edf040e82 100644 --- a/django/db/models/sql/datastructures.py +++ b/django/db/models/sql/datastructures.py @@ -26,7 +26,8 @@ class Join: """ Used by sql.Query and sql.SQLCompiler to generate JOIN clauses into the FROM entry. For example, the SQL generated could be - LEFT OUTER JOIN "sometable" T1 ON ("othertable"."sometable_id" = "sometable"."id") + LEFT OUTER JOIN "sometable" T1 + ON ("othertable"."sometable_id" = "sometable"."id") This class is primarily used in Query.alias_map. All entries in alias_map must be Join compatible by providing the following attributes and methods: diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index 242b2a1f3f..2b1f6757ba 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -682,7 +682,8 @@ class Query(BaseExpression): # the extra complexity when you can write a real query instead. if self.extra and rhs.extra: raise ValueError( - "When merging querysets using 'or', you cannot have extra(select=...) on both sides." + "When merging querysets using 'or', you cannot have " + "extra(select=...) on both sides." ) self.extra.update(rhs.extra) extra_select_mask = set() |
