[jOOQ/jOOQ#13947] Support CockroachDB 23 user defined functions - WIP

- Fix array type support
This commit is contained in:
Lukas Eder 2023-05-31 12:17:59 +02:00
parent 099580c718
commit 97c56d2d53
2 changed files with 21 additions and 19 deletions

View File

@ -540,26 +540,15 @@ class GenerationUtil {
case TRINO: {
return new BaseType(t.replaceFirst("(?i:array\\((.*?)\\))", "$1"), u);
}
case POSTGRES:
case YUGABYTEDB: {
return getPGArrayBaseType(t, u);
}
// The convention is to prepend a "_" to a type to get an array type
if (u != null) {
if (u.last().startsWith("_"))
return new BaseType(u.last().substring(1), u);
else if (u.last().toUpperCase().endsWith(" ARRAY"))
return new BaseType(u.last().replaceFirst("(?i: ARRAY)", ""), u);
else if (t.toUpperCase().endsWith(" ARRAY"))
return new BaseType(t.replaceFirst("(?i: ARRAY)", ""), u);
}
// But there are also arrays with a "vector" suffix
return new BaseType(t, u);
case TRINO: {
return new BaseType(t.replaceFirst("(?i:array\\((.*?)\\))", "$1"), u);
}
case H2:
@ -579,6 +568,21 @@ class GenerationUtil {
}
}
private static final BaseType getPGArrayBaseType(String t, Name u) {
// The convention is to prepend a "_" to a type to get an array type
if (u != null) {
if (u.last().startsWith("_"))
return new BaseType(u.last().substring(1), u);
else if (u.last().toUpperCase().endsWith(" ARRAY"))
return new BaseType(u.last().replaceFirst("(?i: ARRAY)", ""), u);
else if (t.toUpperCase().endsWith(" ARRAY"))
return new BaseType(t.replaceFirst("(?i: ARRAY)", ""), u);
}
// But there are also arrays with a "vector" suffix
return new BaseType(t, u);
}
static ExpressionType expressionType(String expression) {
if (!"null".equals(expression) && TYPE_REFERENCE_PATTERN.matcher(expression).matches())
return CONSTRUCTOR_REFERENCE;

View File

@ -3193,17 +3193,15 @@ public abstract class AbstractDatabase implements Database {
case TRINO:
return upper.startsWith("ARRAY(");
case H2:
case POSTGRES:
case YUGABYTEDB:
return "ARRAY".equals(upper) || upper.endsWith(" ARRAY") || upper.equals("ANYARRAY");
return "ARRAY".equals(upper) || dataType.endsWith("[]") || upper.endsWith(" ARRAY") || upper.equals("ANYARRAY");
case HSQLDB: