use of org.jkiss.dbeaver.model.exec.DBCEntityMetaData in project dbeaver by serge-rider.
the class SQLSemanticProcessor method isValidTableColumn.
private static boolean isValidTableColumn(DBRProgressMonitor monitor, DBPDataSource dataSource, Table table, DBDAttributeConstraint co) throws DBException {
DBSAttributeBase attribute = co.getAttribute();
if (attribute instanceof DBDAttributeBinding) {
attribute = ((DBDAttributeBinding) attribute).getMetaAttribute();
}
if (table != null && attribute instanceof DBCAttributeMetaData) {
DBSEntityAttribute entityAttribute = null;
DBCEntityMetaData entityMetaData = ((DBCAttributeMetaData) attribute).getEntityMetaData();
if (entityMetaData != null) {
DBSEntity entity = DBUtils.getEntityFromMetaData(monitor, DBUtils.getDefaultContext(dataSource, true), entityMetaData);
if (entity != null) {
entityAttribute = entity.getAttribute(monitor, co.getAttributeName());
}
}
// No such attribute in entity. Do not use table prefix (#6927)
return entityAttribute != null;
}
return true;
}
use of org.jkiss.dbeaver.model.exec.DBCEntityMetaData in project dbeaver by serge-rider.
the class SQLServerUtils method getTableFromQuery.
public static SQLServerTableBase getTableFromQuery(DBCSession session, SQLQuery sqlQuery, SQLServerDataSource dataSource) throws DBException, SQLException {
DBCEntityMetaData singleSource = sqlQuery.getSingleSource();
String catalogName = null;
if (singleSource != null) {
catalogName = singleSource.getCatalogName();
}
Connection original = null;
if (session instanceof JDBCConnectionImpl) {
original = ((JDBCConnectionImpl) session).getOriginal();
}
if (catalogName == null && original != null) {
catalogName = original.getCatalog();
}
if (catalogName != null) {
SQLServerDatabase database = dataSource.getDatabase(catalogName);
String schemaName = null;
if (singleSource != null) {
schemaName = singleSource.getSchemaName();
}
if (schemaName == null && original != null) {
schemaName = original.getSchema();
}
if (database != null && schemaName != null) {
SQLServerSchema schema = database.getSchema(schemaName);
if (schema != null && singleSource != null) {
return schema.getTable(session.getProgressMonitor(), singleSource.getEntityName());
}
}
}
return null;
}
Aggregations