MCPcopy
hub / github.com/django/django / split_parameter_list_as_sql

Method split_parameter_list_as_sql

django/db/models/lookups.py:553–573  ·  view source on GitHub ↗
(self, compiler, connection)

Source from the content-addressed store, hash-verified

551 return super().as_sql(compiler, connection)
552
553 def split_parameter_list_as_sql(self, compiler, connection):
554 # This is a special case for databases which limit the number of
555 # elements which can appear in an 'IN' clause.
556 max_in_list_size = connection.ops.max_in_list_size()
557 lhs, lhs_params = self.process_lhs(compiler, connection)
558 rhs, rhs_params = self.batch_process_rhs(compiler, connection)
559 in_clause_elements = ["("]
560 params = []
561 for offset in range(0, len(rhs_params), max_in_list_size):
562 if offset > 0:
563 in_clause_elements.append(" OR ")
564 in_clause_elements.append("%s IN (" % lhs)
565 params.extend(lhs_params)
566 sqls = rhs[offset : offset + max_in_list_size]
567 sqls_params = rhs_params[offset : offset + max_in_list_size]
568 param_group = ", ".join(sqls)
569 in_clause_elements.append(param_group)
570 in_clause_elements.append(")")
571 params.extend(sqls_params)
572 in_clause_elements.append(")")
573 return "".join(in_clause_elements), params
574
575
576class PatternLookup(BuiltinLookup):

Callers 1

as_sqlMethod · 0.95

Calls 6

extendMethod · 0.80
max_in_list_sizeMethod · 0.45
process_lhsMethod · 0.45
batch_process_rhsMethod · 0.45
appendMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected