diff --git a/spanner/google/cloud/spanner/streamed.py b/spanner/google/cloud/spanner/streamed.py index 74c7e8754334..19333844b1c1 100644 --- a/spanner/google/cloud/spanner/streamed.py +++ b/spanner/google/cloud/spanner/streamed.py @@ -253,6 +253,7 @@ def _merge_struct(lhs, rhs, type_): type_pb2.STRING: _merge_string, type_pb2.ARRAY: _merge_array, type_pb2.STRUCT: _merge_struct, + type_pb2.BYTES: _merge_string, } diff --git a/spanner/tests/unit/test_streamed.py b/spanner/tests/unit/test_streamed.py index 674d34e2a03c..740a3e0f0ea0 100644 --- a/spanner/tests/unit/test_streamed.py +++ b/spanner/tests/unit/test_streamed.py @@ -185,6 +185,21 @@ def test__merge_chunk_string(self): self.assertEqual(merged.string_value, u'phredwylma') self.assertIsNone(streamed._pending_chunk) + def test__merge_chunk_string_w_bytes(self): + iterator = _MockCancellableIterator() + streamed = self._make_one(iterator) + FIELDS = [ + self._makeScalarField('image', 'BYTES'), + ] + streamed._metadata = _ResultSetMetadataPB(FIELDS) + streamed._pending_chunk = self._makeValue(u'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAAAAAA6fptVAAAACXBIWXMAAAsTAAALEwEAmpwYAAAA\n') + chunk = self._makeValue(u'B3RJTUUH4QQGFwsBTL3HMwAAABJpVFh0Q29tbWVudAAAAAAAU0FNUExFMG3E+AAAAApJREFUCNdj\nYAAAAAIAAeIhvDMAAAAASUVORK5CYII=\n') + + merged = streamed._merge_chunk(chunk) + + self.assertEqual(merged.string_value, u'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAAAAAA6fptVAAAACXBIWXMAAAsTAAALEwEAmpwYAAAA\nB3RJTUUH4QQGFwsBTL3HMwAAABJpVFh0Q29tbWVudAAAAAAAU0FNUExFMG3E+AAAAApJREFUCNdj\nYAAAAAIAAeIhvDMAAAAASUVORK5CYII=\n') + self.assertIsNone(streamed._pending_chunk) + def test__merge_chunk_array_of_bool(self): iterator = _MockCancellableIterator() streamed = self._make_one(iterator)