Skip to content

Commit b7507fa

Browse files
committedApr 17, 2018
[oracle] Fix clazy warnings in iterator
(cherry-picked from 99a2025)
1 parent 651cbe7 commit b7507fa

File tree

3 files changed

+37
-38
lines changed

3 files changed

+37
-38
lines changed
 

‎src/core/qgssqlexpressioncompiler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ QString QgsSqlExpressionCompiler::quotedValue( const QVariant &value, bool &ok )
6161
return value.toString();
6262

6363
case QVariant::Bool:
64-
return value.toBool() ? "TRUE" : "FALSE";
64+
return value.toBool() ? QStringLiteral( "TRUE" ) : QStringLiteral( "FALSE" );
6565

6666
default:
6767
case QVariant::String:
@@ -344,7 +344,7 @@ QgsSqlExpressionCompiler::Result QgsSqlExpressionCompiler::compileNode( const Qg
344344
if ( rn != Complete && rn != Partial )
345345
return rn;
346346

347-
result = QStringLiteral( "%1 %2IN (%3)" ).arg( nd, n->isNotIn() ? "NOT " : "", list.join( QStringLiteral( "," ) ) );
347+
result = QStringLiteral( "%1 %2IN (%3)" ).arg( nd, n->isNotIn() ? QStringLiteral( "NOT " ) : QString(), list.join( ',' ) );
348348
return ( inResult == Partial || rn == Partial ) ? Partial : Complete;
349349
}
350350

‎src/providers/oracle/qgsoraclefeatureiterator.cpp

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ QgsOracleFeatureIterator::QgsOracleFeatureIterator( QgsOracleFeatureSource *sour
101101
")" );
102102

103103
whereClause = QStringLiteral( "sdo_filter(%1,%2)='TRUE'" )
104-
.arg( QgsOracleProvider::quotedIdentifier( mSource->mGeometryColumn ) ).arg( bbox );
104+
.arg( QgsOracleProvider::quotedIdentifier( mSource->mGeometryColumn ), bbox );
105105

106106
args << ( mSource->mSrid < 1 ? QVariant( QVariant::Int ) : mSource->mSrid ) << mFilterRect.xMinimum() << mFilterRect.yMinimum() << mFilterRect.xMaximum() << mFilterRect.yMaximum();
107107

