summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Pope <nick@nickpope.me.uk>2021-07-16 12:11:46 +0100
committerGitHub <noreply@github.com>2021-07-16 13:11:46 +0200
commit304f6ff46a9d78aab0213b599356d3c7875b0bb9 (patch)
tree917266f4fcae5585b601702e1c9397c210fc1b01
parentf51a792c414166c8745657856cb50ed8a134e2b0 (diff)
Prevented SQLCompiler.execute_sql() from closing cursor twice.
cursor_iter() helper calls cursor.close() in a finally block.
-rw-r--r--django/db/models/sql/compiler.py14
1 files changed, 5 insertions, 9 deletions
diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py
index eda7fc3b5e..4413b00825 100644
--- a/django/db/models/sql/compiler.py
+++ b/django/db/models/sql/compiler.py
@@ -1223,15 +1223,11 @@ class SQLCompiler:
chunk_size,
)
if not chunked_fetch or not self.connection.features.can_use_chunked_reads:
- try:
- # If we are using non-chunked reads, we return the same data
- # structure as normally, but ensure it is all read into memory
- # before going any further. Use chunked_fetch if requested,
- # unless the database doesn't support it.
- return list(result)
- finally:
- # done with the cursor
- cursor.close()
+ # If we are using non-chunked reads, we return the same data
+ # structure as normally, but ensure it is all read into memory
+ # before going any further. Use chunked_fetch if requested,
+ # unless the database doesn't support it.
+ return list(result)
return result
def as_subquery_condition(self, alias, columns, compiler):