Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
2 changes: 1 addition & 1 deletion google/cloud/bigquery/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def _key(self):
field_type = f"{field_type}({self.precision})"

policy_tags = (
() if self.policy_tags is None else tuple(sorted(self.policy_tags.names))
None if self.policy_tags is None else tuple(sorted(self.policy_tags.names))
)

return (
Expand Down
11 changes: 10 additions & 1 deletion tests/unit/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,9 +510,18 @@ def test___hash__not_equals(self):

def test___repr__(self):
field1 = self._make_one("field1", "STRING")
expected = "SchemaField('field1', 'STRING', 'NULLABLE', None, (), ())"
expected = "SchemaField('field1', 'STRING', 'NULLABLE', None, (), None)"
self.assertEqual(repr(field1), expected)

def test___repr__evaluable(self):
field = self._make_one("field1", "STRING", "REQUIRED", "Description")
field_repr = repr(field)
SchemaField = self._get_target_class() # needed for eval # noqa

evaled_field = eval(field_repr)

assert field == evaled_field

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For completeness, do we need a round-trip test for the case where there is a policy tuple?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would not hurt, I'll add it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guess what, that extra test actually revealed deeper issues in the repr() of SchemaField and PolicyTagList.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

W00t!


# TODO: dedup with the same class in test_table.py.
class _SchemaBase(object):
Expand Down