Skip to content

Commit b07e373

Browse files
mrylovnyalldawson
authored andcommittedOct 27, 2021
HANA: improve error message by unknown types
1 parent 3d55a14 commit b07e373

File tree

4 files changed

+5
-17
lines changed

4 files changed

+5
-17
lines changed
 

‎external/odbccpp/src/odbc/Types.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@ class SQLDataTypes
175175
static constexpr int TypeTime = 92;
176176
/// Year, month, day, hour, minute, and second fields.
177177
static constexpr int TypeTimestamp = 93;
178+
/// Unknown data type.
179+
static constexpr int Unknown = 0;
178180
/// Variable length binary data.
179181
static constexpr int VarBinary = -3;
180182
/// Variable-length character string.

‎src/providers/hana/qgshanaconnection.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,8 @@ void QgsHanaConnection::readTableFields( const QString &schemaName, const QStrin
826826
field.name = rsColumns->getString( 4/*COLUMN_NAME*/ );
827827
field.type = rsColumns->getShort( 5/*DATA_TYPE*/ );
828828
field.typeName = rsColumns->getString( 6/*TYPE_NAME*/ );
829+
if ( field.type == SQLDataTypes::Unknown )
830+
throw QgsHanaException( QString( "Type of the column '%1' is unknown" ).arg( field.name ) );
829831
field.size = rsColumns->getInt( 7/*COLUMN_SIZE*/ );
830832
field.precision = static_cast<int>( rsColumns->getShort( 9/*DECIMAL_DIGITS*/ ) );
831833
field.isSigned = field.type == SQLDataTypes::SmallInt || field.type == SQLDataTypes::Integer ||

‎src/providers/hana/qgshanaproviderconnection.cpp

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ QgsFields QgsHanaProviderConnection::fields( const QString &schema, const QStrin
439439
}
440440
catch ( const QgsHanaException &ex )
441441
{
442-
throw QgsProviderConnectionException( QObject::tr( "Could not retrieve fields: %1, %2" ).arg( uri(), ex.what() ) );
442+
throw QgsProviderConnectionException( QObject::tr( "Could not retrieve fields: %1" ).arg( ex.what() ) );
443443
}
444444
}
445445

@@ -475,19 +475,6 @@ QList<QgsVectorDataProvider::NativeType> QgsHanaProviderConnection::nativeTypes(
475475
return types;
476476
}
477477

478-
QgsAbstractDatabaseProviderConnection::SqlVectorLayerOptions QgsHanaProviderConnection::sqlOptions( const QString &layerSource )
479-
{
480-
SqlVectorLayerOptions options;
481-
const QgsDataSourceUri uri( layerSource );
482-
options.primaryKeyColumns = uri.keyColumn().split( ',' );
483-
options.disableSelectAtId = uri.selectAtIdDisabled();
484-
options.geometryColumn = uri.geometryColumn();
485-
options.filter = uri.sql();
486-
const QString trimmedTable { uri.table().trimmed() };
487-
options.sql = trimmedTable.startsWith( '(' ) ? trimmedTable.mid( 1 ).chopped( 1 ) : QStringLiteral( "SELECT * FROM %1" ).arg( uri.quotedTablename() );
488-
return options;
489-
}
490-
491478
QVariantList QgsHanaEmptyProviderResultIterator::nextRowPrivate()
492479
{
493480
return QVariantList();

‎src/providers/hana/qgshanaproviderconnection.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,6 @@ class QgsHanaProviderConnection : public QgsAbstractDatabaseProviderConnection
7878
void remove( const QString &name ) const override;
7979
QIcon icon() const override;
8080
QList<QgsVectorDataProvider::NativeType> nativeTypes() const override;
81-
//QgsVectorLayer *createSqlVectorLayer( const SqlVectorLayerOptions &options ) const override;
82-
//QMultiMap<Qgis::SqlKeywordCategory, QStringList> sqlDictionary() override;
83-
SqlVectorLayerOptions sqlOptions( const QString &layerSource ) override;
8481

8582
private:
8683
QgsHanaConnectionRef createConnection() const;

0 commit comments

Comments
 (0)
Please sign in to comment.