File tree 2 files changed +8
-8
lines changed
2 files changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -1298,17 +1298,13 @@ def __init__(
1298
1298
page_start = _rows_page_start ,
1299
1299
next_token = "pageToken" ,
1300
1300
)
1301
- self ._schema = schema
1302
1301
self ._field_to_index = _helpers ._field_to_index_mapping (schema )
1303
-
1304
- self ._total_rows = None
1305
- if table is not None and hasattr (table , "num_rows" ):
1306
- self ._total_rows = table .num_rows
1307
-
1308
1302
self ._page_size = page_size
1309
- self ._table = table
1310
- self ._selected_fields = selected_fields
1311
1303
self ._project = client .project
1304
+ self ._schema = schema
1305
+ self ._selected_fields = selected_fields
1306
+ self ._table = table
1307
+ self ._total_rows = getattr (table , "num_rows" , None )
1312
1308
1313
1309
def _get_next_page_response (self ):
1314
1310
"""Requests the next page from the path provided.
Original file line number Diff line number Diff line change @@ -4021,6 +4021,8 @@ def test_result(self):
4021
4021
"totalRows" : "2" ,
4022
4022
}
4023
4023
tabledata_resource = {
4024
+ # Explicitly set totalRows to be different from the query response.
4025
+ # to test update during iteration.
4024
4026
"totalRows" : "1" ,
4025
4027
"pageToken" : None ,
4026
4028
"rows" : [{"f" : [{"v" : "abc" }]}],
@@ -4038,6 +4040,8 @@ def test_result(self):
4038
4040
rows = list (result )
4039
4041
self .assertEqual (len (rows ), 1 )
4040
4042
self .assertEqual (rows [0 ].col1 , "abc" )
4043
+ # Test that the total_rows property has changed during iteration, based
4044
+ # on the response from tabledata.list.
4041
4045
self .assertEqual (result .total_rows , 1 )
4042
4046
4043
4047
def test_result_w_empty_schema (self ):
You can’t perform that action at this time.
0 commit comments