Skip to content
Permalink
Browse files
HANA layers are not listed due to a view with a dropped table
  • Loading branch information
mrylov authored and nyalldawson committed May 17, 2021
1 parent 92c7ccd commit 8e4de4b6dd1c0578fec34dae0433a9d16829d3cc
@@ -68,7 +68,8 @@ void QgsHanaColumnTypeThread::run()
.arg( layerProperty.schemaName, layerProperty.tableName, layerProperty.geometryColName ) );
conn->readLayerInfo( layerProperty );

emit setLayerType( layerProperty );
if ( layerProperty.isValid )
emit setLayerType( layerProperty );
}
}
catch ( const QgsHanaException &ex )
@@ -687,9 +687,18 @@ QVector<QgsHanaLayerProperty> QgsHanaConnection::getLayersFull(

void QgsHanaConnection::readLayerInfo( QgsHanaLayerProperty &layerProperty )
{
layerProperty.srid = getColumnSrid( layerProperty.schemaName, layerProperty.tableName, layerProperty.geometryColName );
layerProperty.type = getColumnGeometryType( layerProperty.schemaName, layerProperty.tableName, layerProperty.geometryColName );
layerProperty.pkCols = getPrimaryKeyCandidates( layerProperty );
try
{
layerProperty.srid = getColumnSrid( layerProperty.schemaName, layerProperty.tableName, layerProperty.geometryColName );
layerProperty.type = getColumnGeometryType( layerProperty.schemaName, layerProperty.tableName, layerProperty.geometryColName );
layerProperty.pkCols = getPrimaryKeyCandidates( layerProperty );
layerProperty.isValid = true;
}
catch ( const QgsHanaException &ex )
{
layerProperty.errorMessage = ex.what();
QgsMessageLog::logMessage( QgsHanaUtils::formatErrorMessage( ex.what() ), tr( "SAP HANA" ) );
}
}

void QgsHanaConnection::readQueryFields( const QString &schemaName, const QString &sql,
@@ -318,7 +318,16 @@ QVector<QgsDataItem *> QgsHanaSchemaItem::createChildren()

items.reserve( layers.size() );
for ( const QgsHanaLayerProperty &layerInfo : layers )
items.append( createLayer( layerInfo ) );
{
if ( layerInfo.isValid )
items.append( createLayer( layerInfo ) );
else
{
QgsErrorItem *itemInvalidLayer = new QgsErrorItem( this, layerInfo.defaultName(), mPath + "/error" );
itemInvalidLayer->setToolTip( layerInfo.errorMessage );
items.append( itemInvalidLayer );
}
}
}
catch ( const QgsHanaException &ex )
{
@@ -337,7 +346,7 @@ QgsHanaLayerItem *QgsHanaSchemaItem::createLayer( const QgsHanaLayerProperty &la
QString tip = layerProperty.isView ? QStringLiteral( "View" ) : QStringLiteral( "Table" );

QgsLayerItem::LayerType layerType = QgsLayerItem::TableLayer;
if ( !layerProperty.geometryColName.isEmpty() && layerProperty.isValid() )
if ( !layerProperty.geometryColName.isEmpty() && layerProperty.isGeometryValid() )
{
tip += tr( "\n%1 as %2" ).arg( layerProperty.geometryColName,
QgsWkbTypes::displayString( layerProperty.type ) );
@@ -41,6 +41,8 @@ struct QgsHanaLayerProperty
QString sql;
bool isView = false;
bool isUnique = false;
bool isValid = false;
QString errorMessage;

QString defaultName() const
{
@@ -50,7 +52,7 @@ struct QgsHanaLayerProperty
return ret;
}

bool isValid() const { return type != QgsWkbTypes::Unknown && srid >= 0; }
bool isGeometryValid() const { return type != QgsWkbTypes::Unknown && srid >= 0; }
};

class QIcon;

0 comments on commit 8e4de4b

Please sign in to comment.