Skip to content
Permalink
Browse files

[MSSQL] Correctly interpret geometry-type setting

Interpret a table's geometry type (as selected in the Data Source Manager) as a
value from the QgsWkbTypes::Type enum, matching the values used to populate the
combo box in QgsMssqlSourceSelectDelegate::createEditor().

This allows an empty table whose geometry type is set to "Polygon" to be
selected and added using the dialog.

Fixes #19578.

(cherry-picked from a9ca69b)
  • Loading branch information
Simon South authored and nyalldawson committed Aug 10, 2018
1 parent a3d954b commit 25587f64b1a04ce4fa738a47b68fc5606a0c22f4
Showing with 3 additions and 3 deletions.
  1. +3 −3 src/providers/mssql/qgsmssqltablemodel.cpp
@@ -321,11 +321,11 @@ bool QgsMssqlTableModel::setData( const QModelIndex &idx, const QVariant &value,

if ( idx.column() == DbtmType || idx.column() == DbtmSrid || idx.column() == DbtmPkCol )
{
QgsWkbTypes::GeometryType geomType = ( QgsWkbTypes::GeometryType ) idx.sibling( idx.row(), DbtmType ).data( Qt::UserRole + 2 ).toInt();
QgsWkbTypes::Type wkbType = ( QgsWkbTypes::Type ) idx.sibling( idx.row(), DbtmType ).data( Qt::UserRole + 2 ).toInt();

bool ok = geomType != QgsWkbTypes::UnknownGeometry;
bool ok = wkbType != QgsWkbTypes::Unknown;

if ( ok && geomType != QgsWkbTypes::NullGeometry )
if ( ok && wkbType != QgsWkbTypes::NoGeometry )
idx.sibling( idx.row(), DbtmSrid ).data().toInt( &ok );

QStringList pkCols = idx.sibling( idx.row(), DbtmPkCol ).data( Qt::UserRole + 1 ).toStringList();

0 comments on commit 25587f6

Please sign in to comment.
You can’t perform that action at this time.