Skip to content

Commit f07b3f9

Browse files
szekerestNathanW2
authored andcommittedMar 28, 2012
Do not abort if sp_pkeys is not working
1 parent 45def21 commit f07b3f9

File tree

1 file changed

+18
-20
lines changed

1 file changed

+18
-20
lines changed
 

‎src/providers/mssql/qgsmssqlprovider.cpp

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -364,30 +364,28 @@ void QgsMssqlProvider::loadFields()
364364
if ( mQuery.next() )
365365
{
366366
mFidColName = mQuery.value( 3 ).toString();
367+
return;
367368
}
368-
else
369+
}
370+
foreach( QString pk, pkCandidates )
371+
{
372+
mQuery.clear();
373+
if (!mQuery.exec( QString( "select count(distinct [%1]), count([%1]) from [%2].[%3]" )
374+
.arg( pk )
375+
.arg( mSchemaName )
376+
.arg( mTableName ) ))
369377
{
370-
foreach( QString pk, pkCandidates )
378+
QString msg = mQuery.lastError().text();
379+
QgsDebugMsg( msg );
380+
}
381+
if ( mQuery.isActive() )
382+
{
383+
if ( mQuery.next() )
371384
{
372-
mQuery.clear();
373-
if (!mQuery.exec( QString( "select count(distinct [%1]), count([%1]) from [%2].[%3]" )
374-
.arg( pk )
375-
.arg( mSchemaName )
376-
.arg( mTableName ) ))
377-
{
378-
QString msg = mQuery.lastError().text();
379-
QgsDebugMsg( msg );
380-
}
381-
if ( mQuery.isActive() )
385+
if (mQuery.value( 0 ).toInt() == mQuery.value( 1 ).toInt())
382386
{
383-
if ( mQuery.next() )
384-
{
385-
if (mQuery.value( 0 ).toInt() == mQuery.value( 1 ).toInt())
386-
{
387-
mFidColName = pk;
388-
break;
389-
}
390-
}
387+
mFidColName = pk;
388+
return;
391389
}
392390
}
393391
}

0 commit comments

Comments
 (0)
Please sign in to comment.