Skip to content
Browse files
fix: handle null values in array query parameters (#426)
  • Loading branch information
HemangChothani committed Dec 9, 2020
1 parent 763fb2c commit 78fde4a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
@@ -40,7 +40,7 @@

def _not_null(value, field):
"""Check whether 'value' should be coerced to 'field' type."""
return value is not None or field.mode != "NULLABLE"
return value is not None or (field is not None and field.mode != "NULLABLE")

def _int_from_json(value, field):
@@ -383,6 +383,16 @@ def test_from_api_repr_wo_values(self):
self.assertEqual(param.array_type, "INT64")
self.assertEqual(param.values, [])

def test_from_api_repr_w_none_values(self):
"parameterType": {"type": "ARRAY", "arrayType": {"type": "INT64"}},
"parameterValue": {"arrayValues": [{"value": "1"}, {"value": None}]},
klass = self._get_target_class()
param = klass.from_api_repr(RESOURCE)
self.assertEqual(param.array_type, "INT64")
self.assertEqual(param.values, [1, None])

def test_from_api_repr_w_struct_type(self):
from import StructQueryParameter

0 comments on commit 78fde4a

Please sign in to comment.