[jOOQ/jOOQ#982] Wrap up spatial support:

- Null bind values
- DDL support
- DML support
- Code generation support
- Some additional Oracle SDO_GEOMETRY support
This commit is contained in:
Lukas Eder 2022-01-04 13:59:50 +01:00
parent 3de6db5515
commit b8f6807818
7 changed files with 56 additions and 14 deletions

View File

@ -72,7 +72,6 @@ import static org.jooq.impl.DSL.select;
import static org.jooq.impl.DSL.selectFrom;
import static org.jooq.impl.DSL.sql;
import static org.jooq.impl.DSL.table;
import static org.jooq.impl.DSL.val;
import static org.jooq.impl.DSL.values;
import static org.jooq.impl.DSL.when;
import static org.jooq.impl.SQLDataType.BIGINT;
@ -102,9 +101,7 @@ import static org.jooq.meta.postgres.pg_catalog.Tables.PG_NAMESPACE;
import static org.jooq.meta.postgres.pg_catalog.Tables.PG_PROC;
import static org.jooq.meta.postgres.pg_catalog.Tables.PG_SEQUENCE;
import static org.jooq.meta.postgres.pg_catalog.Tables.PG_TYPE;
import static org.jooq.util.postgres.PostgresDSL.array;
import static org.jooq.util.postgres.PostgresDSL.arrayAppend;
import static org.jooq.util.postgres.PostgresDSL.oid;
import java.math.BigDecimal;
import java.math.BigInteger;
@ -124,13 +121,10 @@ import org.jooq.Name;
import org.jooq.Record;
import org.jooq.Record1;
import org.jooq.Record12;
import org.jooq.Record2;
import org.jooq.Record5;
import org.jooq.Record6;
import org.jooq.Records;
import org.jooq.Result;
import org.jooq.ResultQuery;
import org.jooq.Rows;
import org.jooq.SQLDialect;
import org.jooq.Select;
import org.jooq.SortOrder;
@ -138,7 +132,6 @@ import org.jooq.Table;
import org.jooq.TableField;
import org.jooq.TableOptions.TableType;
import org.jooq.conf.ParseUnknownFunctions;
import org.jooq.conf.SettingsTools;
import org.jooq.exception.DataAccessException;
import org.jooq.impl.DSL;
import org.jooq.impl.ParserException;
@ -168,10 +161,10 @@ import org.jooq.meta.SequenceDefinition;
import org.jooq.meta.TableDefinition;
import org.jooq.meta.UDTDefinition;
import org.jooq.meta.hsqldb.HSQLDBDatabase;
import org.jooq.meta.jaxb.ForcedType;
import org.jooq.meta.postgres.information_schema.tables.CheckConstraints;
import org.jooq.meta.postgres.information_schema.tables.KeyColumnUsage;
import org.jooq.meta.postgres.information_schema.tables.Routines;
import org.jooq.meta.postgres.pg_catalog.Tables;
import org.jooq.meta.postgres.pg_catalog.tables.PgClass;
import org.jooq.meta.postgres.pg_catalog.tables.PgConstraint;
import org.jooq.meta.postgres.pg_catalog.tables.PgIndex;
@ -953,11 +946,14 @@ public class PostgresDatabase extends AbstractDatabase implements ResultQueryDat
r1.SPECIFIC_NAME,
r1.ROUTINE_TYPE,
when(r1.DATA_TYPE.eq(inline("USER-DEFINED")).and(r1.TYPE_UDT_NAME.eq(inline("geometry"))), inline("geometry"))
// Ignore the data type when there is at least one out parameter
canCombineArrays()
.else_(canCombineArrays()
? when(condition("{0} && ARRAY['o','b']::\"char\"[]", PG_PROC.PROARGMODES), inline("void"))
.otherwise(r1.DATA_TYPE).as("data_type")
: r1.DATA_TYPE.as("data_type"),
.else_(r1.DATA_TYPE)
: r1.DATA_TYPE
).as("data_type"),
r1.CHARACTER_MAXIMUM_LENGTH,

View File

@ -44,6 +44,7 @@ import static org.jooq.impl.DSL.inline;
import static org.jooq.impl.DSL.name;
import static org.jooq.impl.DSL.partitionBy;
import static org.jooq.impl.DSL.when;
import static org.jooq.meta.postgres.information_schema.Tables.COLUMNS;
import static org.jooq.meta.postgres.information_schema.Tables.PARAMETERS;
import static org.jooq.meta.postgres.information_schema.Tables.ROUTINES;
@ -131,7 +132,9 @@ public class PostgresRoutineDefinition extends AbstractRoutineDefinition {
for (Record record : create().select(
p.PARAMETER_NAME,
p.DATA_TYPE,
when(p.DATA_TYPE.eq(inline("USER-DEFINED")).and(p.UDT_NAME.eq(inline("geometry"))), inline("geometry"))
.else_(p.DATA_TYPE)
.as(p.DATA_TYPE),
p.CHARACTER_MAXIMUM_LENGTH,
pNumericPrecision(p).as(p.NUMERIC_PRECISION),
p.NUMERIC_SCALE,

View File

@ -89,6 +89,7 @@ public class PostgresTableDefinition extends AbstractTableDefinition {
Field<String> dataType =
when(COLUMNS.INTERVAL_TYPE.like(any(inline("%YEAR%"), inline("%MONTH%"))), inline("INTERVAL YEAR TO MONTH"))
.when(COLUMNS.INTERVAL_TYPE.like(any(inline("%DAY%"), inline("%HOUR%"), inline("%MINUTE%"), inline("%SECOND%"))), inline("INTERVAL DAY TO SECOND"))
.when(COLUMNS.DATA_TYPE.eq(inline("USER-DEFINED")).and(COLUMNS.UDT_NAME.eq(inline("geometry"))), inline("geometry"))
.else_(COLUMNS.DATA_TYPE);
Field<String> udtSchema = COLUMNS.UDT_SCHEMA;
Field<Integer> precision = nvl(COLUMNS.DATETIME_PRECISION, COLUMNS.NUMERIC_PRECISION);

View File

@ -38,8 +38,11 @@
package org.jooq.meta.postgres;
import static org.jooq.impl.DSL.coalesce;
import static org.jooq.impl.DSL.inline;
import static org.jooq.impl.DSL.name;
import static org.jooq.impl.DSL.when;
import static org.jooq.meta.postgres.information_schema.Tables.ATTRIBUTES;
import static org.jooq.meta.postgres.information_schema.Tables.COLUMNS;
import static org.jooq.meta.postgres.information_schema.Tables.DOMAINS;
import java.sql.SQLException;
@ -69,7 +72,11 @@ public class PostgresUDTDefinition extends AbstractUDTDefinition {
for (Record record : create().select(
ATTRIBUTES.ATTRIBUTE_NAME,
ATTRIBUTES.ORDINAL_POSITION,
coalesce(DOMAINS.DATA_TYPE, ATTRIBUTES.DATA_TYPE).as(ATTRIBUTES.DATA_TYPE),
coalesce(
DOMAINS.DATA_TYPE,
when(ATTRIBUTES.DATA_TYPE.eq(inline("USER-DEFINED")).and(ATTRIBUTES.ATTRIBUTE_UDT_NAME.eq(inline("geometry"))), inline("geometry"))
.else_(ATTRIBUTES.DATA_TYPE)
).as(ATTRIBUTES.DATA_TYPE),
coalesce(DOMAINS.CHARACTER_MAXIMUM_LENGTH, ATTRIBUTES.CHARACTER_MAXIMUM_LENGTH).as(ATTRIBUTES.CHARACTER_MAXIMUM_LENGTH),
coalesce(DOMAINS.NUMERIC_PRECISION, ATTRIBUTES.NUMERIC_PRECISION).as(ATTRIBUTES.NUMERIC_PRECISION),
coalesce(DOMAINS.NUMERIC_SCALE, ATTRIBUTES.NUMERIC_SCALE).as(ATTRIBUTES.NUMERIC_SCALE),

View File

@ -5126,6 +5126,20 @@ public class DefaultBinding<T, U> implements Binding<T, U> {

View File

@ -6301,7 +6301,7 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
}
else if (parseFunctionNameIf("ST_WITHIN") && requireProEdition()) {
else if (parseFunctionNameIf("ST_WITHIN", "SDO_INSIDE") && requireProEdition()) {
@ -11906,6 +11906,23 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
break;
case 'G':
if ((parseKeywordOrIdentifierIf("GEOMETRY") ||
parseKeywordOrIdentifierIf("SDO_GEOMETRY"))
&& requireProEdition()
) {
}
else if (parseKeywordOrIdentifierIf("GEOGRAPHY") && requireProEdition()) {
}
break;
case 'I':
if (parseKeywordOrIdentifierIf("INTEGER") ||
parseKeywordOrIdentifierIf("INT") ||

View File

@ -176,6 +176,10 @@ package org.jooq.impl;