1

I have a problem with this code :

for layer in layers :
   #surcharge avec le filtre permanent
   if QgsExpressionContextUtils.layerScope(layer).variable('layer_filter')!=None:
     sql=u"(" + sql + u") AND " + QgsExpressionContextUtils.layerScope(layer).variable('layer_filter')

When a variable is found it is added to the sql variable. It is however kept for every layer even if there is no filter variable for them.

What can be done so the SQL filter corresponds to a single layer?

0

Add an else clause that puts an empty string in sql

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.