Skip to content
Permalink
Browse files

oracle provider: allow switching workspaces through property

  • Loading branch information
jef-n committed Nov 16, 2016
1 parent 1eb8fe5 commit 4e8357fb871fd618f69db8b49999beb70e07b0b1
Showing with 41 additions and 1 deletion.
  1. +30 −1 src/providers/oracle/qgsoracleprovider.cpp
  2. +11 −0 src/providers/oracle/qgsoracleprovider.h
@@ -209,6 +209,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 );
@@ -2325,7 +2354,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() )
@@ -54,6 +54,7 @@ enum QgsOraclePrimaryKeyType
class QgsOracleProvider : public QgsVectorDataProvider
{
Q_OBJECT
Q_PROPERTY( QString workspace READ getWorkspace WRITE setWorkspace )

public:

@@ -281,6 +282,16 @@ class QgsOracleProvider : public QgsVectorDataProvider
*/
virtual bool isSaveAndLoadStyleToDBSupported() 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 4e8357f

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