Skip to content

Commit ba2795b

Browse files
committed
yet another round of merge conflicts.
2 parents db6ef9e + 0b0b85a commit ba2795b

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

google/cloud/bigquery/schema.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import collections
2020
import copy
2121
import enum
22-
from typing import Any, cast, Dict, Iterable, Optional, Union
22+
from typing import Any, cast, Dict, Iterable, Optional, Union, Mapping, List
2323

2424
from google.cloud.bigquery import _helpers
2525
from google.cloud.bigquery import standard_sql
@@ -260,8 +260,6 @@ def __init__(
260260
raise ValueError(
261261
"If the 'field_type' is 'FOREIGN', then 'foreign_type_definition' is required."
262262
)
263-
self._properties["type"] = field_type
264-
265263
if fields: # Don't set the property if it's not set.
266264
self._properties["fields"] = [field.to_api_repr() for field in fields]
267265

tests/unit/test_schema.py

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# limitations under the License.
1414

1515

16+
import copy
1617
import unittest
1718
from unittest import mock
1819

@@ -851,11 +852,30 @@ def test_schema_fields_sequence(self):
851852

852853
def test_unknown_properties(self):
853854
schema = [
854-
{"name": "full_name", "type": "STRING", "mode": "REQUIRED"},
855-
{"name": "address", "invalid_key": "STRING", "mode": "REQUIRED"},
855+
{
856+
"name": "full_name",
857+
"type": "STRING",
858+
"mode": "REQUIRED",
859+
"someNewProperty": "test-value",
860+
},
861+
{
862+
"name": "age",
863+
# Note: This type should be included, too. Avoid client-side
864+
# validation, as it could prevent backwards-compatible
865+
# evolution of the server-side behavior.
866+
"typo": "INTEGER",
867+
"mode": "REQUIRED",
868+
"anotherNewProperty": "another-test",
869+
},
856870
]
857-
with pytest.raises(Exception): # Or a more specific exception if known
858-
_to_schema_fields(schema)
871+
872+
# Make sure the setter doesn't mutate schema.
873+
expected_schema = copy.deepcopy(schema)
874+
875+
result = self._call_fut(schema)
876+
877+
for api_repr, field in zip(expected_schema, result):
878+
assert field.to_api_repr() == api_repr
859879

860880
@pytest.mark.parametrize(
861881
"schema, expected_schema",

0 commit comments

Comments
 (0)