Skip to content

Commit c793a92

Browse files
committed
[MSSQL] Remove Z/M from WKT type name on insert/update
SQL Server doesn't follow OGC standard of LINESTRINGZ so we have to remove it. SQL support LINESTRING(x y z) but not LINESTRINGZ(x y z)
1 parent f196246 commit c793a92

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/providers/mssql/qgsmssqlprovider.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -995,7 +995,13 @@ bool QgsMssqlProvider::addFeatures( QgsFeatureList &flist, Flags flags )
995995
{
996996
QString wkt;
997997
if ( !geom.isNull() )
998+
{
999+
// Z and M on the end of a WKT string isn't valid for
1000+
// SQL Server so we have to remove it first.
9981001
wkt = geom.exportToWkt();
1002+
wkt = wkt.replace( "Z", "" );
1003+
wkt = wkt.replace( "M", "" );
1004+
}
9991005
query.addBindValue( wkt );
10001006
}
10011007
}
@@ -1328,6 +1334,11 @@ bool QgsMssqlProvider::changeGeometryValues( const QgsGeometryMap &geometry_map
13281334
else
13291335
{
13301336
QString wkt = it->exportToWkt();
1337+
// Z and M on the end of a WKT string isn't valid for
1338+
// SQL Server so we have to remove it first.
1339+
wkt = wkt.replace( "Z", "" );
1340+
wkt = wkt.replace( "M", "" );
1341+
QgsDebugMsg( wkt );
13311342
query.addBindValue( wkt );
13321343
}
13331344

0 commit comments

Comments
 (0)