Skip to content

Commit

Permalink
[mssql] Ensure provider rejects features with incorrect geometry type
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Oct 25, 2018
1 parent f4e6477 commit cd64d31
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/providers/mssql/qgsmssqlprovider.cpp
Expand Up @@ -855,6 +855,21 @@ bool QgsMssqlProvider::addFeatures( QgsFeatureList &flist, Flags flags )
{
for ( QgsFeatureList::iterator it = flist.begin(); it != flist.end(); ++it )
{
if ( it->hasGeometry() && mWkbType == QgsWkbTypes::NoGeometry )
{
it->clearGeometry();
}
else if ( it->hasGeometry() && QgsWkbTypes::geometryType( it->geometry().wkbType() ) !=
QgsWkbTypes::geometryType( mWkbType ) )
{
pushError( tr( "Could not add feature with geometry type %1 to layer of type %2" ).arg( QgsWkbTypes::displayString( it->geometry().wkbType() ),
QgsWkbTypes::displayString( mWkbType ) ) );
if ( !mSkipFailures )
return false;

continue;
}

QString statement;
QString values;
statement = QStringLiteral( "INSERT INTO [%1].[%2] (" ).arg( mSchemaName, mTableName );
Expand Down

0 comments on commit cd64d31

Please sign in to comment.