in_clause_elements.append(" OR ") in_clause_elements.append("%s IN (" % lhs) params.extend(lhs_params) sqls_params = tuple() param_group = ("(" + ",".join( "'{}'".format(p) for p in rhs_params[offset:offset + max_in_list_size]) + ")") in_clause_elements.append(param_group) in_clause_elements.append(")") params.extend(sqls_params) in_clause_elements.append(")") return "".join(in_clause_elements), params UUIDField.register_lookup(UUIDIn) CharField.register_lookup(UUIDIn) ForeignKey.register_lookup(UUIDIn) class FilterByUUIDQuerysetMixin(object): """ As a workaround to the SQLITE_MAX_VARIABLE_NUMBER, so we can avoid having to chunk our queries, we pass in the list of ids (after being validated) as an inline query statement. """ def filter_by_uuids(self, ids, validate=True): id_field = self.model._meta.pk.attname return self._by_uuids(ids, validate, id_field, True) def exclude_by_uuids(self, ids, validate=True): id_field = self.model._meta.pk.attname return self._by_uuids(ids, validate, id_field, False)
def ready(self): CharField.register_lookup(Similar) TextField.register_lookup(Similar)