Skip to content

Commit

Permalink
[bugfix] Issue #17387: MSSQL provider fails to load UNIQUEIDENTIFIER …
Browse files Browse the repository at this point in the history
…fields (#5521)

* Fix #17387: MSSQL provider fails to load UNIQUEIDENTIFIER fields
  • Loading branch information
kthy authored and NathanW2 committed Nov 13, 2017
1 parent 150a64e commit 320bda0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/providers/mssql/qgsmssqlprovider.cpp
Expand Up @@ -417,7 +417,9 @@ void QgsMssqlProvider::loadFields()
}
if ( sqlType == QVariant::String )
{
int length = query.value( 7 ).toInt();
// Field length in chars is column 7 ("Length") of the sp_columns output,
// except for uniqueidentifiers which must use column 6 ("Precision").
int length = query.value( sqlTypeName.startsWith( QLatin1String( "uniqueidentifier" ), Qt::CaseInsensitive ) ? 6 : 7 ).toInt();
if ( sqlTypeName.startsWith( QLatin1String( "n" ) ) )
{
length = length / 2;
Expand Down

0 comments on commit 320bda0

Please sign in to comment.