@@ -1478,6 +1478,10 @@ def sample_request(self):
14781478 req [self .body ] = {} # just an empty json.
14791479 return req
14801480
1481+ ENABLE_WRAPPER_TYPES_FOR_PAGE_SIZE = {
1482+ 'google.cloud.bigquery.v2' : True ,
1483+ 'google.cloud.bigquery.connection.v1beta1' : False ,
1484+ }
14811485
14821486@dataclasses .dataclass (frozen = True )
14831487class Method :
@@ -1838,6 +1842,7 @@ def paged_result_field(self) -> Optional[Field]:
18381842
18391843 # The request must have page_token and response must have next_page_token fields
18401844 # because those fields keep track of pagination progress.
1845+
18411846 for source , source_type , name in (
18421847 (self .input , str , "page_token" ),
18431848 (self .output , str , "next_page_token" ),
@@ -1855,18 +1860,26 @@ def paged_result_field(self) -> Optional[Field]:
18551860 if not page_field_size :
18561861 return None
18571862
1858- # The datatype for page_size/max_results must be one of the following:
1859- # int (page_size) or UInt32Value, Int32Value (max_results)
1863+ # If the field is max_results and uses the UInt32Value and Int32Value wrappers,
1864+ # the package must be in the allowlist.
1865+ wrappers_allowed = ENABLE_WRAPPER_TYPES_FOR_PAGE_SIZE .get (self .input .meta .address .proto_package , False )
1866+
1867+ # ALTERNATIVE:
1868+ # As opposed to using a dictionary with package names as keys and True/False as values, we could
1869+ # Use a set and check to see if the package name is in the list
1870+ # WRAPPERS_ALLOWED_PACKAGE_LIST = {"google.cloud.bigquery.v2"}
1871+ # self.input.meta.address.proto_package in WRAPPERS_ALLOWED_PACKAGE_LIST
1872+
18601873 if page_field_size .type == int or (
18611874 # The following additional checks are for several members of the BQ family of
18621875 # APIs, which use legacy wrapper types: "UInt32Value" and "Int32Value"}
18631876 # for max_results.
18641877 # NOTE:
18651878 # bigquery_v2 should be paginated
1866- # but bigquery_connection_v1beta1 should NOT be paginated
1867- isinstance (page_field_size .type , MessageType )
1879+ # but bigquery_connection_v1beta1 should NOT be paginated
1880+ wrappers_allowed
1881+ and isinstance (page_field_size .type , MessageType )
18681882 and page_field_size .type .message_pb .name in {"UInt32Value" , "Int32Value" }
1869- and self .input .message_pb .name not in {"ListConnectionsRequest" }
18701883 ):
18711884 pass
18721885 else :
0 commit comments