Skip to content

Commit 63b2267

Browse files
committedNov 22, 2018
[mssql] Fix import of layers with invalid geometries (fixes #20122)
This essentially reverts 62f4534 Rationale: - even valid geometries according to GEOS may be considered as invalid by MS SQL so there is no way of knowing that a geometry may be fail to be added - change of geometries applies MakeValid() so it is consistent again - GDAL driver also applies MakeValid() on all added/changed geometries - QGIS since 3.4 has optional geometry checks for validity etc. so some truly invalid geometries may be fixed before submitted to the provider See also #8411 (cherry picked from commit b1fd7b5)
1 parent 7c4708e commit 63b2267

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed
 

‎src/providers/mssql/qgsmssqlprovider.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -927,10 +927,10 @@ bool QgsMssqlProvider::addFeatures( QgsFeatureList &flist, Flags flags )
927927
if ( mGeometryColType == QLatin1String( "geometry" ) )
928928
{
929929
if ( mUseWkb )
930-
values += QStringLiteral( "geometry::STGeomFromWKB(%1,%2)" ).arg(
930+
values += QStringLiteral( "geometry::STGeomFromWKB(%1,%2).MakeValid()" ).arg(
931931
QStringLiteral( "?" ), QString::number( mSRId ) );
932932
else
933-
values += QStringLiteral( "geometry::STGeomFromText(%1,%2)" ).arg(
933+
values += QStringLiteral( "geometry::STGeomFromText(%1,%2).MakeValid()" ).arg(
934934
QStringLiteral( "?" ), QString::number( mSRId ) );
935935
}
936936
else

0 commit comments

Comments
 (0)