@@ -249,6 +249,7 @@ void QgsPgTableModel::setSql( const QModelIndex &index, const QString &sql )
249
249
QModelIndex schemaSibling = index.sibling ( index.row (), DbtmSchema );
250
250
QModelIndex tableSibling = index.sibling ( index.row (), DbtmTable );
251
251
QModelIndex geomSibling = index.sibling ( index.row (), DbtmGeomCol );
252
+ QModelIndex geomTypeSibling = index.sibling ( index.row (), DbtmType );
252
253
253
254
if ( !schemaSibling.isValid () || !tableSibling.isValid () || !geomSibling.isValid () )
254
255
{
@@ -258,6 +259,7 @@ void QgsPgTableModel::setSql( const QModelIndex &index, const QString &sql )
258
259
QString schemaName = itemFromIndex ( schemaSibling )->text ();
259
260
QString tableName = itemFromIndex ( tableSibling )->text ();
260
261
QString geomName = itemFromIndex ( geomSibling )->text ();
262
+ QString geomType = itemFromIndex ( geomTypeSibling )->text ();
261
263
262
264
QList<QStandardItem *> schemaItems = findItems ( schemaName, Qt::MatchExactly, DbtmSchema );
263
265
if ( schemaItems.empty () )
@@ -288,7 +290,15 @@ void QgsPgTableModel::setSql( const QModelIndex &index, const QString &sql )
288
290
continue ;
289
291
}
290
292
291
- if ( itemFromIndex ( currentTableIndex )->text () == tableName && itemFromIndex ( currentGeomIndex )->text () == geomName )
293
+ QModelIndex currentGeomType = currentChildIndex.sibling ( i, DbtmType );
294
+ if ( !currentGeomType.isValid () )
295
+ {
296
+ continue ;
297
+ }
298
+
299
+ if ( itemFromIndex ( currentTableIndex )->text () == tableName
300
+ && itemFromIndex ( currentGeomIndex )->text () == geomName
301
+ && itemFromIndex ( currentGeomType )->text () == geomType )
292
302
{
293
303
QModelIndex sqlIndex = currentChildIndex.sibling ( i, DbtmSql );
294
304
if ( sqlIndex.isValid () )
0 commit comments