Skip to content

Commit 544e19e

Browse files
committedApr 12, 2017
backport [MSSQL] Fix update/insert with timestamp columns
1 parent 6e0ca9b commit 544e19e

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed
 

‎src/providers/mssql/qgsmssqlprovider.cpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,10 @@ bool QgsMssqlProvider::addFeatures( QgsFeatureList & flist )
810810
{
811811
QgsField fld = mAttributeFields.at( i );
812812

813-
if ( fld.typeName().endsWith( " identity", Qt::CaseInsensitive ) )
813+
if ( fld.typeName().toLower() == QLatin1String( "timestamp" ) )
814+
continue; // You can't update timestamp columns they are server only.
815+
816+
if ( fld.typeName().endsWith( QLatin1String( " identity" ), Qt::CaseInsensitive ) )
814817
continue; // skip identity field
815818

816819
if ( fld.name().isEmpty() )
@@ -881,7 +884,10 @@ bool QgsMssqlProvider::addFeatures( QgsFeatureList & flist )
881884
{
882885
QgsField fld = mAttributeFields.at( i );
883886

884-
if ( fld.typeName().endsWith( " identity", Qt::CaseInsensitive ) )
887+
if ( fld.typeName().toLower() == QLatin1String( "timestamp" ) )
888+
continue; // You can't update timestamp columns they are server only.
889+
890+
if ( fld.typeName().endsWith( QLatin1String( " identity" ), Qt::CaseInsensitive ) )
885891
continue; // skip identity field
886892

887893
if ( fld.name().isEmpty() )
@@ -1111,7 +1117,10 @@ bool QgsMssqlProvider::changeAttributeValues( const QgsChangedAttributesMap &att
11111117
{
11121118
QgsField fld = mAttributeFields.at( it2.key() );
11131119

1114-
if ( fld.typeName().endsWith( " identity", Qt::CaseInsensitive ) )
1120+
if ( fld.typeName().toLower() == QLatin1String( "timestamp" ) )
1121+
continue; // You can't update timestamp columns they are server only.
1122+
1123+
if ( fld.typeName().endsWith( QLatin1String( " identity" ), Qt::CaseInsensitive ) )
11151124
continue; // skip identity field
11161125

11171126
if ( fld.name().isEmpty() )
@@ -1142,7 +1151,10 @@ bool QgsMssqlProvider::changeAttributeValues( const QgsChangedAttributesMap &att
11421151
{
11431152
QgsField fld = mAttributeFields.at( it2.key() );
11441153

1145-
if ( fld.typeName().endsWith( " identity", Qt::CaseInsensitive ) )
1154+
if ( fld.typeName().toLower() == QLatin1String( "timestamp" ) )
1155+
continue; // You can't update timestamp columns they are server only.
1156+
1157+
if ( fld.typeName().endsWith( QLatin1String( " identity" ), Qt::CaseInsensitive ) )
11461158
continue; // skip identity field
11471159

11481160
if ( fld.name().isEmpty() )

0 commit comments

Comments
 (0)
Please sign in to comment.