Skip to content

Commit 83e6858

Browse files
committedSep 5, 2017
Replace use of deprecated QSqlError::number
1 parent b196d37 commit 83e6858

File tree

5 files changed

+21
-21
lines changed

5 files changed

+21
-21
lines changed
 

‎src/providers/db2/qgsdb2dataitems.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,16 +185,16 @@ QVector<QgsDataItem *> QgsDb2ConnectionItem::createChildren()
185185
}
186186

187187
QgsDb2GeometryColumns db2GC = QgsDb2GeometryColumns( db );
188-
int sqlcode = db2GC.open();
188+
QString sqlcode = db2GC.open();
189189

190190
/* Enabling the DB2 Spatial Extender creates the DB2GSE schema and tables,
191191
so the Extender is either not enabled or set up if SQLCODE -204 is returned. */
192-
if ( sqlcode == -204 )
192+
if ( sqlcode == QStringLiteral( "-204" ) )
193193
{
194194
children.append( new QgsErrorItem( this, tr( "DB2 Spatial Extender is not enabled or set up." ), mPath + "/error" ) );
195195
return children;
196196
}
197-
else if ( sqlcode != 0 )
197+
else if ( !sqlcode.isEmpty() && sqlcode != QStringLiteral( "0" ) )
198198
{
199199
children.append( new QgsErrorItem( this, db.lastError().text(), mPath + "/error" ) );
200200
return children;

‎src/providers/db2/qgsdb2geometrycolumns.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ QgsDb2GeometryColumns::~QgsDb2GeometryColumns()
3232
mQuery.clear();
3333
}
3434

35-
int QgsDb2GeometryColumns::open()
35+
QString QgsDb2GeometryColumns::open()
3636
{
3737
return open( QString(), QString() );
3838
}
3939

