Skip to content

Commit

Permalink
backport [MSSQL] Fix update/insert with timestamp columns
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanW2 committed Apr 12, 2017
1 parent 6e0ca9b commit 544e19e
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/providers/mssql/qgsmssqlprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,10 @@ bool QgsMssqlProvider::addFeatures( QgsFeatureList & flist )
{
QgsField fld = mAttributeFields.at( i );

if ( fld.typeName().endsWith( " identity", Qt::CaseInsensitive ) )
if ( fld.typeName().toLower() == QLatin1String( "timestamp" ) )
continue; // You can't update timestamp columns they are server only.

if ( fld.typeName().endsWith( QLatin1String( " identity" ), Qt::CaseInsensitive ) )
continue; // skip identity field

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

if ( fld.typeName().endsWith( " identity", Qt::CaseInsensitive ) )
if ( fld.typeName().toLower() == QLatin1String( "timestamp" ) )
continue; // You can't update timestamp columns they are server only.

if ( fld.typeName().endsWith( QLatin1String( " identity" ), Qt::CaseInsensitive ) )
continue; // skip identity field

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

if ( fld.typeName().endsWith( " identity", Qt::CaseInsensitive ) )
if ( fld.typeName().toLower() == QLatin1String( "timestamp" ) )
continue; // You can't update timestamp columns they are server only.

if ( fld.typeName().endsWith( QLatin1String( " identity" ), Qt::CaseInsensitive ) )
continue; // skip identity field

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

if ( fld.typeName().endsWith( " identity", Qt::CaseInsensitive ) )
if ( fld.typeName().toLower() == QLatin1String( "timestamp" ) )
continue; // You can't update timestamp columns they are server only.

if ( fld.typeName().endsWith( QLatin1String( " identity" ), Qt::CaseInsensitive ) )
continue; // skip identity field

if ( fld.name().isEmpty() )
Expand Down

0 comments on commit 544e19e

Please sign in to comment.