[jOOQ/jOOQ#16878] Wrong cast syntax used for BigQuery ARRAY types

This commit is contained in:
Lukas Eder 2024-06-27 13:45:08 +02:00
parent 31e4b05be5
commit e35656ec03
3 changed files with 26 additions and 4 deletions

View File

@ -192,6 +192,11 @@ final class ArrayDataType<T> extends DefaultDataType<T[]> {
switch (configuration.family()) {
case DUCKDB:
case POSTGRES:
case YUGABYTEDB:

View File

@ -39,6 +39,7 @@ package org.jooq.impl;
import static java.util.Collections.unmodifiableCollection;
// ...
// ...
import static org.jooq.SQLDialect.CLICKHOUSE;
// ...
import static org.jooq.SQLDialect.DUCKDB;
@ -113,6 +114,7 @@ import org.jooq.Field;
import org.jooq.Generator;
import org.jooq.Name;
import org.jooq.Nullability;
// ...
import org.jooq.QualifiedRecord;
import org.jooq.QueryPart;
import org.jooq.SQLDialect;
@ -150,6 +152,10 @@ public class DefaultDataType<T> extends AbstractDataTypeX<T> {
private static final Set<SQLDialect> SUPPORT_HSQLDB_ARRAY_NOTATION = SQLDialect.supportedBy(H2, HSQLDB, POSTGRES, YUGABYTEDB);
private static final Set<SQLDialect> SUPPORT_TRINO_ARRAY_NOTATION = SQLDialect.supportedBy(CLICKHOUSE, TRINO);
/**
* A pattern for data type name normalisation.
*/
@ -736,6 +742,11 @@ public class DefaultDataType<T> extends AbstractDataTypeX<T> {
else if (arrayCheck && SUPPORT_TRINO_ARRAY_NOTATION.contains(dialect) && upper.startsWith("ARRAY("))
result = getDataType(dialect, typeName.substring(6, typeName.length() - 1)).getArrayDataType();
// [#366] Don't log a warning here. The warning is logged when
// catching the exception in jOOQ-codegen
if (result == null)

View File

@ -7363,7 +7363,7 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
// Work around a missing feature in unnest()
if (!f.getType().isArray())
f = f.coerce(f.getDataType().getArrayDataType());
f = f.coerce(f.getDataType().array());
result = unnest(f);
}
@ -13482,7 +13482,7 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
}
if (array)
result = result.getArrayDataType();
result = result.array();
}
while (array);
}
@ -13498,8 +13498,14 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
switch (character) {
case 'A':
if (parseKeywordOrIdentifierIf("ARRAY"))
return OTHER.getArrayDataType();
if (parseKeywordOrIdentifierIf("ARRAY")) {
if (peek('('))
return parseParenthesised(c -> parseDataTypeIf(parseUnknownTypes).array());
else if (peek('<'))
return parseParenthesised('<', c -> parseDataTypeIf(parseUnknownTypes).array(), '>');
else
return OTHER.array();
}
else if (parseKeywordIf("AUTO_INCREMENT")) {
parseDataTypeIdentityArgsIf();
return INTEGER.identity(true);