40-
int QgsDb2GeometryColumns::open( const QString &schemaName, const QString &tableName )
40+
QString QgsDb2GeometryColumns::open( const QString &schemaName, const QString &tableName )
4141
{
4242
QString queryExtents( "SELECT TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME, TYPE_NAME, "
4343
"SRS_ID, SRS_NAME, MIN_X, MIN_Y, MAX_X, MAX_Y "
@@ -46,7 +46,7 @@ int QgsDb2GeometryColumns::open( const QString &schemaName, const QString &table
4646
"SRS_ID, SRS_NAME "
4747
"FROM DB2GSE.ST_GEOMETRY_COLUMNS" );
4848
mQuery = QSqlQuery( mDatabase );
49-
int sqlcode = 0;
49+
QString nativeError;
5050
mEnvironment = ENV_LUW;
5151

5252
if ( !schemaName.isEmpty() && !tableName.isEmpty() )
@@ -61,30 +61,30 @@ int QgsDb2GeometryColumns::open( const QString &schemaName, const QString &table
6161
if ( !mQuery.exec( queryExtents ) )
6262
{
6363
QgsDebugMsg( "ST_Geometry_Columns query failed: " + mDatabase.lastError().text() );
64-
sqlcode = mQuery.lastError().number();
65-
QgsDebugMsg( QString( "SQLCODE: %1" ).arg( sqlcode ) );
64+
nativeError = mQuery.lastError().nativeErrorCode();
65+
QgsDebugMsg( QString( "SQLCODE: %1" ).arg( nativeError ) );
6666
/* The MIN_X, MIN_Y, MAX_X, and MAX_Y columns are not available on z/OS (and LUW 9.5)
6767
so SQLCODE -206 is returned when specifying non-existent columns. */
68-
if ( mQuery.lastError().number() == -206 )
68+
if ( mQuery.lastError().nativeErrorCode() == QStringLiteral( "-206" ) )
6969
{
7070
QgsDebugMsg( "Try query with no extents" );
7171
mQuery.clear();
7272

7373
if ( !mQuery.exec( queryNoExtents ) )
7474
{
75-
QgsDebugMsg( QString( "SQLCODE: %1" ).arg( mQuery.lastError().number() ) );
75+
QgsDebugMsg( QString( "SQLCODE: %1" ).arg( mQuery.lastError().nativeErrorCode() ) );
7676
}
7777
else
7878
{
7979
QgsDebugMsg( "success; must be z/OS" );
8080
mEnvironment = ENV_ZOS;
81-
sqlcode = 0;
81+
nativeError.clear();
8282
}
8383
}
8484
}
8585
// QgsDebugMsg( QString( "sqlcode: %1" ).arg( sqlcode ) );
8686

87-
return sqlcode;
87+
return nativeError;
8888
}
8989

9090
bool QgsDb2GeometryColumns::isActive()

‎src/providers/db2/qgsdb2geometrycolumns.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ class QgsDb2GeometryColumns // clazy:exclude=rule-of-three
3737

3838
bool isActive();
3939
void close();
40-
int open();
41-
int open( const QString &schemaName, const QString &tableName );
40+
QString open();
41+
QString open( const QString &schemaName, const QString &tableName );
4242
bool populateLayerProperty( QgsDb2LayerProperty &layer );
4343
int db2Environment();
4444

‎src/providers/db2/qgsdb2provider.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -583,8 +583,8 @@ void QgsDb2Provider::updateStatistics() const
583583

584584
QgsDebugMsg( QString( "mSRId: %1" ).arg( mSRId ) );
585585
QgsDb2GeometryColumns gc( mDatabase );
586-
int rc = gc.open( mSchemaName, mTableName ); // returns SQLCODE if failure
587-
if ( rc == 0 )
586+
QString rc = gc.open( mSchemaName, mTableName ); // returns SQLCODE if failure
587+
if ( rc.isEmpty() || rc == QStringLiteral( "0" ) )
588588
{
589589
mEnvironment = gc.db2Environment();
590590
if ( -1 == mSRId )
@@ -1394,7 +1394,7 @@ QgsVectorLayerExporter::ExportError QgsDb2Provider::createEmptyLayer( const QStr
13941394
sql = "DROP TABLE " + fullName;
13951395
if ( !q.exec( sql ) )
13961396
{
1397-
if ( q.lastError().number() != -206 ) // -206 is "not found" just ignore
1397+
if ( q.lastError().nativeErrorCode() != QStringLiteral( "-206" ) ) // -206 is "not found" just ignore
13981398
{
13991399
QString lastError = q.lastError().text();
14001400
QgsDebugMsg( lastError );
@@ -1498,8 +1498,8 @@ QgsVectorLayerExporter::ExportError QgsDb2Provider::createEmptyLayer( const QStr
14981498

14991499
// get the environment
15001500
QgsDb2GeometryColumns gc( db );
1501-
int rc = gc.open( schemaName, tableName ); // returns SQLCODE if failure
1502-
if ( rc == 0 )
1501+
QString rc = gc.open( schemaName, tableName ); // returns SQLCODE if failure
1502+
if ( rc.isEmpty() || rc == QStringLiteral( "0" ) )
15031503
{
15041504
db2Environment = gc.db2Environment();
15051505
}

‎src/providers/db2/qgsdb2sourceselect.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -495,8 +495,8 @@ void QgsDb2SourceSelect::on_btnConnect_clicked()
495495
}
496496

497497
QgsDb2GeometryColumns db2GC = QgsDb2GeometryColumns( db );
498-
int sqlcode = db2GC.open();
499-
if ( 0 != sqlcode )
498+
QString sqlcode = db2GC.open();
499+
if ( !sqlcode.isEmpty() && QStringLiteral( "0" ) != sqlcode )
500500
{
501501
QMessageBox::warning( this, tr( "DB2GSE.ST_GEOMETRY_COLUMNS Not Found" ),
502502
tr( "DB2GSE.ST_GEOMETRY_COLUMNS not found. The DB2 Spatial Extender is not enabled or set up." ) );

0 commit comments

Comments
 (0)
Please sign in to comment.