Skip to content
Permalink
Browse files
fix #6800 (introduced with 0dc01f5)
  • Loading branch information
jef-n committed Dec 3, 2012
1 parent c85b952 commit 1dc75f35614cd0c39bc801ee39073db0ea45823f
@@ -2,7 +2,7 @@

"""
***************************************************************************
layergroup.py
resource.py
---------------------
Date : November 2012
Copyright : (C) 2012 by David Winslow
@@ -2,7 +2,7 @@

"""
***************************************************************************
layergroup.py
store.py
---------------------
Date : November 2012
Copyright : (C) 2012 by David Winslow
@@ -2,7 +2,7 @@

"""
***************************************************************************
layergroup.py
style.py
---------------------
Date : November 2012
Copyright : (C) 2012 by David Winslow
@@ -2,7 +2,7 @@

"""
***************************************************************************
layergroup.py
support.py
---------------------
Date : November 2012
Copyright : (C) 2012 by David Winslow
@@ -2,7 +2,7 @@

"""
***************************************************************************
layergroup.py
util.py
---------------------
Date : November 2012
Copyright : (C) 2012 by David Winslow
@@ -2,7 +2,7 @@

"""
***************************************************************************
layergroup.py
workspace.py
---------------------
Date : November 2012
Copyright : (C) 2012 by David Winslow
@@ -1233,7 +1233,8 @@ bool QgsPostgresProvider::hasSufficientPermsAndCapabilities()
"has_table_privilege(%1,'DELETE'),"
"has_any_column_privilege(%1,'UPDATE'),"
"%2"
"has_table_privilege(%1,'INSERT')" )
"has_table_privilege(%1,'INSERT'),"
"current_schema()" )
.arg( quotedValue( mQuery ) )
.arg( mGeometryColumn.isNull()
? QString( "'f'," )
@@ -1248,7 +1249,8 @@ bool QgsPostgresProvider::hasSufficientPermsAndCapabilities()
"has_table_privilege(%1,'DELETE'),"
"has_table_privilege(%1,'UPDATE'),"
"has_table_privilege(%1,'UPDATE'),"
"has_table_privilege(%1,'INSERT')" )
"has_table_privilege(%1,'INSERT'),"
"current_schema()" )
.arg( quotedValue( mQuery ) );
}

@@ -1288,6 +1290,9 @@ bool QgsPostgresProvider::hasSufficientPermsAndCapabilities()
mEnabledCapabilities |= QgsVectorDataProvider::AddFeatures;
}

if ( mSchemaName.isEmpty() )
mSchemaName = testAccess.PQgetvalue( 0, 4 );

sql = QString( "SELECT 1 FROM pg_class,pg_namespace WHERE "
"pg_class.relnamespace=pg_namespace.oid AND "
"pg_get_userbyid(relowner)=current_user AND "
@@ -1814,33 +1819,33 @@ QString QgsPostgresProvider::paramValue( QString fieldValue, const QString &defa

QString QgsPostgresProvider::geomParam( int offset ) const
{
// TODO: retrive these at construction time
// TODO: retrieve these at construction time
QString toponame;
long layer_id;

if ( mSpatialColType == sctTopoGeometry )
{
QString sql = QString( "SELECT t.name, l.layer_id FROM topology.layer l, topology.topology t "
"WHERE l.topology_id = t.id AND l.schema_name=%1 "
"AND l.table_name=%2 AND l.feature_column=%3" )
.arg( quotedValue( mSchemaName ) )
.arg( quotedValue( mTableName ) )
.arg( quotedValue( mGeometryColumn ) );
"WHERE l.topology_id = t.id AND l.schema_name=%1 "
"AND l.table_name=%2 AND l.feature_column=%3" )
.arg( quotedValue( mSchemaName ) )
.arg( quotedValue( mTableName ) )
.arg( quotedValue( mGeometryColumn ) );
QgsPostgresResult result = mConnectionRO->PQexec( sql );
if ( result.PQresultStatus() != PGRES_TUPLES_OK )
{
throw PGException( result ); // we should probably not do this
}
if ( result.PQntuples() < 1 )
{
QgsMessageLog::logMessage( tr( "Could not find topology of layer %1.%2.%3" )
.arg( quotedValue( mSchemaName ) )
.arg( quotedValue( mTableName ) )
.arg( quotedValue( mGeometryColumn ) ),
tr( "PostGIS" ) );
QgsMessageLog::logMessage( tr( "Could not find topology of layer %1.%2.%3" )
.arg( quotedValue( mSchemaName ) )
.arg( quotedValue( mTableName ) )
.arg( quotedValue( mGeometryColumn ) ),
tr( "PostGIS" ) );
}
toponame = result.PQgetvalue( 0, 0 );
layer_id = result.PQgetvalue( 0, 1 ).toLong();
toponame = result.PQgetvalue( 0, 0 );
layer_id = result.PQgetvalue( 0, 1 ).toLong();

}

@@ -1898,7 +1903,7 @@ QString QgsPostgresProvider::geomParam( int offset ) const
if ( mSpatialColType == sctTopoGeometry )
{
geometry += QString( ",%1,%2)" )
.arg( quotedValue(toponame) )
.arg( quotedValue( toponame ) )
.arg( layer_id );
}

0 comments on commit 1dc75f3

Please sign in to comment.