Skip to content
Permalink
Browse files

fix adding features on geometryless tables

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@14834 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
brushtyler
brushtyler committed Dec 3, 2010
1 parent 43214b4 commit 7123fa6949dfa653011a0e954bff7507db63088f
Showing with 18 additions and 16 deletions.
  1. +18 −16 src/providers/postgres/qgspostgresprovider.cpp
@@ -2265,33 +2265,32 @@ bool QgsPostgresProvider::addFeatures( QgsFeatureList &flist )
connectionRW->PQexecNR( "BEGIN" );

// Prepare the INSERT statement
QString insert = QString( "INSERT INTO %1(" ).arg( mQuery );
QString values;
QString insert = QString( "INSERT INTO %1 (" ).arg( mQuery );
QString values = ") VALUES (";
QString delim = ",";
int offset = 1;

if ( !geometryColumn.isNull() )
{
insert += quotedIdentifier( geometryColumn );
values = QString( ") VALUES (GeomFromWKB($1%1,%2)" )
.arg( connectionRW->useWkbHex() ? "" : "::bytea" )
.arg( srid );
values += QString( "GeomFromWKB($%1%2,%3)" )
.arg( offset )
.arg( connectionRW->useWkbHex() ? "" : "::bytea" )
.arg( srid );
offset += 1;
delim = ",";
}
else
{
delim = "";
}

int offset;
if ( primaryKeyType != "tid" && primaryKeyType != "oid" )
{
insert += delim + quotedIdentifier( primaryKey );
values += delim + "$2";
offset = 3;
}
else
{
offset = 2;
values += delim + QString( "$%1" ).arg( offset );
offset += 1;
delim = ",";
}

const QgsAttributeMap &attributevec = flist[0].attributeMap();
@@ -2393,11 +2392,14 @@ bool QgsPostgresProvider::addFeatures( QgsFeatureList &flist )
{
const QgsAttributeMap &attributevec = features->attributeMap();

QString geomParam;
appendGeomString( features->geometry(), geomParam );

QStringList params;
params << geomParam;
if ( !geometryColumn.isNull() )
{
QString geomParam;
appendGeomString( features->geometry(), geomParam );

params << geomParam;
}

if ( primaryKeyType != "tid" && primaryKeyType != "oid" )
{

0 comments on commit 7123fa6

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