Skip to content

Commit f040b4f

Browse files
committed
remove unneeded bits
1 parent dacf0bb commit f040b4f

File tree

1 file changed

+3
-23
lines changed

1 file changed

+3
-23
lines changed

django_mongodb/fields/array.py

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ class ArrayField(CheckFieldDefaultMixin, Field):
3030

3131
def __init__(self, base_field, size=None, **kwargs):
3232
self.base_field = base_field
33-
self.db_collation = getattr(self.base_field, "db_collation", None)
3433
self.size = size
3534
if self.size:
3635
self.default_validators = [
@@ -72,7 +71,6 @@ def check(self, **kwargs):
7271
)
7372
)
7473
else:
75-
# Remove the field name checks as they are not needed here.
7674
base_checks = self.base_field.check()
7775
if base_checks:
7876
error_messages = "\n ".join(
@@ -114,14 +112,6 @@ def description(self):
114112
def db_type(self, connection):
115113
return "array"
116114

117-
def db_parameters(self, connection):
118-
db_params = super().db_parameters(connection)
119-
db_params["collation"] = self.db_collation
120-
return db_params
121-
122-
def get_placeholder(self, value, compiler, connection):
123-
return f"%s::{self.db_type(connection)}"
124-
125115
def get_db_prep_value(self, value, connection, prepared=False):
126116
if isinstance(value, list | tuple):
127117
# Workaround for https://code.djangoproject.com/ticket/35982
@@ -144,7 +134,7 @@ def deconstruct(self):
144134

145135
def to_python(self, value):
146136
if isinstance(value, str):
147-
# Assume we're deserializing
137+
# Assume value is being deserialized,
148138
vals = json.loads(value)
149139
value = [self.base_field.to_python(val) for val in vals]
150140
return value
@@ -236,9 +226,7 @@ def as_mql(self, compiler, connection):
236226

237227
class ArrayRHSMixin:
238228
def __init__(self, lhs, rhs):
239-
# Don't wrap arrays that contains only None values, psycopg doesn't
240-
# allow this.
241-
if isinstance(rhs, tuple | list) and any(self._rhs_not_none_values(rhs)):
229+
if isinstance(rhs, tuple | list):
242230
expressions = []
243231
for value in rhs:
244232
if not hasattr(value, "resolve_expression"):
@@ -248,13 +236,6 @@ def __init__(self, lhs, rhs):
248236
rhs = Array(*expressions)
249237
super().__init__(lhs, rhs)
250238

251-
def _rhs_not_none_values(self, rhs):
252-
for x in rhs:
253-
if isinstance(x, list | tuple):
254-
yield from self._rhs_not_none_values(x)
255-
elif x is not None:
256-
yield True
257-
258239

259240
@ArrayField.register_lookup
260241
class ArrayContains(ArrayRHSMixin, FieldGetDbPrepValueMixin, Lookup):
@@ -298,8 +279,7 @@ def get_prep_lookup(self):
298279
values = super().get_prep_lookup()
299280
if hasattr(values, "resolve_expression"):
300281
return values
301-
# In.process_rhs() expects values to be hashable, so convert lists
302-
# to tuples.
282+
# process_rhs() expects hashable values, so convert lists to tuples.
303283
prepared_values = []
304284
for value in values:
305285
if hasattr(value, "resolve_expression"):

0 commit comments

Comments
 (0)