Skip to content

Commit

Permalink
When requesting a specific type/srid don't try to detect its validity
Browse files Browse the repository at this point in the history
Avoids double-checking from browser and data selector

See #32276
  • Loading branch information
strk committed Oct 17, 2019
1 parent cc8c2b6 commit e6a8a2f
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/providers/postgres/qgspostgresprovider.cpp
Expand Up @@ -3529,7 +3529,7 @@ bool QgsPostgresProvider::getGeometryDetails()
}
}

QString detectedType;
QString detectedType = mRequestedGeomType == QgsWkbTypes::Unknown ? QString() : QgsPostgresConn::postgisWkbTypeName( mRequestedGeomType );
QString detectedSrid = mRequestedSrid;
if ( !schemaName.isEmpty() )
{
Expand All @@ -3545,14 +3545,17 @@ bool QgsPostgresProvider::getGeometryDetails()

if ( result.PQntuples() == 1 )
{
detectedType = result.PQgetvalue( 0, 0 );
QString dt = result.PQgetvalue( 0, 0 );
if ( dt != "GEOMETRY" ) detectedType = dt;

QString dim = result.PQgetvalue( 0, 2 );
if ( dim == QLatin1String( "3" ) && !detectedType.endsWith( 'M' ) )
detectedType += QLatin1String( "Z" );
else if ( dim == QLatin1String( "4" ) )
detectedType += QLatin1String( "ZM" );

detectedSrid = result.PQgetvalue( 0, 1 );
QString ds = result.PQgetvalue( 0, 1 );
if ( ds != "0" ) detectedSrid = ds;
mSpatialColType = SctGeometry;
}
else
Expand All @@ -3574,8 +3577,10 @@ bool QgsPostgresProvider::getGeometryDetails()

if ( result.PQntuples() == 1 )
{
detectedType = result.PQgetvalue( 0, 0 );
detectedSrid = result.PQgetvalue( 0, 1 );
QString dt = result.PQgetvalue( 0, 0 );
if ( dt != "GEOMETRY" ) detectedType = dt;
QString ds = result.PQgetvalue( 0, 1 );
if ( ds != "0" ) detectedSrid = ds;
mSpatialColType = SctGeography;
}
else
Expand Down

0 comments on commit e6a8a2f

Please sign in to comment.