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 1b66fca
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 18 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
17 changes: 1 addition & 16 deletions django_mongodb/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from itertools import chain

from django.db.models.sql.compiler import (
SQLCompiler as BaseSQLCompiler,
SQLCompiler as BaseSQLCompiler, cursor_iter,
)
from django.db.models.sql.compiler import (
SQLInsertCompiler as BaseSQLInsertCompiler,
Expand Down Expand Up @@ -186,7 +186,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 +201,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 +216,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 1b66fca

Please sign in to comment.