26 if ( pkAttributes.isEmpty() )
28 return QString::number( feature.
id() );
32 for (
const auto &attrIdx : std::as_const( pkAttributes ) )
34 pkValues.append( feature.
attribute( attrIdx ).toString() );
43 if ( pkAttributes.isEmpty() )
46 for (
const QString &serverFid : serverFids )
51 return featureRequest;
55 for (
const QString &serverFid : serverFids )
60 if ( expList.count() == 1 )
66 QString fullExpression;
67 for (
const QString &exp : std::as_const( expList ) )
69 if ( !fullExpression.isEmpty() )
71 fullExpression.append( QStringLiteral(
" OR " ) );
73 fullExpression.append( QStringLiteral(
"( " ) );
74 fullExpression.append( exp );
75 fullExpression.append( QStringLiteral(
" )" ) );
80 return featureRequest;
87 if ( pkAttributes.isEmpty() )
94 QString expressionString;
95 QStringList pkValues = serverFid.split(
pkSeparator() );
96 int pkExprSize = std::min( pkAttributes.size(), pkValues.size() );
97 for (
int i = 0; i < pkExprSize; ++i )
101 expressionString.append( QStringLiteral(
" AND " ) );
104 QString fieldName = fields[ pkAttributes.at( i ) ].name();
108 return expressionString;
113 return QStringLiteral(
"@@" );
static QString createFieldEqualityExpression(const QString &fieldName, const QVariant &value, QVariant::Type fieldType=QVariant::Type::Invalid)
Create an expression allowing to evaluate if a field is equal to a value.
This class wraps a request for features to a vector layer (or directly its vector data provider).
QgsFeatureRequest & combineFilterExpression(const QString &expression)
Modifies the existing filter expression to add an additional expression filter.
QgsFeatureRequest & setFilterFids(const QgsFeatureIds &fids)
Sets the feature IDs that should be fetched.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
QVariant attribute(const QString &name) const
Lookup attribute value by attribute name.
Container of fields for a vector layer.
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)
This is the base class for vector data providers.
virtual QgsAttributeList pkAttributeIndexes() const
Returns list of indexes of fields that make up the primary key.
QgsFields fields() const override=0
Returns the fields associated with this data provider.
SERVER_EXPORT QString getExpressionFromServerFid(const QString &serverFid, const QgsVectorDataProvider *provider)
Returns the expression feature id based on primary keys.
SERVER_EXPORT QString pkSeparator()
Returns the primary keys separator.
SERVER_EXPORT QgsFeatureRequest updateFeatureRequestFromServerFids(QgsFeatureRequest &featureRequest, const QStringList &serverFids, const QgsVectorDataProvider *provider)
Returns the feature request based on feature ids build with primary keys.
SERVER_EXPORT QString getServerFid(const QgsFeature &feature, const QgsAttributeList &pkAttributes)
Returns the feature id based on primary keys.
QSet< QgsFeatureId > QgsFeatureIds
#define STRING_TO_FID(str)
QList< int > QgsAttributeList