From 81356f8abac734b58db9ef9ca5ab6cf2a0dfe4af Mon Sep 17 00:00:00 2001 From: dan-ladd <44812054+dan-ladd@users.noreply.github.com> Date: Thu, 16 Feb 2023 00:12:04 -0500 Subject: [PATCH] Return empty list when no records are found in paginated search (#107) --- netsuitesdk/api/base.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/netsuitesdk/api/base.py b/netsuitesdk/api/base.py index 20c3a77..368bff0 100644 --- a/netsuitesdk/api/base.py +++ b/netsuitesdk/api/base.py @@ -4,7 +4,7 @@ from netsuitesdk.internal.client import NetSuiteClient from netsuitesdk.internal.utils import PaginatedSearch -from typing import List +from typing import List, Generator logger = logging.getLogger(__name__) @@ -78,17 +78,17 @@ def _serialize_array(self, records) -> List[OrderedDict]: return zeep.helpers.serialize_object(records) @staticmethod - def _paginated_search_to_generator(paginated_search): + def _paginated_search_to_generator(paginated_search) -> List: + records = [] + if paginated_search.num_records == 0: - return + return records num_pages = paginated_search.total_pages logger.debug('total pages = %d, records in page = %d', paginated_search.total_pages, paginated_search.num_records) logger.debug(f'current page index {paginated_search.page_index}') logger.debug('going to page %d', 0) - records = [] - for p in range(1, num_pages + 1): logger.debug('going to page %d', p) paginated_search.goto_page(p)