Skip to content
Permalink
Browse files

Fix spatialite PKs autoincrement backticks

... also fixes "Autogenerate" for PKs

Fixes #34085
  • Loading branch information
elpaso committed Jan 28, 2020
1 parent 439a3aa commit 171c5228417cdd679e8662f09e1b2fff70803c62
Showing with 5 additions and 1 deletion.
  1. +5 −1 src/providers/spatialite/qgsspatialiteprovider.cpp
@@ -936,7 +936,7 @@ void QgsSpatiaLiteProvider::fetchConstraints()
if ( rows >= 1 )
{
QString tableSql = QString::fromUtf8( results[ 1 ] );
QRegularExpression rx( QStringLiteral( "[(,]\\s*(?:%1|\"%1\")\\s+INTEGER PRIMARY KEY AUTOINCREMENT" ).arg( mPrimaryKey ), QRegularExpression::CaseInsensitiveOption );
QRegularExpression rx( QStringLiteral( "[(,]\\s*(?:%1|\"%1\"|`%1`)\\s+INTEGER PRIMARY KEY AUTOINCREMENT" ).arg( mPrimaryKey ), QRegularExpression::CaseInsensitiveOption );
if ( tableSql.contains( rx ) )
{
mPrimaryKeyAutoIncrement = true;
@@ -1024,6 +1024,10 @@ QVariant QgsSpatiaLiteProvider::defaultValue( int fieldId ) const

QString QgsSpatiaLiteProvider::defaultValueClause( int fieldIndex ) const
{
if ( mAttributeFields.at( fieldIndex ).name() == mPrimaryKey && mPrimaryKeyAutoIncrement )
{
return tr( "Autogenerate" );
}
return mDefaultValueClause.value( fieldIndex, QString() );
}

0 comments on commit 171c522

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