@@ -110,9 +110,9 @@ QgsOracleFeatureIterator::QgsOracleFeatureIterator( QgsOracleFeatureSource *sour
110110
// sdo_relate requires Spatial
111111
if ( mConnection->hasSpatial() )
112112
{
113-
whereClause += QString( " AND sdo_relate(%1,%2,'mask=ANYINTERACT')='TRUE'" )
114-
.arg( QgsOracleProvider::quotedIdentifier( mSource->mGeometryColumn ) )
115-
.arg( bbox );
113+
whereClause += QStringLiteral( " AND sdo_relate(%1,%2,'mask=ANYINTERACT')='TRUE'" )
114+
.arg( QgsOracleProvider::quotedIdentifier( mSource->mGeometryColumn ),
115+
bbox );
116116
args << ( mSource->mSrid < 1 ? QVariant( QVariant::Int ) : mSource->mSrid ) << mFilterRect.xMinimum() << mFilterRect.yMinimum() << mFilterRect.xMaximum() << mFilterRect.yMaximum();
117117
}
118118
else
@@ -131,7 +131,7 @@ QgsOracleFeatureIterator::QgsOracleFeatureIterator( QgsOracleFeatureSource *sour
131131
}
132132
else if ( !mFilterRect.isNull() )
133133
{
134-
QgsDebugMsg( "filterRect without geometry ignored" );
134+
QgsDebugMsg( QStringLiteral( "filterRect without geometry ignored" ) );
135135
}
136136

137137
switch ( mRequest.filterType() )
@@ -162,16 +162,16 @@ QgsOracleFeatureIterator::QgsOracleFeatureIterator( QgsOracleFeatureSource *sour
162162
if ( mSource->mRequestedGeomType != QgsWkbTypes::Unknown && mSource->mRequestedGeomType != mSource->mDetectedGeomType )
163163
{
164164
if ( !whereClause.isEmpty() )
165-
whereClause += " AND ";
165+
whereClause += QStringLiteral( " AND " );
166166

167-
whereClause += QgsOracleConn::databaseTypeFilter( "FEATUREREQUEST", mSource->mGeometryColumn, mSource->mRequestedGeomType );
167+
whereClause += QgsOracleConn::databaseTypeFilter( QStringLiteral( "FEATUREREQUEST" ), mSource->mGeometryColumn, mSource->mRequestedGeomType );
168168
}
169169

170170
if ( !mSource->mSqlWhereClause.isEmpty() )
171171
{
172172
if ( !whereClause.isEmpty() )
173-
whereClause += " AND ";
174-
whereClause += "(" + mSource->mSqlWhereClause + ")";
173+
whereClause += QStringLiteral( " AND " );
174+
whereClause += '(' + mSource->mSqlWhereClause + ')';
175175
}
176176

177177
//NOTE - must be last added!
@@ -181,7 +181,7 @@ QgsOracleFeatureIterator::QgsOracleFeatureIterator( QgsOracleFeatureSource *sour
181181
bool useFallback = false;
182182
if ( request.filterType() == QgsFeatureRequest::FilterExpression )
183183
{
184-
if ( QgsSettings().value( "qgis/compileExpressions", true ).toBool() )
184+
if ( QgsSettings().value( QStringLiteral( "qgis/compileExpressions" ), true ).toBool() )
185185
{
186186
QgsOracleExpressionCompiler compiler( mSource );
187187
QgsSqlExpressionCompiler::Result result = compiler.compile( mRequest.filterExpression() );
@@ -215,7 +215,7 @@ QgsOracleFeatureIterator::QgsOracleFeatureIterator( QgsOracleFeatureSource *sour
215215
if ( mRequest.limit() >= 0 && limitAtProvider )
216216
{
217217
if ( !whereClause.isEmpty() )
218-
whereClause += " AND ";
218+
whereClause += QStringLiteral( " AND " );
219219

220220
whereClause += QStringLiteral( "rownum<=?" );
221221
fallbackStatement += QStringLiteral( "rownum<=?" );
@@ -265,8 +265,8 @@ bool QgsOracleFeatureIterator::fetchFeature( QgsFeature &feature )
265265
if ( !QgsOracleProvider::exec( mQry, mSql, mArgs ) )
266266
{
267267
QgsMessageLog::logMessage( QObject::tr( "Fetching features failed.\nSQL: %1\nError: %2" )
268-
.arg( mQry.lastQuery() )
269-
.arg( mQry.lastError().text() ),
268+
.arg( mQry.lastQuery(),
269+
mQry.lastError().text() ),
270270
QObject::tr( "Oracle" ) );
271271
return false;
272272
}
@@ -296,7 +296,7 @@ bool QgsOracleFeatureIterator::fetchFeature( QgsFeature &feature )
296296
{
297297
if ( !feature.hasGeometry() )
298298
{
299-
QgsDebugMsg( "no geometry to intersect" );
299+
QgsDebugMsg( QStringLiteral( "no geometry to intersect" ) );
300300
continue;
301301
}
302302

@@ -309,7 +309,7 @@ bool QgsOracleFeatureIterator::fetchFeature( QgsFeature &feature )
309309
if ( !feature.geometry().boundingBox().intersects( mFilterRect ) )
310310
{
311311
// skip feature that don't intersect with our rectangle
312-
QgsDebugMsg( "no bbox intersect" );
312+
QgsDebugMsg( QStringLiteral( "no bbox intersect" ) );
313313
continue;
314314
}
315315
}
@@ -320,7 +320,7 @@ bool QgsOracleFeatureIterator::fetchFeature( QgsFeature &feature )
320320
if ( !feature.geometry().intersects( mFilterRect ) )
321321
{
322322
// skip feature that don't intersect with our rectangle
323-
QgsDebugMsg( "no exact intersect" );
323+
QgsDebugMsg( QStringLiteral( "no exact intersect" ) );
324324
continue;
325325
}
326326
}
@@ -334,15 +334,14 @@ bool QgsOracleFeatureIterator::fetchFeature( QgsFeature &feature )
334334
case PktInt:
335335
// get 64bit integer from result
336336
fid = mQry.value( col++ ).toLongLong();
337-
if ( mAttributeList.contains( mSource->mPrimaryKeyAttrs[0] ) )
338-
feature.setAttribute( mSource->mPrimaryKeyAttrs[0], fid );
337+
if ( mAttributeList.contains( mSource->mPrimaryKeyAttrs.value( 0 ) ) )
338+
feature.setAttribute( mSource->mPrimaryKeyAttrs.value( 0 ), fid );
339339
break;
340340

341341
case PktRowId:
342342
case PktFidMap:
343343
{
344344
QVariantList primaryKeyVals;
345-
346345
if ( mSource->mPrimaryKeyType == PktFidMap )
347346
{
348347
Q_FOREACH ( int idx, mSource->mPrimaryKeyAttrs )
@@ -375,7 +374,7 @@ bool QgsOracleFeatureIterator::fetchFeature( QgsFeature &feature )
375374
}
376375

377376
feature.setId( fid );
378-
QgsDebugMsgLevel( QString( "fid=%1" ).arg( fid ), 5 );
377+
QgsDebugMsgLevel( QStringLiteral( "fid=%1" ).arg( fid ), 5 );
379378

380379
// iterate attributes
381380
Q_FOREACH ( int idx, mAttributeList )
@@ -386,7 +385,7 @@ bool QgsOracleFeatureIterator::fetchFeature( QgsFeature &feature )
386385
QgsField fld = mSource->mFields.at( idx );
387386

388387
QVariant v = mQry.value( col );
389-
if ( fld.type() == QVariant::ByteArray && fld.typeName().endsWith( ".SDO_GEOMETRY" ) )
388+
if ( fld.type() == QVariant::ByteArray && fld.typeName().endsWith( QStringLiteral( ".SDO_GEOMETRY" ) ) )
390389
{
391390
QByteArray ba( v.toByteArray() );
392391
if ( ba.size() > 0 )
@@ -440,42 +439,42 @@ bool QgsOracleFeatureIterator::close()
440439
return true;
441440
}
442441

443-
bool QgsOracleFeatureIterator::openQuery( QString whereClause, QVariantList args, bool showLog )
442+
bool QgsOracleFeatureIterator::openQuery( const QString &whereClause, const QVariantList &args, bool showLog )
444443
{
445444
try
446445
{
447-
QString query = "SELECT ", delim = "";
446+
QString query = QStringLiteral( "SELECT " );
447+
QString delim;
448448

449449
if ( mFetchGeometry )
450450
{
451451
query += QgsOracleProvider::quotedIdentifier( mSource->mGeometryColumn );
452-
delim = ",";
452+
delim = ',';
453453
}
454454

455455
switch ( mSource->mPrimaryKeyType )
456456
{
457457
case PktRowId:
458-
query += delim + QgsOracleProvider::quotedIdentifier( "ROWID" );
459-
delim = ",";
458+
query += delim + QgsOracleProvider::quotedIdentifier( QStringLiteral( "ROWID" ) );
459+
delim = ',';
460460
break;
461461

462462
case PktInt:
463463
query += delim + QgsOracleProvider::quotedIdentifier( mSource->mFields.at( mSource->mPrimaryKeyAttrs[0] ).name() );
464-
delim = ",";
464+
delim = ',';
465465
break;
466466

467467
case PktFidMap:
468468
Q_FOREACH ( int idx, mSource->mPrimaryKeyAttrs )
469469
{
470470
query += delim + mConnection->fieldExpression( mSource->mFields.at( idx ) );
471-
delim = ",";
471+
delim = ',';
472472
}
473473
break;
474474

475475
case PktUnknown:
476-
QgsDebugMsg( "Cannot query without primary key." );
476+
QgsDebugMsg( QStringLiteral( "Cannot query without primary key." ) );
477477
return false;
478-
break;
479478
}
480479

481480
Q_FOREACH ( int idx, mAttributeList )
@@ -486,21 +485,21 @@ bool QgsOracleFeatureIterator::openQuery( QString whereClause, QVariantList args
486485
query += delim + mConnection->fieldExpression( mSource->mFields.at( idx ) );
487486
}
488487

489-
query += QString( " FROM %1 \"FEATUREREQUEST\"" ).arg( mSource->mQuery );
488+
query += QStringLiteral( " FROM %1 \"FEATUREREQUEST\"" ).arg( mSource->mQuery );
490489

491490
if ( !whereClause.isEmpty() )
492-
query += QString( " WHERE %1" ).arg( whereClause );
491+
query += QStringLiteral( " WHERE %1" ).arg( whereClause );
493492

494-
QgsDebugMsg( QString( "Fetch features: %1" ).arg( query ) );
493+
QgsDebugMsg( QStringLiteral( "Fetch features: %1" ).arg( query ) );
495494
mSql = query;
496495
mArgs = args;
497496
if ( !QgsOracleProvider::exec( mQry, query, args ) )
498497
{
499498
if ( showLog )
500499
{
501500
QgsMessageLog::logMessage( QObject::tr( "Fetching features failed.\nSQL: %1\nError: %2" )
502-
.arg( mQry.lastQuery() )
503-
.arg( mQry.lastError().text() ),
501+
.arg( mQry.lastQuery(),
502+
mQry.lastError().text() ),
504503
QObject::tr( "Oracle" ) );
505504
}
506505
return false;

‎src/providers/oracle/qgsoraclefeatureiterator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class QgsOracleFeatureIterator : public QgsAbstractFeatureIteratorFromSource<Qgs
7171
virtual bool fetchFeature( QgsFeature &feature ) override;
7272
bool nextFeatureFilterExpression( QgsFeature &f ) override;
7373

74-
bool openQuery( QString whereClause, QVariantList args, bool showLog = true );
74+
bool openQuery( const QString &whereClause, const QVariantList &args, bool showLog = true );
7575

7676
QgsOracleConn *mConnection = nullptr;
7777
QSqlQuery mQry;

0 commit comments

Comments
 (0)
Please sign in to comment.