use of com.servoy.j2db.query.ITableReference in project servoy-client by Servoy.
the class QBJoin method createColumn.
@Override
protected QBColumn createColumn(String name) throws RepositoryException {
ITableReference foreignTableReference = join.getForeignTableReference();
if (foreignTableReference instanceof TableExpression) {
Table joinTable = getRoot().getTable(foreignTableReference.getTable().getDataSource());
if (joinTable == null) {
throw new RepositoryException("Cannot find column '" + name + "' in data source '" + foreignTableReference.getTable().getDataSource() + "'");
}
Column col = joinTable.getColumn(name);
if (col == null) {
throw new RepositoryException("Cannot find column '" + name + "' in data source '" + foreignTableReference.getTable().getDataSource() + "'");
}
return new QBColumn(getRoot(), this, new QueryColumn(getQueryTable(), col.getID(), col.getSQLName(), col.getType(), col.getLength(), col.getScale(), col.getNativeTypename(), col.getFlags(), false));
} else if (foreignTableReference instanceof DerivedTable) {
QuerySelect query = ((DerivedTable) foreignTableReference).getQuery();
for (IQuerySelectValue qcol : query.getColumns()) {
if (name.equals(qcol.getAliasOrName()) || (qcol.getColumn() != null && name.equals(generateNormalizedNonReservedOSName(qcol.getColumn().getName())))) {
return new QBColumn(getRoot(), this, new QueryColumn(foreignTableReference.getTable(), generateNormalizedNonReservedOSName(name)));
}
}
}
throw new RepositoryException("Cannot find column '" + name + "' in source '" + foreignTableReference + "'");
}
Aggregations