Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix optimize_expression to genereate atlas of feature with textual PKs #72

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

maxencelaurent
Copy link

* allow non-numeric PK expression optimization
* do not assume PK is the very first field of the list: use
  layer.primaryKeyAttributes() instead
* fixes 3liz#71
* related to 3liz/lizmap-web-client#4534
@Gustry
Copy link
Member

Gustry commented Jul 4, 2024

This PR is breaking tests.
Can you add some more ?

* using string pkey is now safe
* According to the [PyQGIS documentation](https://qgis.org/pyqgis/3.0/core/Vector/QgsVectorLayer.html#qgis.core.QgsVectorLayer.primaryKeyAttributes), `QgsVectorLayer.primaryKeyAttributes`
  represents the indexes of the attributes which make up the layer's
  primary key. Former `test_tools::test_optimize_filter` defined this
  using fieldnames. This has been fix using field indexes.
+ New test case in which the primary key is not the first attribute of
  the layer
@maxencelaurent
Copy link
Author

I've fixed the test. There were two issues.

First was quite straightforward: it's now safe to use string PK.

The second was that the test layers were poorly crafted. primaryKeyAttributes shall be field indexes, not field names.

@Gustry
Copy link
Member

Gustry commented Jul 4, 2024

primaryKeyAttributes shall be field indexes, not field names.

Yes you are right, but having a list of field indexes or a list of field strings, it didn't change anything the code, as only the length of the list was used. So it was somehow readable. But yes, it's ok.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GetPrintAtlas does not work if ID of feature is not a number
2 participants