@Override public void compactInternally(final TableReference tableRef) { if (sqlDialect.family() == SQLDialect.POSTGRES) { run((Function<DSLContext, Void>) ctx -> { ctx.execute("VACUUM ANALYZE " + tableName(tableRef)); return null; }); } }
@Override protected DSLContext create0() { SQLDialect dialect = SQLDialect.DEFAULT; try { dialect = SQLDialect.valueOf(getProperties().getProperty(P_DIALECT)); } catch (Exception ignore) {} // [#6493] Data types are better discovered from the family, not the dialect. This affects the XMLDatabase, // for instance. Other databases are currently not affected by the family / dialect distinction return DSL.using(dialect.family()); }
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; }
public static JdbcKeyValueService create(JdbcKeyValueConfiguration config) { JdbcDataSourceConfiguration dataSourceConfig = config.getDataSourceConfig(); SQLDialect sqlDialect = SQLDialect.valueOf(dataSourceConfig.getSqlDialect()); DataSource dataSource = dataSourceConfig.createDataSource(); Settings settings = new Settings();
/** * Creates a new SQL field transformer. * * @param sqlDialect The SQL dialect. Must be for H2, MySQL or * PostgreSQL 9.5. Not {@code null}. */ public SQLFieldTransformer(final SQLDialect sqlDialect) { if (SQLDialect.H2.equals(sqlDialect)) { collectionDataType = CollectionDataType.ARRAY; } else if (SQLDialect.MYSQL.equals(sqlDialect)) { collectionDataType = CollectionDataType.JSON; } else if (SQLDialect.POSTGRES_9_5.equals(sqlDialect)) { collectionDataType = CollectionDataType.ARRAY; } else { throw new IllegalArgumentException("Unsupported SQL dialect: " + sqlDialect); } }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((dialect == null) ? 0 : dialect.hashCode()); result = prime * result + length; result = prime * result + precision; result = prime * result + scale; result = prime * result + ((type == null) ? 0 : type.hashCode()); result = prime * result + ((typeName == null) ? 0 : typeName.hashCode()); return result; }
public static DataType<?> getDataType(SQLDialect dialect, String typeName) { String normalised = DefaultDataType.normalise(typeName); DataType<?> result = TYPES_BY_NAME[dialect.ordinal()].get(normalised); // UDT data types and others are registered using SQL99 if (result == null) { result = TYPES_BY_NAME[SQLDialect.SQL99.ordinal()].get(normalised); } if (result == null) { // [#366] Don't log a warning here. The warning is logged when // catching the exception in jOOQ-codegen throw new SQLDialectNotSupportedException("Type " + typeName + " is not supported in dialect " + dialect, false); } return result; }
private QueryPart delegate(Configuration configuration) { switch (configuration.dialect().family().toString()) { case "MYSQL": case "POSTGRES": return DSL.field("ST_Intersects({0}, {1})", Boolean.class, field1, field2); case "SQLSERVER": return DSL.field("{0}.STIntersects({1})", Boolean.class, field1, field2); default: throw new UnsupportedOperationException("Dialect not supported"); } } }
result.toDialect = SQLDialect.valueOf(args[++i]); continue argsLoop;
/** * Creates a new SQL field transformer. * * @param sqlDialect The SQL dialect. Must be for H2, MySQL or * PostgreSQL 9.5. Not {@code null}. */ public SQLFieldTransformer(final SQLDialect sqlDialect) { if (SQLDialect.H2.equals(sqlDialect)) { collectionDataType = CollectionDataType.ARRAY; } else if (SQLDialect.MYSQL.equals(sqlDialect)) { collectionDataType = CollectionDataType.JSON; } else if (SQLDialect.POSTGRES_9_5.equals(sqlDialect)) { collectionDataType = CollectionDataType.ARRAY; } else { throw new IllegalArgumentException("Unsupported SQL dialect: " + sqlDialect); } }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((dialect == null) ? 0 : dialect.hashCode()); result = prime * result + length; result = prime * result + precision; result = prime * result + scale; result = prime * result + ((uType == null) ? 0 : uType.hashCode()); result = prime * result + ((tType == null) ? 0 : tType.hashCode()); result = prime * result + ((typeName == null) ? 0 : typeName.hashCode()); return result; }
@Override public String translate(SQLDialect dialect) { switch (dialect.family()) { case DERBY: case SQLITE: return "length"; } return "char_length"; } },
private QueryPart delegate(Configuration configuration) { switch (configuration.dialect().family().toString()) { case "MYSQL": case "POSTGRES": return DSL.field("ST_IsValid({0})", Boolean.class, field); case "SQLSERVER": return DSL.field("{0}.STIsValid()", Boolean.class, field); default: throw new UnsupportedOperationException("Dialect not supported"); } } }
@Override public final DataType<T> getDataType(Configuration configuration) { // If this is a SQLDataType find the most suited dialect-specific // data type if (getDialect() == null) { DataType<?> dataType = TYPES_BY_SQL_DATATYPE[configuration.dialect().family().ordinal()] // Be sure to reset length, precision, and scale, as those values // were not registered in the below cache .get(length(0).precision(0, 0)); if (dataType != null) { // ... and then, set them back to the original value // [#2710] TODO: Remove this logic along with cached data types return (DataType<T>) dataType.length(length).precision(precision, scale); } } // If this is already the dialect's specific data type, return this else if (getDialect().family() == configuration.dialect().family()) { return this; } // If the SQL data type is not available stick with this data type else if (getSQLDataType() == null) { return this; } // If this is another dialect's specific data type, recurse else { getSQLDataType().getDataType(configuration); } return this; }