[#2267] SQLDialectNotSupportedException: Type class
org.postgis.PGgeometry is not supported in dialect null, when binding PG* objects
This commit is contained in:
parent
87e281a6f4
commit
24254e039e
@ -30,6 +30,7 @@
|
||||
<classpathentry exported="true" kind="lib" path="lib/jaybird-2.2.0.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/connector-api-1.5.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/antlr-runtime-3.4.jar"/>
|
||||
<classpathentry kind="lib" path="lib/postgis-jdbc-1.3.3.jar" sourcepath="C:/Users/Lukas/.m2/repository/org/postgis/postgis-jdbc/1.3.3/postgis-jdbc-1.3.3-sources.jar"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/jOOQ-console"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/jOOQ-meta"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
|
||||
@ -11,8 +11,8 @@
|
||||
<name>org.jooq.util.DefaultGenerator</name>
|
||||
<database>
|
||||
<name>org.jooq.util.postgres.PostgresDatabase</name>
|
||||
<includes>.*</includes>
|
||||
<excludes>t_book_details|.*?_seq</excludes>
|
||||
<includes>t_.*|x_.*|v_.*|V_.*|p_.*|f_.*|u_.*|(f|p)[0-9]+|s_.*</includes>
|
||||
<excludes>t_book_details|.*?_seq|_.*</excludes>
|
||||
<dateAsTimestamp>false</dateAsTimestamp>
|
||||
<unsignedTypes>true</unsignedTypes>
|
||||
<customTypes>
|
||||
|
||||
BIN
jOOQ-test/lib/postgis-jdbc-1.3.3.jar
Normal file
BIN
jOOQ-test/lib/postgis-jdbc-1.3.3.jar
Normal file
Binary file not shown.
@ -51,6 +51,7 @@ import static org.jooq.test.postgres.generatedclasses.Tables.T_DATES;
|
||||
import static org.jooq.test.postgres.generatedclasses.Tables.T_EXOTIC_TYPES;
|
||||
import static org.jooq.test.postgres.generatedclasses.Tables.T_IDENTITY;
|
||||
import static org.jooq.test.postgres.generatedclasses.Tables.T_IDENTITY_PK;
|
||||
import static org.jooq.test.postgres.generatedclasses.Tables.T_PG_EXTENSIONS;
|
||||
import static org.jooq.test.postgres.generatedclasses.Tables.T_TRIGGERS;
|
||||
import static org.jooq.test.postgres.generatedclasses.Tables.V_AUTHOR;
|
||||
import static org.jooq.test.postgres.generatedclasses.Tables.V_BOOK;
|
||||
@ -97,6 +98,7 @@ import org.jooq.test.postgres.generatedclasses.tables.records.TDatesRecord;
|
||||
import org.jooq.test.postgres.generatedclasses.tables.records.TExoticTypesRecord;
|
||||
import org.jooq.test.postgres.generatedclasses.tables.records.TIdentityPkRecord;
|
||||
import org.jooq.test.postgres.generatedclasses.tables.records.TIdentityRecord;
|
||||
import org.jooq.test.postgres.generatedclasses.tables.records.TPgExtensionsRecord;
|
||||
import org.jooq.test.postgres.generatedclasses.tables.records.TTriggersRecord;
|
||||
import org.jooq.test.postgres.generatedclasses.tables.records.T_639NumbersTableRecord;
|
||||
import org.jooq.test.postgres.generatedclasses.tables.records.T_725LobTestRecord;
|
||||
@ -112,6 +114,8 @@ import org.jooq.types.UShort;
|
||||
import org.jooq.util.postgres.PostgresDataType;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.postgis.PGgeometry;
|
||||
import org.postgis.Point;
|
||||
|
||||
|
||||
/**
|
||||
@ -853,4 +857,24 @@ public class PostgresTest extends jOOQAbstractTest<
|
||||
// OUT parameters for the returned cursor
|
||||
// Object result = Routines.fSearchBook(create(), "Animal", 1L, 0L);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPostgresExtensions() throws Exception {
|
||||
jOOQAbstractTest.reset = false;
|
||||
|
||||
// [#2267] Try to execute some basic CRUD operations on PostGIS data
|
||||
// types. Even without formal support, jOOQ should allow to pass these
|
||||
// objects through to JDBC
|
||||
Point point = new Point(0, 0);
|
||||
point.setSrid(4326);
|
||||
PGgeometry geometry = new PGgeometry(point);
|
||||
|
||||
TPgExtensionsRecord r1 = create().newRecord(T_PG_EXTENSIONS);
|
||||
r1.setPgGeometry(geometry);
|
||||
assertEquals(1, r1.store());
|
||||
assertEquals(1, (int) create().selectCount().from(T_PG_EXTENSIONS).fetchOne(0, int.class));
|
||||
|
||||
TPgExtensionsRecord r2 = create().selectFrom(T_PG_EXTENSIONS).fetchOne();
|
||||
assertEquals(r1, r2);
|
||||
}
|
||||
}
|
||||
|
||||
@ -62,6 +62,7 @@ DROP TABLE IF EXISTS t_959/
|
||||
DROP TABLE IF EXISTS t_booleans/
|
||||
DROP TABLE IF EXISTS t_identity/
|
||||
DROP TABLE IF EXISTS t_identity_pk/
|
||||
DROP TABLE IF EXISTS t_pg_extensions/
|
||||
|
||||
DROP TYPE IF EXISTS u_address_type/
|
||||
DROP TYPE IF EXISTS u_street_type/
|
||||
@ -99,6 +100,16 @@ CREATE TYPE u_address_type AS (
|
||||
)
|
||||
/
|
||||
|
||||
CREATE TABLE t_pg_extensions (
|
||||
id serial not null,
|
||||
pg_interval interval,
|
||||
pg_box box,
|
||||
pg_hstore hstore,
|
||||
pg_geometry geometry(Point, 4326, 2),
|
||||
|
||||
CONSTRAINT pk_t_pg_extensions PRIMARY KEY (id)
|
||||
)/
|
||||
|
||||
CREATE TABLE t_identity_pk (
|
||||
id serial not null,
|
||||
val int,
|
||||
|
||||
@ -596,6 +596,10 @@ public class DefaultDataType<T> implements DataType<T> {
|
||||
}
|
||||
|
||||
public static <T> DataType<T> getDataType(SQLDialect dialect, Class<T> type) {
|
||||
return getDataType(dialect, type, null);
|
||||
}
|
||||
|
||||
public static <T> DataType<T> getDataType(SQLDialect dialect, Class<T> type, DataType<T> fallbackDataType) {
|
||||
|
||||
// Treat primitive types the same way as their respective wrapper types
|
||||
type = (Class<T>) wrapper(type);
|
||||
@ -635,6 +639,11 @@ public class DefaultDataType<T> implements DataType<T> {
|
||||
return (DataType<T>) SQL_DATATYPES_BY_TYPE.get(type);
|
||||
}
|
||||
|
||||
// If we have a "fallback" data type from an outer context
|
||||
else if (fallbackDataType != null) {
|
||||
return fallbackDataType;
|
||||
}
|
||||
|
||||
// All other data types are illegal
|
||||
else {
|
||||
throw new SQLDialectNotSupportedException("Type " + type + " is not supported in dialect " + dialect);
|
||||
|
||||
@ -6850,11 +6850,11 @@ public class Factory {
|
||||
*/
|
||||
private static <T> DataType<T> mostSpecific(T value, DataType<T> dataType) {
|
||||
if (value != null) {
|
||||
Class<?> valueType = value.getClass();
|
||||
Class<T> valueType = (Class<T>) value.getClass();
|
||||
Class<T> coercionType = dataType.getType();
|
||||
|
||||
if (valueType != coercionType && coercionType.isAssignableFrom(valueType)) {
|
||||
return (DataType<T>) DefaultDataType.getDataType(null, valueType);
|
||||
return DefaultDataType.getDataType(null, valueType, dataType);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user