mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
oracle provider: verify existence of layer style table before trying to retrieve a style
This commit is contained in:
parent
1af74f7ace
commit
61eea8674a
@ -3163,9 +3163,7 @@ bool QOCISpatialResult::exec()
|
||||
qOraWarning( "Unable to get statement type:", d->err );
|
||||
setLastError( qMakeError( QCoreApplication::translate( "QOCISpatialResult",
|
||||
"Unable to get statement type" ), QSqlError::StatementError, d->err ) );
|
||||
#ifdef QOCISPATIAL_DEBUG
|
||||
qDebug() << "lastQuery()" << lastQuery();
|
||||
#endif
|
||||
qWarning( "type retrieval failed with statement:%s", lastQuery().toLocal8Bit().constData() );
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -3189,9 +3187,7 @@ bool QOCISpatialResult::exec()
|
||||
qOraWarning( "unable to bind value: ", d->err );
|
||||
setLastError( qMakeError( QCoreApplication::translate( "QOCISpatialResult", "Unable to bind value" ),
|
||||
QSqlError::StatementError, d->err ) );
|
||||
#ifdef QOCISPATIAL_DEBUG
|
||||
qDebug() << "lastQuery()" << lastQuery();
|
||||
#endif
|
||||
qWarning( "bind failed with statement:%s", lastQuery().toLocal8Bit().constData() );
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -3202,9 +3198,7 @@ bool QOCISpatialResult::exec()
|
||||
qOraWarning( "unable to execute statement:", d->err );
|
||||
setLastError( qMakeError( QCoreApplication::translate( "QOCISpatialResult",
|
||||
"Unable to execute statement" ), QSqlError::StatementError, d->err ) );
|
||||
#ifdef QOCISPATIAL_DEBUG
|
||||
qDebug() << "lastQuery()" << lastQuery();
|
||||
#endif
|
||||
qWarning( "execution failed with statement:%s", lastQuery().toLocal8Bit().constData() );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -3402,19 +3402,25 @@ QGISEXTERN QString loadStyle( const QString &uri, QString &errCause )
|
||||
QSqlQuery qry( *conn );
|
||||
|
||||
QString style;
|
||||
if ( !qry.exec( QString( "SELECT styleQML FROM ("
|
||||
"SELECT styleQML"
|
||||
" FROM layer_styles"
|
||||
" WHERE f_table_catalog=%1"
|
||||
" AND f_table_schema=%2"
|
||||
" AND f_table_name=%3"
|
||||
" AND f_geometry_column=%4"
|
||||
" ORDER BY useAsDefault DESC"
|
||||
") WHERE rownum=1" )
|
||||
.arg( QgsOracleConn::quotedValue( dsUri.database() ) )
|
||||
.arg( QgsOracleConn::quotedValue( dsUri.schema() ) )
|
||||
.arg( QgsOracleConn::quotedValue( dsUri.table() ) )
|
||||
.arg( QgsOracleConn::quotedValue( dsUri.geometryColumn() ) ) ) )
|
||||
if ( !qry.exec( "SELECT COUNT(*) FROM user_tables WHERE table_name='LAYER_STYLES'" ) || !qry.next() || qry.value( 0 ).toInt() == 0 )
|
||||
{
|
||||
errCause = QObject::tr( "Unable layer style table not found [%1]" ).arg( qry.lastError().text() );
|
||||
conn->disconnect();
|
||||
return QString::null;
|
||||
}
|
||||
else if ( !qry.exec( QString( "SELECT styleQML FROM ("
|
||||
"SELECT styleQML"
|
||||
" FROM layer_styles"
|
||||
" WHERE f_table_catalog=%1"
|
||||
" AND f_table_schema=%2"
|
||||
" AND f_table_name=%3"
|
||||
" AND f_geometry_column=%4"
|
||||
" ORDER BY useAsDefault DESC"
|
||||
") WHERE rownum=1" )
|
||||
.arg( QgsOracleConn::quotedValue( dsUri.database() ) )
|
||||
.arg( QgsOracleConn::quotedValue( dsUri.schema() ) )
|
||||
.arg( QgsOracleConn::quotedValue( dsUri.table() ) )
|
||||
.arg( QgsOracleConn::quotedValue( dsUri.geometryColumn() ) ) ) )
|
||||
{
|
||||
errCause = QObject::tr( "Could not retrieve style [%1]" ).arg( qry.lastError().text() );
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user