Skip to content

Commit

Permalink
[mssql] Fix shifted attributes after importing layers via browser
Browse files Browse the repository at this point in the history
drag and drop

Fixes #15305
  • Loading branch information
nyalldawson committed Oct 5, 2018
1 parent 10095ce commit b7f5a3c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/providers/mssql/qgsmssqlprovider.cpp
Expand Up @@ -1710,10 +1710,8 @@ QgsVectorLayerExporter::ExportError QgsMssqlProvider::createEmptyLayer( const QS
if ( wkbType != QgsWkbTypes::NoGeometry && geometryColumn.isEmpty() )
geometryColumn = QStringLiteral( "geom" );

if ( primaryKey.isEmpty() )
primaryKey = QStringLiteral( "qgs_fid" );

// get the pk's name and type
bool createdNewPk = false;

// if no pk name was passed, define the new pk field name
if ( primaryKey.isEmpty() )
Expand All @@ -1729,6 +1727,7 @@ QgsVectorLayerExporter::ExportError QgsMssqlProvider::createEmptyLayer( const QS
i = 0;
}
}
createdNewPk = true;
}
else
{
Expand Down Expand Up @@ -1879,7 +1878,8 @@ QgsVectorLayerExporter::ExportError QgsMssqlProvider::createEmptyLayer( const QS

if ( fields.size() > 0 )
{
int offset = 0;
// if we had to create a primary key column, we start the old columns from 1
int offset = createdNewPk ? 1 : 0;

// get the list of fields
QList<QgsField> flist;
Expand Down

0 comments on commit b7f5a3c

Please sign in to comment.