26 if ( pkAttributes.isEmpty() )
28 return QString::number( feature.
id() );
32 QgsAttributeList::const_iterator it = pkAttributes.constBegin();
33 if ( it != pkAttributes.constEnd() )
35 pkValues.append( feature.
attribute( *it ).toString() );
44 if ( pkAttributes.isEmpty() )
47 for (
const QString &serverFid : serverFids )
49 fids.insert( serverFid.toLongLong() );
52 return featureRequest;
56 for (
const QString &serverFid : serverFids )
61 if ( expList.count() == 1 )
67 QString fullExpression;
68 for (
const QString &exp : qgis::as_const( expList ) )
70 if ( !fullExpression.isEmpty() )
72 fullExpression.append( QStringLiteral(
" OR " ) );
74 fullExpression.append( QStringLiteral(
"( " ) );
75 fullExpression.append( exp );
76 fullExpression.append( QStringLiteral(
" )" ) );
81 return featureRequest;
88 if ( pkAttributes.isEmpty() )
95 QString expressionString;
96 QStringList pkValues = serverFid.split(
pkSeparator() );
97 int pkExprSize = std::min( pkAttributes.size(), pkValues.size() );
98 for (
int i = 0; i < pkExprSize; ++i )
102 expressionString.
append( QStringLiteral(
" AND " ) );
105 QString fieldName = fields[ pkAttributes.at( i ) ].name();
109 return expressionString;
114 return QStringLiteral(
"@@" );
QSet< QgsFeatureId > QgsFeatureIds
SERVER_EXPORT QString getServerFid(const QgsFeature &feature, const QgsAttributeList &pkAttributes)
Returns the feature id based on primary keys.
virtual QgsAttributeList pkAttributeIndexes() const
Returns list of indexes of fields that make up the primary key.
Container of fields for a vector layer.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
QgsFeatureRequest & setFilterExpression(const QString &expression)
Set the filter expression.
QgsFields fields() const override=0
Returns the fields associated with this data provider.
This class wraps a request for features to a vector layer (or directly its vector data provider)...
bool append(const QgsField &field, FieldOrigin origin=OriginProvider, int originIndex=-1)
Appends a field. The field must have unique name, otherwise it is rejected (returns false) ...
static QString createFieldEqualityExpression(const QString &fieldName, const QVariant &value)
Create an expression allowing to evaluate if a field is equal to a value.
SERVER_EXPORT QgsFeatureRequest updateFeatureRequestFromServerFids(QgsFeatureRequest &featureRequest, const QStringList &serverFids, const QgsVectorDataProvider *provider)
Returns the feature request based on feature ids build with primary keys.
QgsFeatureRequest & setFilterFids(const QgsFeatureIds &fids)
Sets feature IDs that should be fetched.
SERVER_EXPORT QString getExpressionFromServerFid(const QString &serverFid, const QgsVectorDataProvider *provider)
Returns the expression feature id based on primary keys.
QList< int > QgsAttributeList
This is the base class for vector data providers.
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
SERVER_EXPORT QString pkSeparator()
Returns the primary keys separator.