Skip to content

Commit 31daa82

Browse files
Gustrynyalldawson
authored andcommitted
fid is the default if the ID column is empty when we create a geopackage
1 parent a7ea3ea commit 31daa82

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/gui/qgsnewgeopackagelayerdialog.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
#include <cpl_error.h>
4545
#include <cpl_string.h>
4646

47+
#define DEFAULT_OGR_FID_COLUMN_TITLE "fid" // default value from OGR
48+
4749
QgsNewGeoPackageLayerDialog::QgsNewGeoPackageLayerDialog( QWidget *parent, Qt::WindowFlags fl )
4850
: QDialog( parent, fl )
4951
{
@@ -85,7 +87,7 @@ QgsNewGeoPackageLayerDialog::QgsNewGeoPackageLayerDialog( QWidget *parent, Qt::W
8587
mGeometryWithMCheckBox->setEnabled( false );
8688
mGeometryColumnEdit->setEnabled( false );
8789
mGeometryColumnEdit->setText( "geometry" );
88-
mFeatureIdColumnEdit->setText( "fid" );
90+
mFeatureIdColumnEdit->setPlaceholderText( DEFAULT_OGR_FID_COLUMN_TITLE );
8991
mCheckBoxCreateSpatialIndex->setEnabled( false );
9092
mCrsSelector->setEnabled( false );
9193

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

0 commit comments

Comments
 (0)