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

SingleInheritance views use default obj_id of parent instead of child #65

Closed
cymed opened this issue Jan 3, 2024 · 9 comments · Fixed by #288
Closed

SingleInheritance views use default obj_id of parent instead of child #65

cymed opened this issue Jan 3, 2024 · 9 comments · Fixed by #288
Assignees
Labels
bug Something isn't working datamodel Concerns the datamodel

Comments

@cymed
Copy link
Contributor

cymed commented Jan 3, 2024

If the Primary Key of a SingleInheritance view (i.e. tww_app.vw_cover) is missing, the insert command from pirogue uses the PK of the parent (i.e. structure_part). It would be more user friendly to use the child's PK.

@sjib
Copy link
Contributor

sjib commented Jan 3, 2024 via email

@cymed
Copy link
Contributor Author

cymed commented Jan 3, 2024

If you add a cover in vw_cover, we use tww_sys.generate_oid('tww_od'::text, 'cover'::text) as a default for the view. This default is only applied in three cases:

  1. When QGIS is set to apply defaults on provider side
  2. when creating an item with an insert query that omits setting obj_id
  3. when creating an item with an insert query that sets obj_id=DEFAULT.

However, when creating an item with obj_id =NULL, we use tww_sys.generate_oid('tww_od'::text, 'structure_part'::text) . The same goes with all SingleInheritance views.

@sjib
Copy link
Contributor

sjib commented Jan 5, 2024

I see the problem:
ww_sys.generate_oid('tww_od'::text, 'structure_part'::text) will generate an obj_id with prefix + shortcut of structure_part and then 6 digits - eg. ch000000SP000001
tww_sys.generate_oid('tww_od'::text, 'cover'::text) will generate an obj_id with prefix + shortcut of cover and then 6 digits - eg. ch000000CO000001

@cymed
Copy link
Contributor Author

cymed commented Feb 2, 2024

Solve in bugfixing, maybe upstream in pirogue

@sjib sjib added the bug Something isn't working label Feb 2, 2024
@ponceta ponceta added the datamodel Concerns the datamodel label Feb 12, 2024
@ponceta
Copy link
Member

ponceta commented Feb 13, 2024

To be discussed with @ponceta and @3nids

@ponceta ponceta self-assigned this Mar 4, 2024
@ponceta
Copy link
Member

ponceta commented Apr 10, 2024

However, when creating an item with obj_id =NULL, we use tww_sys.generate_oid('tww_od'::text, 'structure_part'::text) . The same goes with all SingleInheritance views.

Could you add a bit of context? Is it a case when you insert data with QGIS?

The QGIS project should be set so that the obj_id get generated right but I'm open to enhancements on that side!

@sjib
Copy link
Contributor

sjib commented Apr 12, 2024

@cymed Can you show, where this happens in the code?

@cymed
Copy link
Contributor Author

cymed commented Apr 15, 2024

It happens in pirogue, called in

for key in SingleInheritances:
SingleInheritance(
"tww_od." + SingleInheritances[key],
"tww_od." + key,
view_name="vw_" + key,
pkey_default_value=True,
inner_defaults={"identifier": "obj_id"},
**defaults,
).create()

in pirogue, I suppose we enter the exception in https://github.com/opengisch/pirogue/blob/9cbf10f2a8811d84b2051b6b1d2a9c2b78b4a4bb/pirogue/single_inheritance.py#L77-L80 but I can't see why

3nids added a commit that referenced this issue Jul 5, 2024
@3nids 3nids mentioned this issue Jul 5, 2024
@3nids
Copy link
Contributor

3nids commented Jul 5, 2024

fixed by #288

for more details, see opengisch/pirogue#34

@3nids 3nids closed this as completed in #288 Jul 8, 2024
@3nids 3nids closed this as completed in 502eaa6 Jul 8, 2024
cymed added a commit that referenced this issue Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working datamodel Concerns the datamodel
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants