|
61 | 61 | BatchMessage, RESULT_KIND_PREPARED, |
62 | 62 | RESULT_KIND_SET_KEYSPACE, RESULT_KIND_ROWS, |
63 | 63 | RESULT_KIND_SCHEMA_CHANGE, MIN_SUPPORTED_VERSION, |
64 | | - ProtocolHandler) |
| 64 | + ProtocolHandler, _RESULT_SEQUENCE_TYPES) |
65 | 65 | from cassandra.metadata import Metadata, protect_name, murmur3 |
66 | 66 | from cassandra.policies import (TokenAwarePolicy, DCAwareRoundRobinPolicy, SimpleConvictionPolicy, |
67 | 67 | ExponentialReconnectionPolicy, HostDistance, |
@@ -3345,7 +3345,7 @@ class ResultSet(object): |
3345 | 3345 |
|
3346 | 3346 | def __init__(self, response_future, initial_response): |
3347 | 3347 | self.response_future = response_future |
3348 | | - self._current_rows = initial_response or [] |
| 3348 | + self._set_current_rows(initial_response) |
3349 | 3349 | self._page_iter = None |
3350 | 3350 | self._list_mode = False |
3351 | 3351 |
|
@@ -3386,10 +3386,16 @@ def fetch_next_page(self): |
3386 | 3386 | if self.response_future.has_more_pages: |
3387 | 3387 | self.response_future.start_fetching_next_page() |
3388 | 3388 | result = self.response_future.result() |
3389 | | - self._current_rows = result._current_rows |
| 3389 | + self._current_rows = result._current_rows # ResultSet has already _set_current_rows to the appropriate form |
3390 | 3390 | else: |
3391 | 3391 | self._current_rows = [] |
3392 | 3392 |
|
| 3393 | + def _set_current_rows(self, result): |
| 3394 | + if isinstance(result, _RESULT_SEQUENCE_TYPES): |
| 3395 | + self._current_rows = result |
| 3396 | + else: |
| 3397 | + self._current_rows = [result] if result else [] |
| 3398 | + |
3393 | 3399 | def _fetch_all(self): |
3394 | 3400 | self._current_rows = list(self) |
3395 | 3401 | self._page_iter = None |
|
0 commit comments