|
20 | 20 |
|
21 | 21 | import io.r2dbc.postgresql.PostgresqlConnectionConfiguration;
|
22 | 22 | 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.*; |
31 | 24 | import io.r2dbc.postgresql.extension.CodecRegistrar;
|
32 | 25 | import io.r2dbc.spi.ConnectionFactory;
|
33 | 26 | import lombok.AllArgsConstructor;
|
34 | 27 | import lombok.Data;
|
35 | 28 | import reactor.test.StepVerifier;
|
36 | 29 |
|
| 30 | +import java.time.Duration; |
37 | 31 | import java.util.Arrays;
|
38 | 32 | import java.util.Collections;
|
39 | 33 | import java.util.List;
|
@@ -245,6 +239,27 @@ void shouldReadAndWriteGeoTypes() {
|
245 | 239 | assertThat(saved).isEqualTo(loaded);
|
246 | 240 | }
|
247 | 241 |
|
| 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 | + |
248 | 263 | private void insert(EntityWithArrays object) {
|
249 | 264 |
|
250 | 265 | client.insert() //
|
@@ -300,4 +315,15 @@ static class GeoType {
|
300 | 315 | org.springframework.data.geo.Point springDataPoint;
|
301 | 316 | org.springframework.data.geo.Polygon springDataPolygon;
|
302 | 317 | }
|
| 318 | + |
| 319 | + @Data |
| 320 | + @Table("with_interval") |
| 321 | + static class EntityWithInterval { |
| 322 | + |
| 323 | + @Id Integer id; |
| 324 | + |
| 325 | + Interval interval; |
| 326 | + |
| 327 | + } |
| 328 | + |
303 | 329 | }
|
0 commit comments