Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion google/cloud/bigquery/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,11 @@ def _record_field_to_json(fields, row_value):


def _single_field_to_json(field, row_value):
"""Convert a single (non-repeating) field into JSON-serializable values.
"""Convert a single field into JSON-serializable values.

Ignores mode so that this can function for ARRAY / REPEATING fiels
without requiring a deepcopy of the field. See:
https://github.com/googleapis/python-bigquery/issues/6

Args:
field (google.cloud.bigquery.schema.SchemaField):
Expand Down
6 changes: 6 additions & 0 deletions tests/unit/test__helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,12 @@ def test_w_scalar(self):
converted = self._call_fut(field, original)
self.assertEqual(converted, str(original))

def test_w_scalar_ignores_mode(self):
field = _make_field("STRING", mode="REPEATED")
original = "hello world"
converted = self._call_fut(field, original)
self.assertEqual(converted, original)


class Test_repeated_field_to_json(unittest.TestCase):
def _call_fut(self, field, value):
Expand Down