Skip to content

Commit 70244fb

Browse files
committed
#573 - Add integration test for interval type
1 parent 3e7bb1a commit 70244fb

File tree

1 file changed

+34
-8
lines changed

1 file changed

+34
-8
lines changed

src/test/java/org/springframework/data/r2dbc/core/PostgresIntegrationTests.java

+34-8
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,14 @@
2020

2121
import io.r2dbc.postgresql.PostgresqlConnectionConfiguration;
2222
import io.r2dbc.postgresql.PostgresqlConnectionFactory;
23-
import io.r2dbc.postgresql.codec.Box;
24-
import io.r2dbc.postgresql.codec.Circle;
25-
import io.r2dbc.postgresql.codec.EnumCodec;
26-
import io.r2dbc.postgresql.codec.Line;
27-
import io.r2dbc.postgresql.codec.Lseg;
28-
import io.r2dbc.postgresql.codec.Path;
29-
import io.r2dbc.postgresql.codec.Point;
30-
import io.r2dbc.postgresql.codec.Polygon;
23+
import io.r2dbc.postgresql.codec.*;
3124
import io.r2dbc.postgresql.extension.CodecRegistrar;
3225
import io.r2dbc.spi.ConnectionFactory;
3326
import lombok.AllArgsConstructor;
3427
import lombok.Data;
3528
import reactor.test.StepVerifier;
3629

30+
import java.time.Duration;
3731
import java.util.Arrays;
3832
import java.util.Collections;
3933
import java.util.List;
@@ -245,6 +239,27 @@ void shouldReadAndWriteGeoTypes() {
245239
assertThat(saved).isEqualTo(loaded);
246240
}
247241

242+
@Test // gh-573
243+
void shouldReadAndWriteInterval() {
244+
EntityWithInterval entityWithInterval = new EntityWithInterval();
245+
entityWithInterval.interval = Interval.of(Duration.ofHours(3));
246+
247+
template.execute("DROP TABLE IF EXISTS with_interval");
248+
template.execute("CREATE TABLE with_interval (" //
249+
+ "id serial PRIMARY KEY," //
250+
+ "interval INTERVAL" //
251+
+ ")");
252+
253+
R2dbcEntityTemplate template = new R2dbcEntityTemplate(client,
254+
new DefaultReactiveDataAccessStrategy(PostgresDialect.INSTANCE));
255+
256+
EntityWithInterval saved = template.insert(entityWithInterval).block();
257+
EntityWithInterval loaded = template.select(Query.empty(), EntityWithInterval.class) //
258+
.blockLast();
259+
260+
assertThat(saved.interval).isEqualTo(loaded.interval);
261+
}
262+
248263
private void insert(EntityWithArrays object) {
249264

250265
client.insert() //
@@ -300,4 +315,15 @@ static class GeoType {
300315
org.springframework.data.geo.Point springDataPoint;
301316
org.springframework.data.geo.Polygon springDataPolygon;
302317
}
318+
319+
@Data
320+
@Table("with_interval")
321+
static class EntityWithInterval {
322+
323+
@Id Integer id;
324+
325+
Interval interval;
326+
327+
}
328+
303329
}

0 commit comments

Comments
 (0)