use of org.jkiss.dbeaver.model.sql.SQLDialect in project dbeaver by serge-rider.
the class DBUtils method getFullQualifiedName.
@NotNull
public static String getFullQualifiedName(@Nullable DBPDataSource dataSource, @NotNull DBPNamedObject... path) {
StringBuilder name = new StringBuilder(20 * path.length);
if (dataSource == null) {
// It is not SQL identifier, let's just make it simple then
for (DBPNamedObject namePart : path) {
if (isVirtualObject(namePart)) {
continue;
}
if (name.length() > 0) {
name.append('.');
}
name.append(namePart.getName());
}
} else {
final SQLDialect sqlDialect = dataSource.getSQLDialect();
DBPNamedObject parent = null;
for (DBPNamedObject namePart : path) {
if (namePart == null || isVirtualObject(namePart)) {
continue;
}
if (namePart instanceof DBSCatalog && ((sqlDialect.getCatalogUsage() & SQLDialect.USAGE_DML) == 0)) {
// Do not use catalog name in FQ name
continue;
}
if (namePart instanceof DBSSchema && ((sqlDialect.getSchemaUsage() & SQLDialect.USAGE_DML) == 0)) {
// Do not use schema name in FQ name
continue;
}
// Check for valid object name
if (!isValidObjectName(namePart.getName())) {
continue;
}
if (name.length() > 0) {
if (parent instanceof DBSCatalog) {
if (!sqlDialect.isCatalogAtStart()) {
log.warn("Catalog name should be at the start of full-qualified name!");
}
name.append(sqlDialect.getCatalogSeparator());
} else {
name.append(sqlDialect.getStructSeparator());
}
}
name.append(DBUtils.getQuotedIdentifier(dataSource, namePart.getName()));
parent = namePart;
}
}
return name.toString();
}
use of org.jkiss.dbeaver.model.sql.SQLDialect in project dbeaver by serge-rider.
the class SQLScriptParserTest method setDialect.
private SQLDialect setDialect(String name) throws DBException {
SQLDialectRegistry registry = SQLDialectRegistry.getInstance();
SQLDialect dialect = registry.getDialect(name).createInstance();
Mockito.when(dataSource.getSQLDialect()).thenReturn(dialect);
return dialect;
}
Aggregations