use of com.google.cloud.spanner.Struct in project google-cloud-java by GoogleCloudPlatform.
the class ITQueryTest method bindBytes.
@Test
public void bindBytes() {
Struct row = execute(Statement.newBuilder("SELECT @v").bind("v").to(ByteArray.copyFrom("xyz")), Type.bytes());
assertThat(row.isNull(0)).isFalse();
assertThat(row.getBytes(0)).isEqualTo(ByteArray.copyFrom("xyz"));
}
use of com.google.cloud.spanner.Struct in project google-cloud-java by GoogleCloudPlatform.
the class ITQueryTest method bindInt64Null.
@Test
public void bindInt64Null() {
Struct row = execute(Statement.newBuilder("SELECT @v").bind("v").to((Long) null), Type.int64());
assertThat(row.isNull(0)).isTrue();
}
use of com.google.cloud.spanner.Struct in project google-cloud-java by GoogleCloudPlatform.
the class ITQueryTest method bindDate.
@Test
public void bindDate() {
Date d = Date.parseDate("2016-09-18");
Struct row = execute(Statement.newBuilder("SELECT @v").bind("v").to(d), Type.date());
assertThat(row.isNull(0)).isFalse();
assertThat(row.getDate(0)).isEqualTo(d);
}
use of com.google.cloud.spanner.Struct in project google-cloud-java by GoogleCloudPlatform.
the class ITQueryTest method arrayOfStructNullElement.
// Not yet supported by the backend.
@Ignore
@Test
public void arrayOfStructNullElement() {
Type structType = Type.struct(StructField.of("", Type.string()), StructField.of("", Type.int64()));
Struct row = execute(Statement.of("SELECT ARRAY(SELECT AS STRUCT 'a', 1" + " UNION ALL SELECT CAST (NULL AS STRUCT<string,int64>))"), Type.array(structType));
assertThat(row.isNull(0)).isFalse();
List<Struct> value = row.getStructList(0);
assertThat(value.size()).isEqualTo(2);
assertThat(value.get(0).getType()).isEqualTo(structType);
assertThat(value.get(0).getString(0)).isEqualTo("a");
assertThat(value.get(0).getLong(1)).isEqualTo(1);
assertThat(value.get(1)).isNull();
}
use of com.google.cloud.spanner.Struct in project google-cloud-java by GoogleCloudPlatform.
the class ITQueryTest method bindDateArrayNull.
@Test
public void bindDateArrayNull() {
Struct row = execute(Statement.newBuilder("SELECT @v").bind("v").toDateArray(null), Type.array(Type.date()));
assertThat(row.isNull(0)).isTrue();
}
Aggregations