public DataType<T[]> getArrayDataType() { return dataType.getArrayDataType(); }
@SuppressWarnings({ "rawtypes", "unchecked" }) private static <T> DataType<T[]> type(Collection<? extends Field<T>> fields) { if (fields == null || fields.isEmpty()) return (DataType) SQLDataType.OTHER.getArrayDataType(); else return fields.iterator().next().getDataType().getArrayDataType(); }
public static final DataType<?> getDataType(SQLDialect dialect, String typeName) { SQLDialect family = dialect.family(); int ordinal = family.ordinal(); String upper = typeName.toUpperCase(); String normalised = typeName; DataType<?> result = TYPES_BY_NAME[ordinal].get(upper); // [#3225] Normalise only if necessary if (result == null) { result = TYPES_BY_NAME[ordinal].get(normalised = DefaultDataType.normalise(typeName)); // UDT data types and others are registered using DEFAULT if (result == null) { result = TYPES_BY_NAME[SQLDialect.DEFAULT.ordinal()].get(normalised); // [#4065] PostgreSQL reports array types as _typename, e.g. _varchar if (result == null && ( family == POSTGRES) && normalised.charAt(0) == '_') result = getDataType(dialect, normalised.substring(1)).getArrayDataType(); // [#6466] HSQLDB reports array types as XYZARRAY 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) throw new SQLDialectNotSupportedException("Type " + typeName + " is not supported in dialect " + dialect, false); } } return result; }
/** * The PostgreSQL <code>array(select)</code> function. * <p> * Example: <code><pre> * {1, 2, 3} = array(select 1 union select 2 union select 3) * </pre></code> */ @SuppressWarnings({ "rawtypes", "unchecked" }) @Support({ POSTGRES }) public static <T> Field<T[]> array(Select<? extends Record1<T>> select) { return DSL.field("array({0})", (DataType) select.getSelect().get(0).getDataType().getArrayDataType(), select); }
/** * Get the <code>array_agg()</code> aggregate function. */ @Support({ HSQLDB, POSTGRES }) public static <T> ArrayAggOrderByStep<T[]> arrayAggDistinct(Field<T> field) { return new org.jooq.impl.Function<T[]>(Term.ARRAY_AGG, true, field.getDataType().getArrayDataType(), nullSafe(field)); }
/** * The PostgreSQL <code>string_to_array(anyarray, delimiter)</code> function. * <p> * Example: <code><pre> * {xx,NULL,zz} = string_to_array('xx~^~yy~^~zz', '~^~', 'yy') * </pre></code> */ @Support({ POSTGRES }) public static Field<String[]> stringToArray(Field<String> string, Field<String> delimiter) { return field("{string_to_array}({0}, {1})", SQLDataType.VARCHAR.getArrayDataType(), nullSafe(string), nullSafe(delimiter)); }
return (DataType<T>) getDataType(dialect, type.getComponentType()).getArrayDataType();
/** * The PostgreSQL <code>string_to_array(anyarray, delimiter)</code> function. * <p> * Example: <code><pre> * {xx,NULL,zz} = string_to_array('xx~^~yy~^~zz', '~^~', 'yy') * </pre></code> */ @Support({ POSTGRES }) public static Field<String[]> stringToArray(Field<String> string, Field<String> delimiter) { return field("{string_to_array}({0}, {1})", SQLDataType.VARCHAR.getArrayDataType(), nullSafe(string), nullSafe(delimiter)); }
/** * Get the <code>array_agg()</code> aggregate function. */ @Support({ HSQLDB, POSTGRES }) public static <T> ArrayAggOrderByStep<T[]> arrayAgg(Field<T> field) { return new org.jooq.impl.Function<T[]>(Term.ARRAY_AGG, field.getDataType().getArrayDataType(), nullSafe(field)); }
return (DataType<T>) getDataType(dialect, type.getComponentType()).getArrayDataType();
/** * The PostgreSQL <code>string_to_array(anyarray, delimiter)</code> function. * <p> * Example: <code><pre> * {xx,NULL,zz} = string_to_array('xx~^~yy~^~zz', '~^~', 'yy') * </pre></code> */ @Support({ POSTGRES }) public static Field<String[]> stringToArray(Field<String> string, Field<String> delimiter, Field<String> nullString) { return field("{string_to_array}({0}, {1}, {2})", SQLDataType.VARCHAR.getArrayDataType(), nullSafe(string), nullSafe(delimiter), nullSafe(nullString)); }
private static final DataType<?> parseDataType(ParserContext ctx) { DataType<?> result = parseDataTypePrefix(ctx); boolean array = false; if (parseKeywordIf(ctx, "ARRAY")) array = true; if (parseIf(ctx, '[')) { parseUnsignedIntegerIf(ctx); parse(ctx, ']'); array = true; } if (array) result = result.getArrayDataType(); return result; }
/** * The PostgreSQL <code>array_fill(anyelement, int[])</code> function. * <p> * Example: <code><pre> * {7,7,7} = array_fill(7, ARRAY[3]) * </pre></code> */ @Support({ POSTGRES }) public static <T> Field<T[]> arrayFill(Field<T> value, Field<Integer[]> dimensions) { return field("{array_fill}({0}, {1})", nullSafe(value).getDataType().getArrayDataType(), nullSafe(value), nullSafe(dimensions)); }
/** * The PostgreSQL <code>array_fill(anyelement, int[], int[])</code> function. * <p> * Example: <code><pre> * [2:4]={7,7,7} = array_fill(7, ARRAY[3], ARRAY[2]) * </pre></code> */ @Support({ POSTGRES }) public static <T> Field<T[]> arrayFill(Field<T> value, Field<Integer[]> dimensions, Field<Integer[]> bounds) { return field("{array_fill}({0}, {1})", nullSafe(value).getDataType().getArrayDataType(), nullSafe(value), nullSafe(dimensions), nullSafe(bounds)); }
f = f.coerce(f.getDataType().getArrayDataType());
case 'A': if (parseKeywordOrIdentifierIf(ctx, "ARRAY")) return SQLDataType.OTHER.getArrayDataType();