Skip to content
Permalink
Browse files

fid is the default if the ID column is empty when we create a geopackage

  • Loading branch information
Gustry authored and nyalldawson committed Sep 13, 2018
1 parent a7ea3ea commit 31daa826c0fb35138b36c5c8035a8d177b76dcd9
Showing with 5 additions and 2 deletions.
  1. +5 −2 src/gui/qgsnewgeopackagelayerdialog.cpp
@@ -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 )
{
@@ -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 );

@@ -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;

0 comments on commit 31daa82

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