From 8f6d811b6daa192dd6e0e5c78552f1267e6f6a04 Mon Sep 17 00:00:00 2001 From: Robert Date: Mon, 18 Nov 2024 16:45:33 -0500 Subject: [PATCH] mibios/query: remove superceeded QuerySet methods --- mibios/query.py | 77 ------------------------------------------------- 1 file changed, 77 deletions(-) diff --git a/mibios/query.py b/mibios/query.py index 57054866..ec8a95ad 100644 --- a/mibios/query.py +++ b/mibios/query.py @@ -1016,80 +1016,3 @@ def iterate(self, chunk_size=None, cache=None): return ModelIterable(self, chunk_size, cache) else: return ValuesListIterable(self, chunk_size, cache) - - def _iterate_model(self, chunk_size, cache): - """ iterate() implementation for normal model-based querysets """ - if cache is True: - # auto-caching-mode - # TODO: pick up fields from only()? - cache = FKCache(self.model, fk_fields=None) - - qs = self.order_by('pk') - - last_pk = 0 - while True: - chunk = qs.filter(pk__gt=last_pk)[:chunk_size] - - if cache: - # update in-place - cache.update_chunk(chunk) - - yield from chunk - - if len(chunk) < chunk_size: - # no further results - break - - last_pk = chunk[len(chunk) - 1].pk - - def _iterate_values_list(self, chunk_size, cache): - """ iterate() implementation for values_list() querysets """ - qs = self - - outnames = qs.get_output_field_names() - hide_pk = False - try: - pk_pos = outnames.index(qs.model._meta.pk.name) - except ValueError: - if 'pk' in outnames: - pk_pos = outnames.index('pk') - else: - # we have to get PK to make chunking work - qs = qs.values_list('pk', *outnames) - pk_pos = 0 - hide_pk = True - - if cache is True: - # auto-caching-mode - fk_fields = [] - for i in qs.model._meta.get_fields(): - if not i.many_to_one: - continue - if i.name in outnames or i.attname in outnames: - fk_fields.append(i) - cache = FKCache(qs.model, fk_fields=fk_fields) - - qs = qs.order_by('pk') - - last_pk = 0 - while True: - chunk = qs.filter(pk__gt=last_pk)[:chunk_size] - - if cache: - # chunk is replaced, type is list now - chunk = cache.update_values_list(chunk) - - # For non-empty chunk get last PK before they are removed. Must - # also avoid negative indexing in case chunk is queryset, so - # calculate last row via length. - if chunk_length := len(chunk): - last_pk = chunk[chunk_length - 1][pk_pos] - - if hide_pk: - chunk = ((i[slice(1, None)] for i in chunk)) - - yield from chunk - - if chunk_length < chunk_size: - # no further results - break