Skip to content

Commit

Permalink
[MSSQL] Correctly interpret geometry-type setting
Browse files Browse the repository at this point in the history
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 25587f6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/providers/mssql/qgsmssqltablemodel.cpp
Expand Up @@ -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();
Expand Down

0 comments on commit 25587f6

Please sign in to comment.