Skip to content

Commit

Permalink
Merge pull request #3271 from samizuh/patch-1
Browse files Browse the repository at this point in the history
Fix missing BYTES merger
  • Loading branch information
tseaver authored Apr 18, 2017
2 parents 3b8c9f6 + 2e0bec8 commit 7100b84
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions spanner/google/cloud/spanner/streamed.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}


Expand Down
15 changes: 15 additions & 0 deletions spanner/tests/unit/test_streamed.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 7100b84

Please sign in to comment.