Skip to content
Permalink
Browse files

[mssql] Ensure provider rejects features with incorrect geometry type

  • Loading branch information
nyalldawson committed Oct 22, 2018
1 parent f4e6477 commit cd64d31b39e0a21b8e06f2d1170e8b44bac2e116
Showing with 15 additions and 0 deletions.
  1. +15 −0 src/providers/mssql/qgsmssqlprovider.cpp
@@ -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 );

0 comments on commit cd64d31

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