Skip to content
Permalink
Browse files

[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)
  • Loading branch information
NathanW2 committed Jun 22, 2017
1 parent 6cfd1a0 commit 53305a8507564e6e63a06aa379656c5ed87109e7
Showing with 12 additions and 1 deletion.
  1. +12 −1 src/providers/mssql/qgsmssqlprovider.cpp
@@ -985,7 +985,13 @@ bool QgsMssqlProvider::addFeatures( QgsFeatureList & flist )
{
QString wkt;
if ( geom && !geom->isEmpty() )
wkt = geom->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 = geom.exportToWkt();
wkt = wkt.replace( "Z", "" );
wkt = wkt.replace( "M", "" );
}
query.addBindValue( wkt );
}
}
@@ -1309,6 +1315,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 );
}

3 comments on commit 53305a8

@nyalldawson

This comment has been minimized.

Copy link
Collaborator

@nyalldawson nyalldawson replied Jun 22, 2017

Did you even test this commit?

@NathanW2

This comment has been minimized.

Copy link
Member Author

@NathanW2 NathanW2 replied Jun 22, 2017

in 3 yes.

@nyalldawson

This comment has been minimized.

Copy link
Collaborator

@nyalldawson nyalldawson replied Jun 22, 2017

:p

Damn, i wanted an excuse to go all "Linus" on you!

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