Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit78fde4a

Browse files
fix: handle null values in array query parameters (#426)
1 parent763fb2c commit78fde4a

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

‎google/cloud/bigquery/_helpers.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
def_not_null(value,field):
4242
"""Check whether 'value' should be coerced to 'field' type."""
43-
returnvalueisnotNoneorfield.mode!="NULLABLE"
43+
returnvalueisnotNoneor(fieldisnotNoneandfield.mode!="NULLABLE")
4444

4545

4646
def_int_from_json(value,field):

‎tests/unit/test_query.py‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,16 @@ def test_from_api_repr_wo_values(self):
383383
self.assertEqual(param.array_type,"INT64")
384384
self.assertEqual(param.values, [])
385385

386+
deftest_from_api_repr_w_none_values(self):
387+
RESOURCE= {
388+
"parameterType": {"type":"ARRAY","arrayType": {"type":"INT64"}},
389+
"parameterValue": {"arrayValues": [{"value":"1"}, {"value":None}]},
390+
}
391+
klass=self._get_target_class()
392+
param=klass.from_api_repr(RESOURCE)
393+
self.assertEqual(param.array_type,"INT64")
394+
self.assertEqual(param.values, [1,None])
395+
386396
deftest_from_api_repr_w_struct_type(self):
387397
fromgoogle.cloud.bigquery.queryimportStructQueryParameter
388398

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp