@@ -62,6 +62,8 @@ def spanner_type_to_schema_str(
6262 return "TIMESTAMP"
6363 if t .code == param_types .TypeCode .JSON :
6464 return "JSON"
65+ if t .code == param_types .TypeCode .DATE :
66+ return "DATE"
6567 raise ValueError ("Unsupported type: %s" % t )
6668
6769 @staticmethod
@@ -90,6 +92,8 @@ def schema_str_to_spanner_type(s: str) -> param_types.Type:
9092 return param_types .TIMESTAMP
9193 if s == "JSON" :
9294 return param_types .JSON
95+ if s == "DATE" :
96+ return param_types .DATE
9397 if s .startswith ("ARRAY<" ) and s .endswith (">" ):
9498 return param_types .Array (
9599 TypeUtility .schema_str_to_spanner_type (s [len ("ARRAY<" ) : - len (">" )])
@@ -118,6 +122,8 @@ def value_to_param_type(v: Any) -> param_types.Type:
118122 return param_types .FLOAT64
119123 if isinstance (v , datetime .datetime ):
120124 return param_types .TIMESTAMP
125+ if isinstance (v , datetime .date ):
126+ return param_types .DATE
121127 if isinstance (v , JsonObject ):
122128 return param_types .JSON
123129 if isinstance (v , list ):
@@ -145,6 +151,8 @@ def value_for_json(v: Any) -> Any:
145151 return base64 .b64encode (v ).decode ("utf-8" )
146152 if isinstance (v , datetime .datetime ):
147153 return str (v )
154+ if isinstance (v , datetime .date ):
155+ return str (v )
148156 if isinstance (v , JsonObject ):
149157 return v
150158 if isinstance (v , list ):
0 commit comments