Skip to content

Commit

Permalink
fid is the default if the ID column is empty when we create a geopackage
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustry authored and nyalldawson committed Sep 13, 2018
1 parent a7ea3ea commit 31daa82
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/gui/qgsnewgeopackagelayerdialog.cpp
Expand Up @@ -44,6 +44,8 @@
#include <cpl_error.h>
#include <cpl_string.h>

#define DEFAULT_OGR_FID_COLUMN_TITLE "fid" // default value from OGR

QgsNewGeoPackageLayerDialog::QgsNewGeoPackageLayerDialog( QWidget *parent, Qt::WindowFlags fl )
: QDialog( parent, fl )
{
Expand Down Expand Up @@ -85,7 +87,7 @@ QgsNewGeoPackageLayerDialog::QgsNewGeoPackageLayerDialog( QWidget *parent, Qt::W
mGeometryWithMCheckBox->setEnabled( false );
mGeometryColumnEdit->setEnabled( false );
mGeometryColumnEdit->setText( "geometry" );
mFeatureIdColumnEdit->setText( "fid" );
mFeatureIdColumnEdit->setPlaceholderText( DEFAULT_OGR_FID_COLUMN_TITLE );
mCheckBoxCreateSpatialIndex->setEnabled( false );
mCrsSelector->setEnabled( false );

Expand Down Expand Up @@ -192,7 +194,8 @@ void QgsNewGeoPackageLayerDialog::mAddAttributeButton_clicked()
if ( !mFieldNameEdit->text().isEmpty() )
{
QString myName = mFieldNameEdit->text();
if ( myName == mFeatureIdColumnEdit->text() )
const QString featureId = mFeatureIdColumnEdit->text().isEmpty() ? DEFAULT_OGR_FID_COLUMN_TITLE : mFeatureIdColumnEdit->text();
if ( myName.compare( featureId, Qt::CaseInsensitive ) == 0 )
{
QMessageBox::critical( this, tr( "Add Field" ), tr( "The field cannot have the same name as the feature identifier." ) );
return;
Expand Down

0 comments on commit 31daa82

Please sign in to comment.