Skip to content

Commit

Permalink
[mssql] fix a bunch of strange bugs when connecting from linux
Browse files Browse the repository at this point in the history
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 6, 2018
1 parent 711feec commit 637f47c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/providers/mssql/qgsmssqlconnection.cpp
Expand Up @@ -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
}

Expand Down

0 comments on commit 637f47c

Please sign in to comment.