Skip to content

Commit

Permalink
chore: small cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
gersmann committed Jan 23, 2024
1 parent 871b985 commit 0a708d8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
2 changes: 0 additions & 2 deletions django_mongodb/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ class DatabaseWrapper(BaseDatabaseWrapper):
"iendswith": "LIKE UPPER(%s)",
}

connection: MongoClient = None

SchemaEditorClass = DatabaseSchemaEditor
# Classes instantiated in __init__().
client_class = DatabaseClient
Expand Down
18 changes: 3 additions & 15 deletions django_mongodb/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
from django.db.models.sql.compiler import (
SQLInsertCompiler as BaseSQLInsertCompiler,
)
from django.db.models.sql.compiler import (
cursor_iter,
)
from django.db.models.sql.constants import (
CURSOR,
GET_ITERATOR_CHUNK_SIZE,
Expand Down Expand Up @@ -186,7 +189,6 @@ def results_iter(
fields = [s[0] for s in self.select[0 : self.col_count]]
converters = self.get_converters(fields)
rows = chain.from_iterable(results)
# Temporary mapping of dict to tuple, until we move this to 'project'
_row_tuples = []
cols = self.select[0 : self.col_count]
for row in rows:
Expand All @@ -202,18 +204,6 @@ def results_iter(
yield row


def cursor_iter(cursor, sentinel, col_count, itersize):
"""
Yield blocks of rows from a cursor and ensure the cursor is closed when
done.
"""
try:
for rows in iter((lambda: cursor.fetchmany(itersize)), sentinel):
yield rows if col_count is None else [r[:col_count] for r in rows]
finally:
cursor.close()


class SQLDeleteCompiler(SQLCompiler):
def as_operation(self, with_limits=True, with_col_aliases=False):
opts = self.query.get_meta()
Expand All @@ -229,8 +219,6 @@ class SQLInsertCompiler(SQLCompiler, BaseSQLInsertCompiler):
compiler = "SQLInsertCompiler"

def as_operation(self):
# We don't need quote_name_unless_alias() here, since these are all
# going to be column names (so we can avoid the extra overhead).
opts = self.query.get_meta()
fields = self.query.fields or [opts.pk]

Expand Down

0 comments on commit 0a708d8

Please sign in to comment.