<div dir="ltr">Hi Hannes,<div><br></div><div>This information can be used by the expression engine to determine what needs to be requested from the provider.</div><div>This can lead to significant performance improvements, depending on the scenario.</div><div><br></div><div>Depending on other functions used in the expression and the capabilities of the provider itself, the request may or may not include them.</div><div><br></div><div>As stated in the help, it's what the function *requires*, these attributes are guaranteed to be available. Others may still be there.</div><div><br></div><div>Cheers</div><div>Matthias</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Nov 22, 2021 at 2:41 PM Johannes Kröger (WhereGroup) <<a href="mailto:johannes.kroeger@wheregroup.com" target="_blank">johannes.kroeger@wheregroup.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi list,<br>
<br>
<a href="https://docs.qgis.org/3.22/en/docs/user_manual/expressions/expression.html#function-editor" rel="noreferrer" target="_blank">https://docs.qgis.org/3.22/en/docs/user_manual/expressions/expression.html#function-editor</a> <br>
mentions the optional keyword argument "referenced_columns" to the <br>
`@qgsfunction` decorator. It says<br>
<br>
 > referenced_columns=[list]: An array of attribute names that are <br>
required to the function. Defaults to<br>
 > [QgsFeatureRequest.ALL_ATTRIBUTES].<br>
<br>
That, and examples where it is used in other people's code, led me to <br>
believe that the feature's attributes would not be accessible unless <br>
listed in that parameter or if the parameter was omitted (-> default <br>
value getting used -> default is all attributes).<br>
<br>
The default code that gets inserted into the editor includes the <br>
decorator `@qgsfunction(args='auto', group='Custom', <br>
referenced_columns=[])` so I'd assume that I would not be able to use <br>
any attributes in the function.<br>
<br>
In reality I can access them just fine though, e. g. `feature["name"]` <br>
if I had features with a "name" attribute and that default <br>
`referenced_columns=[]`.<br>
<br>
I can even do so if I used `referenced_columns=["foo", "bar"]`! <br>
`feature["name"]` is still perfectly accessible.<br>
<br>
Is this a bug or by design? If by design, what purpose does this <br>
parameter have?<br>
<br>
Thanks<br>
Hannes<br>
<br>
-- <br>
Johannes Kröger / GIS-Entwickler/-Berater<br>
WhereGroup GmbH<br>
Eifelstraße 7<br>
53119 Bonn<br>
Germany<br>
<br>
Tel: +49 (0)228 / 90 90 38 - 36<br>
Fax: +49 (0)228 / 90 90 38 - 11<br>
<br>
<a href="mailto:johannes.kroeger@wheregroup.com" target="_blank">johannes.kroeger@wheregroup.com</a><br>
<a href="http://www.wheregroup.com" rel="noreferrer" target="_blank">www.wheregroup.com</a><br>
Geschäftsführer:<br>
Olaf Knopp, Peter Stamm<br>
Amtsgericht Bonn, HRB 9885<br>
-------------------------------<br>
<br>
********************************************<br>
Where2B Konferenz 2021<br>
16. Dezember 2021<br>
im Universitätsclub Bonn und online<br>
<a href="https://where2b-conference.com/" rel="noreferrer" target="_blank">https://where2b-conference.com/</a><br>
********************************************<br>
<br>
_______________________________________________<br>
QGIS-Developer mailing list<br>
<a href="mailto:QGIS-Developer@lists.osgeo.org" target="_blank">QGIS-Developer@lists.osgeo.org</a><br>
List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
</blockquote></div>