[jOOQ/jOOQ#8545] WIP
This commit is contained in:
parent
941bf0ed4a
commit
1f9fb4dfdb
@ -39,6 +39,7 @@ package org.jooq.codegen;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.MARIADB;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.MYSQL;
|
||||
|
||||
@ -367,6 +367,12 @@ class GenerationUtil {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
case POSTGRES: {
|
||||
|
||||
// The convention is to prepend a "_" to a type to get an array type
|
||||
@ -393,14 +399,12 @@ class GenerationUtil {
|
||||
|
||||
// In HSQLDB 2.2.5, there has been an incompatible INFORMATION_SCHEMA change around the
|
||||
// ELEMENT_TYPES view. Arrays are now described much more explicitly
|
||||
if ("ARRAY".equalsIgnoreCase(t)) {
|
||||
if ("ARRAY".equalsIgnoreCase(t))
|
||||
return name("OTHER");
|
||||
}
|
||||
|
||||
// This is for backwards compatibility
|
||||
else {
|
||||
else
|
||||
return name(t.replace(" ARRAY", ""));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2286,6 +2286,9 @@ public abstract class AbstractDatabase implements Database {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
case POSTGRES:
|
||||
case H2:
|
||||
return "ARRAY".equals(dataType);
|
||||
|
||||
@ -40,6 +40,7 @@ package org.jooq.meta;
|
||||
import org.jooq.SQLDialect;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import org.jooq.meta.cubrid.CUBRIDDatabase;
|
||||
// ...
|
||||
import org.jooq.meta.derby.DerbyDatabase;
|
||||
@ -97,6 +98,7 @@ public class Databases {
|
||||
|
||||
|
||||
|
||||
|
||||
case CUBRID: result = CUBRIDDatabase.class; break;
|
||||
case DERBY: result = DerbyDatabase.class; break;
|
||||
case FIREBIRD: result = FirebirdDatabase.class; break;
|
||||
|
||||
@ -84,9 +84,11 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jooq.Condition;
|
||||
import org.jooq.DSLContext;
|
||||
import org.jooq.Field;
|
||||
import org.jooq.Name;
|
||||
// ...
|
||||
import org.jooq.Record;
|
||||
import org.jooq.Record2;
|
||||
import org.jooq.Record4;
|
||||
@ -878,6 +880,22 @@ public class PostgresDatabase extends AbstractDatabase {
|
||||
return exists1(table, TABLES, TABLES.TABLE_SCHEMA, TABLES.TABLE_NAME);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
boolean canCombineArrays() {
|
||||
if (canCombineArrays == null) {
|
||||
|
||||
|
||||
@ -54,6 +54,7 @@ import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.jooq.Field;
|
||||
import org.jooq.Record;
|
||||
import org.jooq.meta.AbstractTableDefinition;
|
||||
import org.jooq.meta.ColumnDefinition;
|
||||
@ -75,10 +76,16 @@ public class PostgresTableDefinition extends AbstractTableDefinition {
|
||||
public List<ColumnDefinition> getElements0() throws SQLException {
|
||||
List<ColumnDefinition> result = new ArrayList<>();
|
||||
|
||||
Field<String> dataType = COLUMNS.DATA_TYPE;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
for (Record record : create().select(
|
||||
COLUMNS.COLUMN_NAME,
|
||||
COLUMNS.ORDINAL_POSITION,
|
||||
COLUMNS.DATA_TYPE,
|
||||
dataType,
|
||||
|
||||
// [#8067] A more robust / sophisticated decoding might be available
|
||||
nvl(
|
||||
@ -105,6 +112,9 @@ public class PostgresTableDefinition extends AbstractTableDefinition {
|
||||
.and(PG_DESCRIPTION.OBJSUBID.eq(COLUMNS.ORDINAL_POSITION))
|
||||
.where(COLUMNS.TABLE_SCHEMA.equal(getSchema().getName()))
|
||||
.and(COLUMNS.TABLE_NAME.equal(getName()))
|
||||
|
||||
|
||||
|
||||
.orderBy(COLUMNS.ORDINAL_POSITION)
|
||||
.fetch()) {
|
||||
|
||||
@ -117,7 +127,7 @@ public class PostgresTableDefinition extends AbstractTableDefinition {
|
||||
DataTypeDefinition type = new DefaultDataTypeDefinition(
|
||||
getDatabase(),
|
||||
typeSchema,
|
||||
record.get(COLUMNS.DATA_TYPE),
|
||||
record.get(dataType),
|
||||
record.get(COLUMNS.CHARACTER_MAXIMUM_LENGTH),
|
||||
record.get(COLUMNS.NUMERIC_PRECISION),
|
||||
record.get(COLUMNS.NUMERIC_SCALE),
|
||||
|
||||
@ -863,9 +863,16 @@ public class DefaultDataType<T> implements DataType<T> {
|
||||
result = getDataType(dialect, normalised.substring(1)).getArrayDataType();
|
||||
|
||||
// [#6466] HSQLDB reports array types as XYZARRAY
|
||||
if (result == null && family == HSQLDB && upper.endsWith(" ARRAY"))
|
||||
else if (result == null && family == HSQLDB && upper.endsWith(" ARRAY"))
|
||||
result = getDataType(dialect, typeName.substring(0, typeName.length() - 6)).getArrayDataType();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// [#366] Don't log a warning here. The warning is logged when
|
||||
// catching the exception in jOOQ-codegen
|
||||
if (result == null)
|
||||
|
||||
@ -41,6 +41,7 @@ package org.jooq.impl;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.CUBRID;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.DERBY;
|
||||
@ -98,6 +99,7 @@ import org.jooq.types.YearToSecond;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import org.jooq.util.cubrid.CUBRIDDataType;
|
||||
// ...
|
||||
import org.jooq.util.derby.DerbyDataType;
|
||||
@ -729,6 +731,9 @@ public final class SQLDataType {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user