mirror of
				https://github.com/qgis/QGIS.git
				synced 2025-11-04 00:04:25 -05:00 
			
		
		
		
	Don't send expressions with special fields to provider
This commit is contained in:
		
							parent
							
								
									fee5da9071
								
							
						
					
					
						commit
						480a0f17c3
					
				@ -54,6 +54,16 @@ class QgsFeatureRequest
 | 
			
		||||
    QgsFeatureRequest& setFilterExpression( const QString& expression );
 | 
			
		||||
    QgsExpression* filterExpression() const;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Disables filter conditions.
 | 
			
		||||
     * The spatial filter (filterRect) will be kept in place.
 | 
			
		||||
     *
 | 
			
		||||
     * @return The object the method is called on for chaining
 | 
			
		||||
     *
 | 
			
		||||
     * @note Added in 2.12
 | 
			
		||||
     */
 | 
			
		||||
    QgsFeatureRequest& disableFilter();
 | 
			
		||||
 | 
			
		||||
    //! Set flags that affect how features will be fetched
 | 
			
		||||
    QgsFeatureRequest& setFlags( Flags flags );
 | 
			
		||||
    const Flags& flags() const;
 | 
			
		||||
 | 
			
		||||
@ -112,6 +112,16 @@ class CORE_EXPORT QgsFeatureRequest
 | 
			
		||||
    QgsFeatureRequest& setFilterExpression( const QString& expression );
 | 
			
		||||
    QgsExpression* filterExpression() const { return mFilterExpression; }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Disables filter conditions.
 | 
			
		||||
     * The spatial filter (filterRect) will be kept in place.
 | 
			
		||||
     *
 | 
			
		||||
     * @return The object the method is called on for chaining
 | 
			
		||||
     *
 | 
			
		||||
     * @note Added in 2.12
 | 
			
		||||
     */
 | 
			
		||||
    QgsFeatureRequest& disableFilter() { mFilter = FilterNone; return *this; }
 | 
			
		||||
 | 
			
		||||
    //! Set flags that affect how features will be fetched
 | 
			
		||||
    QgsFeatureRequest& setFlags( Flags flags );
 | 
			
		||||
    const Flags& flags() const { return mFlags; }
 | 
			
		||||
 | 
			
		||||
@ -117,6 +117,21 @@ QgsVectorLayerFeatureIterator::QgsVectorLayerFeatureIterator( QgsVectorLayerFeat
 | 
			
		||||
    mProviderRequest.setSubsetOfAttributes( providerSubset );
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if ( mProviderRequest.filterType() == QgsFeatureRequest::FilterExpression )
 | 
			
		||||
  {
 | 
			
		||||
    Q_FOREACH( const QString& field, mProviderRequest.filterExpression()->referencedColumns() )
 | 
			
		||||
    {
 | 
			
		||||
      int idx = source->mFields.fieldNameIndex( field );
 | 
			
		||||
 | 
			
		||||
      // If there are fields in the expression which are not of origin provider, the provider will not be able to filter based on them.
 | 
			
		||||
      // In this case we disable the expression filter.
 | 
			
		||||
      if ( source->mFields.fieldOrigin( idx ) != QgsFields::OriginProvider )
 | 
			
		||||
      {
 | 
			
		||||
        mProviderRequest.disableFilter();
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if ( mSource->mHasEditBuffer )
 | 
			
		||||
  {
 | 
			
		||||
    mChangedFeaturesRequest = mProviderRequest;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user