Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[MSSQL] Don't add constraints for identity columns
These are generated server side and will block the form if we set
this client side
  • Loading branch information
NathanW2 committed Nov 13, 2017
1 parent 82644fb commit 9369e5c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/providers/mssql/qgsmssqlprovider.cpp
Expand Up @@ -365,6 +365,7 @@ void QgsMssqlProvider::loadMetadata()

void QgsMssqlProvider::loadFields()
{
bool isIdentity = false;
mAttributeFields.clear();
mDefaultValues.clear();
mComputedColumns.clear();
Expand Down Expand Up @@ -410,7 +411,10 @@ void QgsMssqlProvider::loadFields()
{
QVariant::Type sqlType = DecodeSqlType( sqlTypeName );
if ( sqlTypeName == QLatin1String( "int identity" ) || sqlTypeName == QLatin1String( "bigint identity" ) )
{
mFidColName = query.value( 3 ).toString();
isIdentity = true;
}
else if ( sqlTypeName == QLatin1String( "int" ) || sqlTypeName == QLatin1String( "bigint" ) )
{
pkCandidates << query.value( 3 ).toString();
Expand Down Expand Up @@ -499,7 +503,7 @@ void QgsMssqlProvider::loadFields()
setLastError( error );
}

if ( !mFidColName.isEmpty() )
if ( !mFidColName.isEmpty() && !isIdentity )
{
mFidColIdx = mAttributeFields.indexFromName( mFidColName );
if ( mFidColIdx >= 0 )
Expand Down

0 comments on commit 9369e5c

Please sign in to comment.