Skip to content
Permalink
Browse files

oracle provider: allow switching workspaces through property

(cherry picked from commit 2dc448dfb8c568c20e69fc9e3955e5df63d9a880)
  • Loading branch information
jef-n committed Nov 16, 2016
1 parent 33ee514 commit 66385690743d20fcea7b8b898e0fc3dae6eed010
Showing with 41 additions and 1 deletion.
  1. +30 −1 src/providers/oracle/qgsoracleprovider.cpp
  2. +11 −0 src/providers/oracle/qgsoracleprovider.h
@@ -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;

0 comments on commit 6638569

Please sign in to comment.
You can’t perform that action at this time.