Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[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 53305a8
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/providers/mssql/qgsmssqlprovider.cpp
Expand Up @@ -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 );
}
}
Expand Down Expand Up @@ -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 );
}

Expand Down

3 comments on commit 53305a8

@nyalldawson
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you even test this commit?

@NathanW2
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in 3 yes.

@nyalldawson
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:p

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

Please sign in to comment.