Skip to content
Permalink
Browse files
fix #2137
git-svn-id: http://svn.osgeo.org/qgis/trunk@12235 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Nov 23, 2009
1 parent 53be3e1 commit 8a66aee713b0f258553ec559d5bfa844e1fc5a3d
Showing with 12 additions and 4 deletions.
  1. +12 −4 src/providers/postgres/qgspostgresprovider.cpp
@@ -2044,7 +2044,7 @@ QByteArray QgsPostgresProvider::paramValue( QString fieldValue, const QString &d
return fieldValue.toUtf8();
}

bool QgsPostgresProvider::addFeatures( QgsFeatureList & flist )
bool QgsPostgresProvider::addFeatures( QgsFeatureList &flist )
{
if ( flist.size() == 0 )
return true;
@@ -2082,6 +2082,7 @@ bool QgsPostgresProvider::addFeatures( QgsFeatureList & flist )

QStringList defaultValues;
QList<int> fieldId;
int primaryKeyId = -1;

// look for unique attribute values to place in statement instead of passing as parameter
// e.g. for defaults
@@ -2095,9 +2096,15 @@ bool QgsPostgresProvider::addFeatures( QgsFeatureList & flist )

QgsDebugMsg( "Checking field against: " + fieldname );

if ( fieldname.isEmpty() || fieldname == geometryColumn || fieldname == primaryKey )
if ( fieldname.isEmpty() || fieldname == geometryColumn )
continue;

if ( fieldname == primaryKey )
{
primaryKeyId = it.key();
continue;
}

int i;
for ( i = 1; i < flist.size(); i++ )
{
@@ -2179,15 +2186,16 @@ bool QgsPostgresProvider::addFeatures( QgsFeatureList & flist )

if ( primaryKeyType != "tid" )
{
if ( keyDefault.isNull() )
QByteArray key = paramValue( primaryKeyId >= 0 ? attributevec[ primaryKeyId ].toString() : QString::null, keyDefault );

if ( key.isNull() )
{
++primaryKeyHighWater;
params << QString::number( primaryKeyHighWater );
newIds << primaryKeyHighWater;
}
else
{
QByteArray key = paramValue( keyDefault, keyDefault );
params << key;
newIds << key.toInt();
}

0 comments on commit 8a66aee

Please sign in to comment.