mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
postgres provider: don't try to detect geometry type or srid, if it's already known (fixes #9421)
This commit is contained in:
parent
72988e9aa4
commit
eaf5725f56
@ -1132,21 +1132,41 @@ void QgsPostgresConn::retrieveLayerTypes( QgsPostgresLayerProperty &layerPropert
|
||||
table += QString( " WHERE %1" ).arg( layerProperty.sql );
|
||||
}
|
||||
|
||||
QString query = QString( "SELECT DISTINCT"
|
||||
" CASE"
|
||||
QString query = "SELECT DISTINCT ";
|
||||
|
||||
QGis::WkbType type = layerProperty.types.value( 0, QGis::WKBUnknown );
|
||||
if ( type == QGis::WKBUnknown )
|
||||
{
|
||||
query += QString( "CASE"
|
||||
" WHEN %1 THEN 'POINT'"
|
||||
" WHEN %2 THEN 'LINESTRING'"
|
||||
" WHEN %3 THEN 'POLYGON'"
|
||||
" END,"
|
||||
" %4(%5%6)"
|
||||
" FROM %7" )
|
||||
" END" )
|
||||
.arg( postgisTypeFilter( layerProperty.geometryColName, QGis::WKBPoint, layerProperty.geometryColType == sctGeography ) )
|
||||
.arg( postgisTypeFilter( layerProperty.geometryColName, QGis::WKBLineString, layerProperty.geometryColType == sctGeography ) )
|
||||
.arg( postgisTypeFilter( layerProperty.geometryColName, QGis::WKBPolygon, layerProperty.geometryColType == sctGeography ) )
|
||||
.arg( postgisTypeFilter( layerProperty.geometryColName, QGis::WKBPolygon, layerProperty.geometryColType == sctGeography ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
query += quotedValue( QgsPostgresConn::postgisWkbTypeName( type ) );
|
||||
}
|
||||
|
||||
query += ",";
|
||||
|
||||
int srid = layerProperty.srids.value( 0, INT_MIN );
|
||||
if ( srid == INT_MIN )
|
||||
{
|
||||
query += QString( "%1(%2%3)" )
|
||||
.arg( majorVersion() < 2 ? "srid" : "st_srid" )
|
||||
.arg( quotedIdentifier( layerProperty.geometryColName ) )
|
||||
.arg( layerProperty.geometryColType == sctGeography ? "::geometry" : "" )
|
||||
.arg( table );
|
||||
.arg( layerProperty.geometryColType == sctGeography ? "::geometry" : "" );
|
||||
}
|
||||
else
|
||||
{
|
||||
query += QString::number( srid );
|
||||
}
|
||||
|
||||
query += " FROM " + table;
|
||||
|
||||
QgsDebugMsg( "Retrieving geometry types: " + query );
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user