mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-17 00:04:02 -04:00
fix adding features on geometryless tables
git-svn-id: http://svn.osgeo.org/qgis/trunk@14834 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
1d3b4f8f00
commit
3e0bd614d4
@ -2265,16 +2265,19 @@ bool QgsPostgresProvider::addFeatures( QgsFeatureList &flist )
|
|||||||
connectionRW->PQexecNR( "BEGIN" );
|
connectionRW->PQexecNR( "BEGIN" );
|
||||||
|
|
||||||
// Prepare the INSERT statement
|
// Prepare the INSERT statement
|
||||||
QString insert = QString( "INSERT INTO %1(" ).arg( mQuery );
|
QString insert = QString( "INSERT INTO %1 (" ).arg( mQuery );
|
||||||
QString values;
|
QString values = ") VALUES (";
|
||||||
QString delim = ",";
|
QString delim = ",";
|
||||||
|
int offset = 1;
|
||||||
|
|
||||||
if ( !geometryColumn.isNull() )
|
if ( !geometryColumn.isNull() )
|
||||||
{
|
{
|
||||||
insert += quotedIdentifier( geometryColumn );
|
insert += quotedIdentifier( geometryColumn );
|
||||||
values = QString( ") VALUES (GeomFromWKB($1%1,%2)" )
|
values += QString( "GeomFromWKB($%1%2,%3)" )
|
||||||
|
.arg( offset )
|
||||||
.arg( connectionRW->useWkbHex() ? "" : "::bytea" )
|
.arg( connectionRW->useWkbHex() ? "" : "::bytea" )
|
||||||
.arg( srid );
|
.arg( srid );
|
||||||
|
offset += 1;
|
||||||
delim = ",";
|
delim = ",";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -2282,16 +2285,12 @@ bool QgsPostgresProvider::addFeatures( QgsFeatureList &flist )
|
|||||||
delim = "";
|
delim = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
int offset;
|
|
||||||
if ( primaryKeyType != "tid" && primaryKeyType != "oid" )
|
if ( primaryKeyType != "tid" && primaryKeyType != "oid" )
|
||||||
{
|
{
|
||||||
insert += delim + quotedIdentifier( primaryKey );
|
insert += delim + quotedIdentifier( primaryKey );
|
||||||
values += delim + "$2";
|
values += delim + QString( "$%1" ).arg( offset );
|
||||||
offset = 3;
|
offset += 1;
|
||||||
}
|
delim = ",";
|
||||||
else
|
|
||||||
{
|
|
||||||
offset = 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const QgsAttributeMap &attributevec = flist[0].attributeMap();
|
const QgsAttributeMap &attributevec = flist[0].attributeMap();
|
||||||
@ -2393,11 +2392,14 @@ bool QgsPostgresProvider::addFeatures( QgsFeatureList &flist )
|
|||||||
{
|
{
|
||||||
const QgsAttributeMap &attributevec = features->attributeMap();
|
const QgsAttributeMap &attributevec = features->attributeMap();
|
||||||
|
|
||||||
|
QStringList params;
|
||||||
|
if ( !geometryColumn.isNull() )
|
||||||
|
{
|
||||||
QString geomParam;
|
QString geomParam;
|
||||||
appendGeomString( features->geometry(), geomParam );
|
appendGeomString( features->geometry(), geomParam );
|
||||||
|
|
||||||
QStringList params;
|
|
||||||
params << geomParam;
|
params << geomParam;
|
||||||
|
}
|
||||||
|
|
||||||
if ( primaryKeyType != "tid" && primaryKeyType != "oid" )
|
if ( primaryKeyType != "tid" && primaryKeyType != "oid" )
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user