Skip to content

Commit 30e584d

Browse files
committedNov 3, 2018
[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
1 parent eb5d487 commit 30e584d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed
 

‎src/providers/mssql/qgsmssqlconnection.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,12 @@ QSqlDatabase QgsMssqlConnection::getDatabase( const QString &service, const QStr
9898
#ifdef Q_OS_WIN
9999
connectionString = "driver={SQL Server}";
100100
#else
101-
connectionString = QStringLiteral( "driver={FreeTDS};port=1433" );
101+
// It seems that FreeTDS driver by default uses an ancient TDS protocol version (4.2) to communicate with MS SQL
102+
// which was causing various data corruption errors, for example:
103+
// - truncating data from varchar columns to 255 chars - failing to read WKT for CRS
104+
// - truncating binary data to 4096 bytes (see @@TEXTSIZE) - failing to parse larger geometries
105+
// The added "TDS_Version=auto" should negotiate more recent version (manually setting e.g. 7.2 worked fine too)
106+
connectionString = QStringLiteral( "driver={FreeTDS};port=1433;TDS_Version=auto" );
102107
#endif
103108
}
104109

0 commit comments

Comments
 (0)
Please sign in to comment.