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
  • Loading branch information
wonder-sk committed Nov 3, 2018
1 parent eb5d487 commit 30e584d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/providers/mssql/qgsmssqlconnection.cpp
Original file line number Diff line number Diff line change
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 30e584d

Please sign in to comment.