Skip to content

Commit f4b68b4

Browse files
committed
Postgres geometric types are considered simple.
Closes #1065
1 parent abf0db5 commit f4b68b4

File tree

2 files changed

+66
-2
lines changed

2 files changed

+66
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Copyright 2021 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.data.jdbc.core.dialect;
17+
18+
import static org.assertj.core.api.Assertions.*;
19+
20+
import org.junit.jupiter.api.Test;
21+
import org.postgresql.geometric.PGbox;
22+
import org.postgresql.geometric.PGcircle;
23+
import org.postgresql.geometric.PGlseg;
24+
import org.postgresql.geometric.PGpath;
25+
import org.postgresql.geometric.PGpoint;
26+
import org.postgresql.geometric.PGpolygon;
27+
import org.postgresql.util.PGobject;
28+
29+
/**
30+
* Unit tests for {@link JdbcPostgresDialect}.
31+
*
32+
* @author Jens Schauder
33+
*/
34+
public class JdbcPostgresDialectUnitTests {
35+
36+
@Test // GH-1065
37+
void pgobjectIsConsideredSimple() {
38+
assertThat(JdbcPostgresDialect.INSTANCE.simpleTypes()).contains(PGobject.class);
39+
}
40+
41+
@Test // GH-1065
42+
void geometricalTypesAreConsideredSimple() {
43+
44+
assertThat(JdbcPostgresDialect.INSTANCE.simpleTypes()).contains( //
45+
PGpoint.class, //
46+
PGbox.class, //
47+
PGcircle.class, //
48+
org.postgresql.geometric.PGline.class, //
49+
PGpath.class, //
50+
PGpolygon.class, //
51+
PGlseg.class);
52+
}
53+
}

spring-data-relational/src/main/java/org/springframework/data/relational/core/dialect/PostgresDialect.java

+13-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
package org.springframework.data.relational.core.dialect;
1717

18-
import java.sql.JDBCType;
18+
import java.util.Arrays;
1919
import java.util.Collection;
2020
import java.util.Collections;
2121
import java.util.HashSet;
@@ -214,8 +214,19 @@ public IdentifierProcessing getIdentifierProcessing() {
214214
*/
215215
@Override
216216
public Set<Class<?>> simpleTypes() {
217+
217218
Set<Class<?>> simpleTypes = new HashSet<>();
218-
ifClassPresent("org.postgresql.util.PGobject", simpleTypes::add);
219+
final List<String> simpleTypeNames = Arrays.asList( //
220+
"org.postgresql.util.PGobject", //
221+
"org.postgresql.geometric.PGpoint", //
222+
"org.postgresql.geometric.PGbox", //
223+
"org.postgresql.geometric.PGcircle", //
224+
"org.postgresql.geometric.PGline", //
225+
"org.postgresql.geometric.PGpath", //
226+
"org.postgresql.geometric.PGpolygon", //
227+
"org.postgresql.geometric.PGlseg" //
228+
);
229+
simpleTypeNames.forEach(name -> ifClassPresent(name, simpleTypes::add));
219230
return Collections.unmodifiableSet(simpleTypes);
220231
}
221232

0 commit comments

Comments
 (0)