Skip to content

Commit

Permalink
test: support float32 in mock server (#2937)
Browse files Browse the repository at this point in the history
Adds support for `float32` to the mock server for testing. Also adds a couple of tests that can be used to verify that the mock server supports all types, and that verifies that the client library reads and encodes all types correctly. These tests can be overridden by frameworks using the Java client (e.g. JDBC and PGAdapter) to verify that these also handle these types correctly when used through the API of that tool (I.e. through JDBC or PostgreSQL wire-protocol).
  • Loading branch information
olavloite committed Mar 4, 2024
1 parent ccb110a commit 66ddf6c
Show file tree
Hide file tree
Showing 2 changed files with 696 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1286,6 +1286,7 @@ private Statement buildStatement(
break;
case FLOAT32:
builder.bind(fieldName).toFloat32Array((Iterable<Float>) null);
break;
case FLOAT64:
builder.bind(fieldName).toFloat64Array((Iterable<Double>) null);
break;
Expand Down Expand Up @@ -1331,6 +1332,7 @@ private Statement buildStatement(
break;
case FLOAT32:
builder.bind(fieldName).to((Float) null);
break;
case FLOAT64:
builder.bind(fieldName).to((Double) null);
break;
Expand Down Expand Up @@ -1396,6 +1398,14 @@ private Statement buildStatement(
GrpcStruct.decodeArrayValue(
com.google.cloud.spanner.Type.date(), value.getListValue()));
break;
case FLOAT32:
builder
.bind(fieldName)
.toFloat32Array(
(Iterable<Float>)
GrpcStruct.decodeArrayValue(
com.google.cloud.spanner.Type.float32(), value.getListValue()));
break;
case FLOAT64:
builder
.bind(fieldName)
Expand Down Expand Up @@ -1479,6 +1489,9 @@ private Statement buildStatement(
case DATE:
builder.bind(fieldName).to(Date.parseDate(value.getStringValue()));
break;
case FLOAT32:
builder.bind(fieldName).to((float) value.getNumberValue());
break;
case FLOAT64:
builder.bind(fieldName).to(value.getNumberValue());
break;
Expand Down

0 comments on commit 66ddf6c

Please sign in to comment.