Skip to content
Permalink
Browse files

fix #35026 fix MSSQL connection on MacOS

  • Loading branch information
PeterPetrik authored and nyalldawson committed Oct 1, 2020
1 parent 9c9b070 commit 09f84eb84b0eb3b4e7a2f7b15ed662383e95d82c
Showing with 11 additions and 0 deletions.
  1. +11 −0 src/providers/mssql/qgsmssqlconnection.cpp
@@ -25,6 +25,7 @@
#include <QSqlQuery>
#include <QSet>
#include <QCoreApplication>
#include <QFile>

int QgsMssqlConnection::sConnectionId = 0;
QMutex QgsMssqlConnection::sMutex{ QMutex::Recursive };
@@ -97,6 +98,16 @@ QSqlDatabase QgsMssqlConnection::getDatabase( const QString &service, const QStr
{
#ifdef Q_OS_WIN
connectionString = "driver={SQL Server}";
#elif defined (Q_OS_MAC)
QString freeTDSDriver( QCoreApplication::applicationDirPath().append( "/lib/libtdsodbc.so" ) );
if ( QFile::exists( freeTDSDriver ) )
{
connectionString = QStringLiteral( "driver=%1;port=1433;TDS_Version=auto" ).arg( freeTDSDriver );
}
else
{
connectionString = QStringLiteral( "driver={FreeTDS};port=1433;TDS_Version=auto" );
}
#else
// 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:

0 comments on commit 09f84eb

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