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

The problem of a unique human-readable id vs UUID #636

Open
fguerra06 opened this issue Feb 6, 2025 · 4 comments
Open

The problem of a unique human-readable id vs UUID #636

fguerra06 opened this issue Feb 6, 2025 · 4 comments

Comments

@fguerra06
Copy link

Hello,

I'm dealing with a problem of articulation between UUIDs and human-readable identifiers.

Sorry for the long message but I'll try to be clear...

I have two postgis tables: « polygon » and « points ». Points can be children of polygons.

Image

In Postgis as in Qfieldsynch, the primary key of both tables are uuids. Here is an example with the polygon table:

Image

Each polygon has a type and a number, the combination of them must be unique. This is my auto-calculated and human readable “type_num” field.

Image

In the “points” table, the “fk_polyg” field is a relation reference widget. The display expression is the “type_num” field in the polygon table.

Image

The “id_pol_pt” field is auto-calculated using the “represent value” function. It is my unique human-readable point identifier. It concatenates “fk_polyg” which is supposed to be the display expression “type_num”, the type of point and the point number. « type_num » is itself the result of automatic concatenation in polygon table.

Image

Point labels and display names are based on the « id_pol_pt » field.

Image

When I add a point directly in Qgis, everything works fine. I can see my human-readable identifier.

Image

After exportation, this identifier is recognized by Qfield and all goes well when I add a new point in Qfield. I can see my human-readable field.

Image

The problem occurs when Qfield and Qgis synchronize. QGIS is unable to find the “type_num” component of the polygon. It writes the uuid instead.

Image

I get the following error about the RepresentValue() fonction.

"2025-02-06T15:14:23 WARNING Layer point, field fk_polyg: representValue() with inconsistent layer parameter w.r.t relation referencingLayer"

Image

Is there something wrong with my approach?

Thank you.

Fabien

@fguerra06
Copy link
Author

Hello, is there a better place to write this kind of problem?

Fabien

@SeqLaz
Copy link
Member

SeqLaz commented Feb 12, 2025

Hi @fguerra06, sorry for the late reply.

It seems the retrieved information is the ID of the foreign key. As a suggestion for the "id_pol_pt", instead of using the represent_value() function, use the following expression (The warning is just a warning in the console):

attribute(get_feature(layer:='polygone', attribute:='id_polyg', value:="fk_polyg"), 'type_polyg')

Copy link

The QFieldSync project highly values your report and would love to see it addressed. However, this issue has been left in feedback mode for the last 14 days and is being automatically marked as "stale". If you would like to continue with this issue, please provide any missing information or answer any open questions. If you could resolve the issue yourself meanwhile, please leave a note for future readers with the same problem and close the issue.
In case you should have any uncertainty, please leave a comment and we will be happy to help you proceed with this issue.
If there is no further activity on this issue, it will be closed in a week.

@github-actions github-actions bot added the stale label Feb 27, 2025
@fguerra06
Copy link
Author

Hello, thank you for the answer. Sorry to to the late response. I'll try it. For the moment I solved the problem by using a simple join in the layer properties dialog. It's working well without adding a new field in the postgis database.

Thank you again

Fabien

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

No branches or pull requests

2 participants