0

I've been having a lot of trouble with this error, in multiple versions of QGIS/QField (3.22 LTR, 3.24.2, 3.26.2) and have checked out useful answers about getting the uuid of the parent and the foreign key of the child properly set up, etc etc, with success in some test projects, but not the actual one.

I suspect but can't really be sure that the problem arises when the uuid is added to the parent with the Fields item in the layer properties, rather than created with the new Geopackage Layer item, but I don't think there's any easy way to escape adding it, because I'm trying to import a .gpx file from a walk mapping app (MyTrails by FrogSparks), which I had been (ab)using as a GIS app. Some test projects I've made with the parent layer fully created by Create Layer|New Geopackage Layer do not have this problem, and work fine (but don't have the data).

So the questions are a) is my suspicion that fields added later cannot be used for creating many-to-one relations correct b) is there anything reasonably straightforward to deal with the resulting problem (I've tried import the .gpx as a shape file, adding the uuid there, and then exporting as Geopackage, but that didn't work).

And a further c) there is an fid field which is the default provided by the Relations editor, but every tutorial I've ever seen doesn't use that, but rather added uuid attributes. Is there some reason for using uuid, such as greater compatibility with things you might want to do later? (It didn't work, but maybe I made some mistake in that experiment, but, if it doesn't work, why is it presented as the default?)

5
  • UUID is preferred to FID because it is universally unique and this has several benefits. E.g. when combining data from say multiple surveypors, there is (almost) no risk of duplicate a duplicate uuid, but there is a high risk of a duplicate fid.
    – Oisin
    Commented Sep 7, 2022 at 7:49
  • About question b, did you try importing the gpx as it is, then save that gpx as a shape file or layer in a geopackage, and then rename the column names so that they match with the column names in the target table? When they match (lower and higher case sensitive), you can simply copy them all on the map of the source table (select them all and CTRL + C) and paste them (CTRL + V) on the map of the target table (the uuid will be added automatically). Hope this helps. Commented Sep 7, 2022 at 19:29
  • Thanks @Oisin! That is useful background information, not explained in the tutorials I have seen. Commented Sep 8, 2022 at 10:27
  • Thanks @Boswatcher_Marc! This helped me see that my actual problem was quite different than I thought it was; the features form the original gpx file don't get an actual uuid assigned at any point, since this happens on creation. The amount of data is small enough so that I can do this by hand if there isn't some easy-to-find way to it automatically. Commented Sep 8, 2022 at 11:25
  • And the efficient way to fill in uuid values with 3.6.2 is to first make the uuid attribute visible with the forms editor, then open the Attribute Table, hit the yellow pencil, select uuid in the box below, hit the epsilon, put uuid() into the Expression tab, hit OK, and then 'update all' and finally the 'save' button (3rd from left). A problem with this project, other than my own stupidity, is that most of the documentation and all of the tutorials are outdated, current QGIS providing much more streamlined ways of doing many useful things. Commented Sep 9, 2022 at 4:04

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.