Skip to content
Permalink
Browse files

[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 9369e5c137aa1e2cc26c023459f9ebb35920c718
Showing with 5 additions and 1 deletion.
  1. +5 −1 src/providers/mssql/qgsmssqlprovider.cpp
@@ -365,6 +365,7 @@ void QgsMssqlProvider::loadMetadata()

void QgsMssqlProvider::loadFields()
{
bool isIdentity = false;
mAttributeFields.clear();
mDefaultValues.clear();
mComputedColumns.clear();
@@ -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();
@@ -499,7 +503,7 @@ void QgsMssqlProvider::loadFields()
setLastError( error );
}

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

0 comments on commit 9369e5c

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