Skip to content

Commit d2fdfe8

Browse files
authoredOct 2, 2018
add null and is null macros for QgsFeatureId (#8085)
* add null and is null macros for QgsFeatureId * Finalize FID_NULL * No string to fid null conversion for now * add parenthesis to fix macro call
1 parent b3f36dc commit d2fdfe8

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed
 

‎src/core/qgsfeatureid.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@ email : matthias@opengis.ch
2323

2424
// 64 bit feature ids
2525
typedef qint64 QgsFeatureId SIP_SKIP;
26-
#define FID_IS_NEW(fid) (fid<0)
27-
#define FID_TO_NUMBER(fid) static_cast<qint64>(fid)
28-
#define FID_TO_STRING(fid) QString::number( fid )
29-
#define STRING_TO_FID(str) (str).toLongLong()
26+
#define FID_NULL std::numeric_limits<QgsFeatureId>::min()
27+
#define FID_IS_NULL(fid) ( fid == std::numeric_limits<QgsFeatureId>::min() )
28+
#define FID_IS_NEW(fid) ( fid < 0 && fid != std::numeric_limits<QgsFeatureId>::min() )
29+
#define FID_TO_NUMBER(fid) static_cast<qint64>( fid )
30+
#define FID_TO_STRING(fid) ( fid != std::numeric_limits<QgsFeatureId>::min() ? QString::number( fid ) : QStringLiteral( "NULL" ) )
31+
#define STRING_TO_FID(str) ( (str).toLongLong() )
3032

3133
#ifndef SIP_RUN
3234
typedef QSet<QgsFeatureId> QgsFeatureIds;

‎src/providers/postgres/qgspostgresprovider.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ QString QgsPostgresUtils::whereClause( const QgsFeatureIds &featureIds, const Qg
590590

591591
Q_FOREACH ( const QgsFeatureId featureId, featureIds )
592592
{
593-
expr += delim + FID_TO_STRING( pkType == PktOid ? featureId : pkType == PktUint64 ? featureId : FID2PKINT( featureId ) );
593+
expr += delim + FID_TO_STRING( ( pkType == PktOid ? featureId : pkType == PktUint64 ? featureId : FID2PKINT( featureId ) ) );
594594
delim = ',';
595595
}
596596
expr += ')';

0 commit comments

Comments
 (0)
Please sign in to comment.