fix #35026 fix MSSQL connection on MacOS

This commit is contained in:
Peter Petrik 2020-09-29 17:24:25 +02:00 committed by Nyall Dawson
parent 9c9b070d47
commit 09f84eb84b

View File

@ -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: