Skip to content
Permalink
Browse files

[mssql] fix a bunch of strange bugs when connecting from linux

These include:
- fetching incomplete (corrupted) geometries
- fetching incomplete text data (e.g. WKT for CRS)

Also fixes a bug with empty attribute table for some ms sql layers

(cherry picked from commit 30e584d)
  • Loading branch information
wonder-sk authored and nyalldawson committed Nov 3, 2018
1 parent 711feec commit 637f47c9b3cb1141e1973482f79934872f8a45a6
Showing with 6 additions and 1 deletion.
  1. +6 −1 src/providers/mssql/qgsmssqlconnection.cpp
@@ -98,7 +98,12 @@ QSqlDatabase QgsMssqlConnection::getDatabase( const QString &service, const QStr
#ifdef Q_OS_WIN
connectionString = "driver={SQL Server}";
#else
connectionString = QStringLiteral( "driver={FreeTDS};port=1433" );
// It seems that FreeTDS driver by default uses an ancient TDS protocol version (4.2) to communicate with MS SQL
// which was causing various data corruption errors, for example:
// - truncating data from varchar columns to 255 chars - failing to read WKT for CRS
// - truncating binary data to 4096 bytes (see @@TEXTSIZE) - failing to parse larger geometries
// The added "TDS_Version=auto" should negotiate more recent version (manually setting e.g. 7.2 worked fine too)
connectionString = QStringLiteral( "driver={FreeTDS};port=1433;TDS_Version=auto" );
#endif
}

0 comments on commit 637f47c

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