diff --git a/jOOQ/src/main/java/org/jooq/DataType.java b/jOOQ/src/main/java/org/jooq/DataType.java index ca88beb944..a53b5594d0 100644 --- a/jOOQ/src/main/java/org/jooq/DataType.java +++ b/jOOQ/src/main/java/org/jooq/DataType.java @@ -1052,4 +1052,9 @@ public interface DataType extends Named { * Whether this data type is an XML type. */ boolean isXML(); + + /** + * Whether this data type is a spatial type. + */ + boolean isSpatial(); } diff --git a/jOOQ/src/main/java/org/jooq/Geography.java b/jOOQ/src/main/java/org/jooq/Geography.java index 22fceecc89..a7fa51f8dd 100644 --- a/jOOQ/src/main/java/org/jooq/Geography.java +++ b/jOOQ/src/main/java/org/jooq/Geography.java @@ -114,6 +114,8 @@ package org.jooq; + + diff --git a/jOOQ/src/main/java/org/jooq/Geometry.java b/jOOQ/src/main/java/org/jooq/Geometry.java index 22fceecc89..033db91638 100644 --- a/jOOQ/src/main/java/org/jooq/Geometry.java +++ b/jOOQ/src/main/java/org/jooq/Geometry.java @@ -115,5 +115,6 @@ package org.jooq; + diff --git a/jOOQ/src/main/java/org/jooq/impl/AbstractDataType.java b/jOOQ/src/main/java/org/jooq/impl/AbstractDataType.java index 1d3a888947..a21f3684ce 100644 --- a/jOOQ/src/main/java/org/jooq/impl/AbstractDataType.java +++ b/jOOQ/src/main/java/org/jooq/impl/AbstractDataType.java @@ -83,6 +83,8 @@ import org.jooq.Domain; import org.jooq.EmbeddableRecord; import org.jooq.EnumType; import org.jooq.Field; +// ... +// ... import org.jooq.JSON; import org.jooq.JSONB; import org.jooq.Name; @@ -753,6 +755,12 @@ implements return tType0() == XML.class; } + @Override + public final boolean isSpatial() { + Class tType = tType0(); + return tType == Geometry.class || tType == Geography.class; + } + @Override public final void accept(Context ctx) { switch (ctx.family()) { diff --git a/jOOQ/src/main/java/org/jooq/impl/ArrayGet.java b/jOOQ/src/main/java/org/jooq/impl/ArrayGet.java index 3d29d7083c..e80cf57835 100644 --- a/jOOQ/src/main/java/org/jooq/impl/ArrayGet.java +++ b/jOOQ/src/main/java/org/jooq/impl/ArrayGet.java @@ -84,8 +84,8 @@ implements allNotNull((DataType) StringUtils.defaultIfNull(array.getDataType().getArrayComponentDataType(), OTHER), array, index) ); - this.array = nullSafeNotNull(array, (DataType) OTHER); - this.index = nullSafeNotNull(index, (DataType) OTHER); + this.array = nullSafeNotNull(array, ((DataType) OTHER).getArrayDataType()); + this.index = nullSafeNotNull(index, INTEGER); } // ------------------------------------------------------------------------- diff --git a/jOOQ/src/main/java/org/jooq/impl/DateAdd.java b/jOOQ/src/main/java/org/jooq/impl/DateAdd.java index 83c72ff724..acc8f487b3 100644 --- a/jOOQ/src/main/java/org/jooq/impl/DateAdd.java +++ b/jOOQ/src/main/java/org/jooq/impl/DateAdd.java @@ -86,7 +86,7 @@ implements ); this.date = nullSafeNotNull(date, (DataType) OTHER); - this.interval = nullSafeNotNull(interval, (DataType) OTHER); + this.interval = nullSafeNotNull(interval, INTEGER); this.datePart = null; } @@ -101,7 +101,7 @@ implements ); this.date = nullSafeNotNull(date, (DataType) OTHER); - this.interval = nullSafeNotNull(interval, (DataType) OTHER); + this.interval = nullSafeNotNull(interval, INTEGER); this.datePart = datePart; } diff --git a/jOOQ/src/main/java/org/jooq/impl/DefaultBinding.java b/jOOQ/src/main/java/org/jooq/impl/DefaultBinding.java index 80466f0e3f..cdc5bbd534 100644 --- a/jOOQ/src/main/java/org/jooq/impl/DefaultBinding.java +++ b/jOOQ/src/main/java/org/jooq/impl/DefaultBinding.java @@ -53,6 +53,8 @@ import static java.util.function.Function.identity; // ... // ... // ... +// ... +// ... import static org.jooq.SQLDialect.CUBRID; // ... import static org.jooq.SQLDialect.DEFAULT; @@ -107,6 +109,8 @@ import static org.jooq.impl.Keywords.K_DATETIME2; import static org.jooq.impl.Keywords.K_DATETIMEOFFSET; import static org.jooq.impl.Keywords.K_FALSE; import static org.jooq.impl.Keywords.K_FORMAT; +import static org.jooq.impl.Keywords.K_GEOGRAPHY; +import static org.jooq.impl.Keywords.K_GEOMETRY; import static org.jooq.impl.Keywords.K_HOUR_TO_SECOND; import static org.jooq.impl.Keywords.K_JSON; import static org.jooq.impl.Keywords.K_NULL; @@ -117,6 +121,7 @@ import static org.jooq.impl.Keywords.K_TIME_WITH_TIME_ZONE; import static org.jooq.impl.Keywords.K_TRUE; import static org.jooq.impl.Keywords.K_YEAR_TO_DAY; import static org.jooq.impl.Keywords.K_YEAR_TO_FRACTION; +import static org.jooq.impl.Names.N_ST_GEOMFROMTEXT; import static org.jooq.impl.R2DBC.isR2dbc; import static org.jooq.impl.SQLDataType.BIGINT; import static org.jooq.impl.SQLDataType.BLOB; @@ -126,6 +131,7 @@ import static org.jooq.impl.SQLDataType.DECIMAL_INTEGER; import static org.jooq.impl.SQLDataType.DOUBLE; import static org.jooq.impl.SQLDataType.INTEGER; import static org.jooq.impl.SQLDataType.LONGVARCHAR; +import static org.jooq.impl.SQLDataType.NUMERIC; import static org.jooq.impl.SQLDataType.OTHER; import static org.jooq.impl.SQLDataType.REAL; import static org.jooq.impl.SQLDataType.ROWID; @@ -139,7 +145,6 @@ import static org.jooq.impl.Tools.attachRecords; import static org.jooq.impl.Tools.convertBytesToHex; import static org.jooq.impl.Tools.emulateMultiset; import static org.jooq.impl.Tools.enums; -import static org.jooq.impl.Tools.findAny; // ... import static org.jooq.impl.Tools.getMappedUDTName; import static org.jooq.impl.Tools.map; @@ -148,7 +153,6 @@ import static org.jooq.impl.Tools.uncoerce; import static org.jooq.tools.StringUtils.leftPad; import static org.jooq.tools.jdbc.JDBCUtils.safeFree; import static org.jooq.tools.jdbc.JDBCUtils.wasNull; -import static org.jooq.tools.reflect.Reflect.on; import static org.jooq.tools.reflect.Reflect.onClass; import static org.jooq.util.postgres.PostgresUtils.toPGArray; import static org.jooq.util.postgres.PostgresUtils.toPGArrayString; @@ -214,8 +218,11 @@ import org.jooq.DataType; import org.jooq.EnumType; import org.jooq.ExecuteScope; import org.jooq.Field; +// ... +// ... import org.jooq.JSON; import org.jooq.JSONB; +import org.jooq.Package; import org.jooq.Param; // ... import org.jooq.QualifiedRecord; @@ -228,6 +235,8 @@ import org.jooq.SQLDialect; import org.jooq.Schema; import org.jooq.Scope; import org.jooq.TableRecord; +import org.jooq.UDT; +import org.jooq.UDTField; import org.jooq.UDTRecord; import org.jooq.XML; import org.jooq.conf.NestedCollectionEmulation; @@ -253,6 +262,7 @@ import org.jooq.types.YearToMonth; import org.jooq.types.YearToSecond; import org.jooq.util.postgres.PostgresUtils; +// ... // ... // ... @@ -317,6 +327,21 @@ public class DefaultBinding implements Binding { return new DefaultDoubleBinding(dataType, converter); else if (type == Float.class || type == float.class) return new DefaultFloatBinding(dataType, converter); + else if (type == Geometry.class) + + + + + + return new CommercialOnlyBinding(dataType, converter); + else if (type == Geography.class) + + + + + + + return new CommercialOnlyBinding(dataType, converter); else if (type == Integer.class || type == int.class) return new DefaultIntegerBinding(dataType, converter); else if (type == JSON.class) @@ -729,7 +754,7 @@ public class DefaultBinding implements Binding { } // [#7242] Other vendor specific types also need a lot of casting - if (dataType.isJSON()) { + if (dataType.isJSON() || dataType.isSpatial()) { switch (ctx.family()) { @@ -802,8 +827,8 @@ public class DefaultBinding implements Binding { (sqlDataType == null || (!sqlDataType.isTemporal() && sqlDataType != SQLDataType.UUID - && sqlDataType != SQLDataType.JSON - && sqlDataType != SQLDataType.JSONB))) + && !sqlDataType.isSpatial() + && !sqlDataType.isJSON()))) sql(ctx, converted); @@ -3390,6 +3415,45 @@ public class DefaultBinding implements Binding { } } + static final class CommercialOnlyBinding extends AbstractBinding { + CommercialOnlyBinding(DataType dataType, Converter converter) { + super(dataType, converter); + } + + @Override + final void set0(BindingSetStatementContext ctx, Object value) throws SQLException { + ctx.configuration().requireCommercial(() -> "The out of the box binding for " + dataType.getName() + " is available in the commercial jOOQ distribution only. Alternatively, you can implement your own custom binding."); + } + + @Override + final void set0(BindingSetSQLOutputContext ctx, Object value) throws SQLException { + ctx.configuration().requireCommercial(() -> "The out of the box binding for " + dataType.getName() + " is available in the commercial jOOQ distribution only. Alternatively, you can implement your own custom binding."); + } + + @Override + final Object get0(BindingGetResultSetContext ctx) throws SQLException { + ctx.configuration().requireCommercial(() -> "The out of the box binding for " + dataType.getName() + " is available in the commercial jOOQ distribution only. Alternatively, you can implement your own custom binding."); + return null; + } + + @Override + final Object get0(BindingGetStatementContext ctx) throws SQLException { + ctx.configuration().requireCommercial(() -> "The out of the box binding for " + dataType.getName() + " is available in the commercial jOOQ distribution only. Alternatively, you can implement your own custom binding."); + return null; + } + + @Override + final Object get0(BindingGetSQLInputContext ctx) throws SQLException { + ctx.configuration().requireCommercial(() -> "The out of the box binding for " + dataType.getName() + " is available in the commercial jOOQ distribution only. Alternatively, you can implement your own custom binding."); + return null; + } + + @Override + final int sqltype(Statement statement, Configuration configuration) throws SQLException { + return Types.OTHER; + } + } + static final class DefaultOtherBinding extends AbstractBinding { DefaultOtherBinding(DataType dataType, Converter converter) { @@ -4500,6 +4564,229 @@ public class DefaultBinding implements Binding { } } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + static final class DefaultJSONBinding extends AbstractBinding { DefaultJSONBinding(DataType dataType, Converter converter) { @@ -4892,5 +5179,98 @@ public class DefaultBinding implements Binding { return Types.VARCHAR; } } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + } diff --git a/jOOQ/src/main/java/org/jooq/impl/Keywords.java b/jOOQ/src/main/java/org/jooq/impl/Keywords.java index 602a0fa14c..c3b76f7a92 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Keywords.java +++ b/jOOQ/src/main/java/org/jooq/impl/Keywords.java @@ -186,6 +186,8 @@ final class Keywords { static final Keyword K_FROM = keyword("from"); static final Keyword K_FUNCTION = keyword("function"); static final Keyword K_GENERATED = keyword("generated"); + static final Keyword K_GEOGRAPHY = keyword("geography"); + static final Keyword K_GEOMETRY = keyword("geometry"); static final Keyword K_GLOBAL_TEMPORARY = keyword("global temporary"); static final Keyword K_GOTO = keyword("goto"); static final Keyword K_GRANT = keyword("grant"); diff --git a/jOOQ/src/main/java/org/jooq/impl/Xmlserialize.java b/jOOQ/src/main/java/org/jooq/impl/Xmlserialize.java index 927969ada3..d7b81692d1 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Xmlserialize.java +++ b/jOOQ/src/main/java/org/jooq/impl/Xmlserialize.java @@ -87,7 +87,7 @@ implements ); this.content = content; - this.value = nullSafeNotNull(value, (DataType) OTHER); + this.value = nullSafeNotNull(value, XML); this.type = type; }