diff --git a/jOOQ-test/.classpath b/jOOQ-test/.classpath
index 24a0654523..ea6603cc16 100644
--- a/jOOQ-test/.classpath
+++ b/jOOQ-test/.classpath
@@ -30,6 +30,7 @@
+
diff --git a/jOOQ-test/configuration/org/jooq/configuration/lukas/postgres/library.xml b/jOOQ-test/configuration/org/jooq/configuration/lukas/postgres/library.xml
index 2affee7107..9a6107e70d 100644
--- a/jOOQ-test/configuration/org/jooq/configuration/lukas/postgres/library.xml
+++ b/jOOQ-test/configuration/org/jooq/configuration/lukas/postgres/library.xml
@@ -11,8 +11,8 @@
org.jooq.util.DefaultGenerator
org.jooq.util.postgres.PostgresDatabase
- .*
- t_book_details|.*?_seq
+ t_.*|x_.*|v_.*|V_.*|p_.*|f_.*|u_.*|(f|p)[0-9]+|s_.*
+ t_book_details|.*?_seq|_.*
false
true
diff --git a/jOOQ-test/lib/postgis-jdbc-1.3.3.jar b/jOOQ-test/lib/postgis-jdbc-1.3.3.jar
new file mode 100644
index 0000000000..05d7f6858a
Binary files /dev/null and b/jOOQ-test/lib/postgis-jdbc-1.3.3.jar differ
diff --git a/jOOQ-test/src/org/jooq/test/PostgresTest.java b/jOOQ-test/src/org/jooq/test/PostgresTest.java
index 6abdf7c25b..cc364a0eb0 100644
--- a/jOOQ-test/src/org/jooq/test/PostgresTest.java
+++ b/jOOQ-test/src/org/jooq/test/PostgresTest.java
@@ -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);
+ }
}
diff --git a/jOOQ-test/src/org/jooq/test/postgres/create.sql b/jOOQ-test/src/org/jooq/test/postgres/create.sql
index 6d7c61dc04..ada5c06ecf 100644
--- a/jOOQ-test/src/org/jooq/test/postgres/create.sql
+++ b/jOOQ-test/src/org/jooq/test/postgres/create.sql
@@ -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,
diff --git a/jOOQ/src/main/java/org/jooq/impl/DefaultDataType.java b/jOOQ/src/main/java/org/jooq/impl/DefaultDataType.java
index 83dd9ab32e..dff23fc940 100644
--- a/jOOQ/src/main/java/org/jooq/impl/DefaultDataType.java
+++ b/jOOQ/src/main/java/org/jooq/impl/DefaultDataType.java
@@ -596,6 +596,10 @@ public class DefaultDataType implements DataType {
}
public static DataType getDataType(SQLDialect dialect, Class type) {
+ return getDataType(dialect, type, null);
+ }
+
+ public static DataType getDataType(SQLDialect dialect, Class type, DataType fallbackDataType) {
// Treat primitive types the same way as their respective wrapper types
type = (Class) wrapper(type);
@@ -635,6 +639,11 @@ public class DefaultDataType implements DataType {
return (DataType) 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);
diff --git a/jOOQ/src/main/java/org/jooq/impl/Factory.java b/jOOQ/src/main/java/org/jooq/impl/Factory.java
index 85352d4a55..95608337c8 100644
--- a/jOOQ/src/main/java/org/jooq/impl/Factory.java
+++ b/jOOQ/src/main/java/org/jooq/impl/Factory.java
@@ -6850,11 +6850,11 @@ public class Factory {
*/
private static DataType mostSpecific(T value, DataType dataType) {
if (value != null) {
- Class> valueType = value.getClass();
+ Class valueType = (Class) value.getClass();
Class coercionType = dataType.getType();
if (valueType != coercionType && coercionType.isAssignableFrom(valueType)) {
- return (DataType) DefaultDataType.getDataType(null, valueType);
+ return DefaultDataType.getDataType(null, valueType, dataType);
}
}