File tree Expand file tree Collapse file tree 1 file changed +22
-5
lines changed Expand file tree Collapse file tree 1 file changed +22
-5
lines changed Original file line number Diff line number Diff line change @@ -2412,11 +2412,28 @@ bool QgsPostgresProvider::changeGeometryValues( QgsGeometryMap & geometry_map )
2412
2412
// Start the PostGIS transaction
2413
2413
mConnectionRW ->PQexecNR ( " BEGIN" );
2414
2414
2415
- QString update = QString ( " UPDATE %1 SET %2=%3 WHERE %4" )
2416
- .arg ( mQuery )
2417
- .arg ( quotedIdentifier ( mGeometryColumn ) )
2418
- .arg ( geomParam ( 1 ) )
2419
- .arg ( pkParamWhereClause ( 2 ) );
2415
+ QString update;
2416
+
2417
+ if ( mSpatialColType == sctTopoGeometry ) {
2418
+ // NOTE: We are creating a new TopoGeometry objects with the new shape.
2419
+ // TODO: _replace_ the initial TopoGeometry instead, so that it keeps
2420
+ // the same identifier and thus still partecipates in any
2421
+ // hierarchical definition. Also creating a new object results
2422
+ // in orphaned topogeometries!
2423
+ update = QString ( " UPDATE %1 SET %2=toTopoGeom(%3,t.name,layer_id(%2))"
2424
+ " FROM topology.topology t WHERE t.id = topology_id(%2)"
2425
+ " AND %4" )
2426
+ .arg ( mQuery )
2427
+ .arg ( quotedIdentifier ( mGeometryColumn ) )
2428
+ .arg ( geomParam ( 1 ) )
2429
+ .arg ( pkParamWhereClause ( 2 ) );
2430
+ } else {
2431
+ update = QString ( " UPDATE %1 SET %2=%3 WHERE %4" )
2432
+ .arg ( mQuery )
2433
+ .arg ( quotedIdentifier ( mGeometryColumn ) )
2434
+ .arg ( geomParam ( 1 ) )
2435
+ .arg ( pkParamWhereClause ( 2 ) );
2436
+ }
2420
2437
2421
2438
QgsDebugMsg ( " updating: " + update );
2422
2439
You can’t perform that action at this time.
0 commit comments