Skip to content

Commit

Permalink
[MSSQL] Remove Z/M from WKT type name on insert/update
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
NathanW2 committed Jun 22, 2017
1 parent f196246 commit c793a92
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/providers/mssql/qgsmssqlprovider.cpp
Expand Up @@ -995,7 +995,13 @@ bool QgsMssqlProvider::addFeatures( QgsFeatureList &flist, Flags flags )
{
QString wkt;
if ( !geom.isNull() )
{
// Z and M on the end of a WKT string isn't valid for
// SQL Server so we have to remove it first.
wkt = geom.exportToWkt();
wkt = wkt.replace( "Z", "" );
wkt = wkt.replace( "M", "" );
}
query.addBindValue( wkt );
}
}
Expand Down Expand Up @@ -1328,6 +1334,11 @@ bool QgsMssqlProvider::changeGeometryValues( const QgsGeometryMap &geometry_map
else
{
QString wkt = it->exportToWkt();
// Z and M on the end of a WKT string isn't valid for
// SQL Server so we have to remove it first.
wkt = wkt.replace( "Z", "" );
wkt = wkt.replace( "M", "" );
QgsDebugMsg( wkt );
query.addBindValue( wkt );
}

Expand Down

0 comments on commit c793a92

Please sign in to comment.