mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
oracle provider: allow switching workspaces through property
(cherry picked from commit 2dc448dfb8c568c20e69fc9e3955e5df63d9a880)
This commit is contained in:
parent
33ee514b5d
commit
6638569074
@ -207,6 +207,35 @@ QgsOracleProvider::~QgsOracleProvider()
|
||||
disconnectDb();
|
||||
}
|
||||
|
||||
QString QgsOracleProvider::getWorkspace() const
|
||||
{
|
||||
return mUri.param( "dbworkspace" );
|
||||
}
|
||||
|
||||
void QgsOracleProvider::setWorkspace( const QString &workspace )
|
||||
{
|
||||
QgsDataSourceUri prevUri( mUri );
|
||||
|
||||
disconnectDb();
|
||||
|
||||
if ( workspace.isEmpty() )
|
||||
mUri.removeParam( "dbworkspace" );
|
||||
else
|
||||
mUri.setParam( "dbworkspace", workspace );
|
||||
|
||||
mConnection = QgsOracleConn::connectDb( mUri );
|
||||
if ( !mConnection )
|
||||
{
|
||||
mUri = prevUri;
|
||||
QgsDebugMsg( QString( "restoring previous uri:%1" ).arg( mUri.uri() ) );
|
||||
mConnection = QgsOracleConn::connectDb( mUri );
|
||||
}
|
||||
else
|
||||
{
|
||||
setDataSourceUri( mUri.uri() );
|
||||
}
|
||||
}
|
||||
|
||||
QgsAbstractFeatureSource *QgsOracleProvider::featureSource() const
|
||||
{
|
||||
return new QgsOracleFeatureSource( this );
|
||||
@ -2381,7 +2410,7 @@ bool QgsOracleProvider::getGeometryDetails()
|
||||
}
|
||||
|
||||
if ( exec( qry, QString( mUseEstimatedMetadata
|
||||
? "SELECT DISTINCT gtype FROM (SELECT t.%1.sdo_gtype AS gtype FROM %2 t WHERE t.%1 IS NOT NULL AND rownum<1000) WHERE rownum<=2"
|
||||
? "SELECT DISTINCT gtype FROM (SELECT t.%1.sdo_gtype AS gtype FROM %2 t WHERE t.%1 IS NOT NULL AND rownum<100) WHERE rownum<=2"
|
||||
: "SELECT DISTINCT t.%1.sdo_gtype FROM %2 t WHERE t.%1 IS NOT NULL AND rownum<=2" ).arg( quotedIdentifier( geomCol ) ).arg( mQuery ) ) )
|
||||
{
|
||||
if ( qry.next() )
|
||||
|
@ -56,6 +56,7 @@ enum QgsOraclePrimaryKeyType
|
||||
class QgsOracleProvider : public QgsVectorDataProvider
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY( QString workspace READ getWorkspace WRITE setWorkspace )
|
||||
|
||||
public:
|
||||
|
||||
@ -283,6 +284,16 @@ class QgsOracleProvider : public QgsVectorDataProvider
|
||||
*/
|
||||
virtual bool isSaveAndLoadStyleToDBSupported() const override { return true; }
|
||||
|
||||
/**
|
||||
* Switch to oracle workspace
|
||||
*/
|
||||
void setWorkspace( const QString &workspace );
|
||||
|
||||
/**
|
||||
* Retrieve oracle workspace name
|
||||
*/
|
||||
QString getWorkspace() const;
|
||||
|
||||
private:
|
||||
QString whereClause( QgsFeatureId featureId ) const;
|
||||
QString pkParamWhereClause() const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user