Skip to content
Permalink
Browse files
HANA: improve error message by unknown types
  • Loading branch information
mrylov authored and nyalldawson committed Oct 27, 2021
1 parent 3d55a14 commit b07e37390ecd1d24c648f2c6225e8f50cd9e56fc
@@ -175,6 +175,8 @@ class SQLDataTypes
static constexpr int TypeTime = 92;
/// Year, month, day, hour, minute, and second fields.
static constexpr int TypeTimestamp = 93;
/// Unknown data type.
static constexpr int Unknown = 0;
/// Variable length binary data.
static constexpr int VarBinary = -3;
/// Variable-length character string.
@@ -826,6 +826,8 @@ void QgsHanaConnection::readTableFields( const QString &schemaName, const QStrin
field.name = rsColumns->getString( 4/*COLUMN_NAME*/ );
field.type = rsColumns->getShort( 5/*DATA_TYPE*/ );
field.typeName = rsColumns->getString( 6/*TYPE_NAME*/ );
if ( field.type == SQLDataTypes::Unknown )
throw QgsHanaException( QString( "Type of the column '%1' is unknown" ).arg( field.name ) );
field.size = rsColumns->getInt( 7/*COLUMN_SIZE*/ );
field.precision = static_cast<int>( rsColumns->getShort( 9/*DECIMAL_DIGITS*/ ) );
field.isSigned = field.type == SQLDataTypes::SmallInt || field.type == SQLDataTypes::Integer ||
@@ -439,7 +439,7 @@ QgsFields QgsHanaProviderConnection::fields( const QString &schema, const QStrin
}
catch ( const QgsHanaException &ex )
{
throw QgsProviderConnectionException( QObject::tr( "Could not retrieve fields: %1, %2" ).arg( uri(), ex.what() ) );
throw QgsProviderConnectionException( QObject::tr( "Could not retrieve fields: %1" ).arg( ex.what() ) );
}
}

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

QgsAbstractDatabaseProviderConnection::SqlVectorLayerOptions QgsHanaProviderConnection::sqlOptions( const QString &layerSource )
{
SqlVectorLayerOptions options;
const QgsDataSourceUri uri( layerSource );
options.primaryKeyColumns = uri.keyColumn().split( ',' );
options.disableSelectAtId = uri.selectAtIdDisabled();
options.geometryColumn = uri.geometryColumn();
options.filter = uri.sql();
const QString trimmedTable { uri.table().trimmed() };
options.sql = trimmedTable.startsWith( '(' ) ? trimmedTable.mid( 1 ).chopped( 1 ) : QStringLiteral( "SELECT * FROM %1" ).arg( uri.quotedTablename() );
return options;
}

QVariantList QgsHanaEmptyProviderResultIterator::nextRowPrivate()
{
return QVariantList();
@@ -78,9 +78,6 @@ class QgsHanaProviderConnection : public QgsAbstractDatabaseProviderConnection
void remove( const QString &name ) const override;
QIcon icon() const override;
QList<QgsVectorDataProvider::NativeType> nativeTypes() const override;
//QgsVectorLayer *createSqlVectorLayer( const SqlVectorLayerOptions &options ) const override;
//QMultiMap<Qgis::SqlKeywordCategory, QStringList> sqlDictionary() override;
SqlVectorLayerOptions sqlOptions( const QString &layerSource ) override;

private:
QgsHanaConnectionRef createConnection() const;

0 comments on commit b07e373

Please sign in to comment.