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

set obj_id sequences when importing #223

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

cymed
Copy link
Contributor

@cymed cymed commented Apr 25, 2024

This PR sets the sequences used for obj_id generation based on the current value of the sequence and the highest imported postfix with a matching shortcut. Mainly necessary when importing a dataset that was exported by TEKSI. Tackles #117

@cymed cymed self-assigned this Apr 25, 2024
@cymed cymed added enhancement New feature or request plugin Concerns the wastewater plugin INTERLIS About INTERLIS exchange format (import / export) review Waiting for review labels Apr 25, 2024
@cymed cymed requested review from urskaufmann and sjib and removed request for urskaufmann April 25, 2024 09:52
@sjib
Copy link
Contributor

sjib commented Apr 25, 2024

@cymed Funktioniert das auch wenn du Daten mit verschiedenen Präfixes hast in einer Tabelle?

@urskaufmann
Copy link
Contributor

I do not really understand the code. I think to understand, that the prefix has no effect !?
I think that is not efficient. The postfix has to be unique per prefix and not overall.
If I choose a new prefix (what reason ever - because there are to many records), I should have a function who resets the sequence numbers. If I have to migrate my old database (that has three prefixes, two from the merged communities and one for the cantons road_drainage), I want the sequence_number for new records to be dependent on the actual prefix.

@cymed
Copy link
Contributor Author

cymed commented Apr 30, 2024

I do not really understand the code. I think to understand, that the prefix has no effect !? I think that is not efficient. The postfix has to be unique per prefix and not overall. If I choose a new prefix (what reason ever - because there are to many records), I should have a function who resets the sequence numbers. If I have to migrate my old database (that has three prefixes, two from the merged communities and one for the cantons road_drainage), I want the sequence_number for new records to be dependent on the actual prefix.

The latest push includes the oid_prefix and re-sets all sequences to the new prefix once there is change in tww_sys.oid_prefixes, making it more dynamic.

@cymed cymed added this to the TEKSI Wastewater 2024.1 milestone Jun 20, 2024
@ponceta
Copy link
Member

ponceta commented Jul 17, 2024

Same question as @sjib, what happens when you import data with a different oid than the active one?

@sjib
Copy link
Contributor

sjib commented Jul 17, 2024

  • I think it is right that the obj_id sequence is reset with taking into account the active prefix - because new data will be created using that prefix.

  • If you change the prefix - then the obj_Id sequence again is adapted - and you can continue to create data with that new prefix.

So whether we import data with different prefixes or not seems not relevant here. More relevant is that it is clear with which prefix the user wants to go on creating new data.

@cymed @urskaufmann @ponceta - are we here all at the same point of understanding?

@cymed
Copy link
Contributor Author

cymed commented Jul 18, 2024

  • I think it is right that the obj_id sequence is reset with taking into account the active prefix - because new data will be created using that prefix.

    • If you change the prefix - then the obj_Id sequence again is adapted - and you can continue to create data with that new prefix.

So whether we import data with different prefixes or not seems not relevant here. More relevant is that it is clear with which prefix the user wants to go on creating new data.

* [ ]  Updating obj_id sequence after each import I think is a good thing to implement - then we are sure that if any new data with the chosen prefix is added the obj_id sequence is adjusted before going on with adding data (original need from Urs in [Sequence number not correct after import #117](https://github.com/teksi/wastewater/issues/117))

* [ ]  So maybe we should include this fonctionality also on to a a new button or have some visualisation what prefix is currently acitve - see [Ensure that triggers stay active in case of error #319](https://github.com/teksi/wastewater/pull/319)

@cymed @urskaufmann @ponceta - are we here all at the same point of understanding?

I agree in general. If we want to show which prefix is active, I suggest putting it into the settings. Also, once we go towards multitenancy, we'll need a way to switch between tenants anyway

@cymed cymed closed this Jul 25, 2024
@cymed cymed reopened this Jul 25, 2024
@urskaufmann
Copy link
Contributor

I agree with @sjib . And to show the active prefix is also good idea (anyway, if you care, you will see the active prefix with every new record you create in the obj_id...)

@cymed cymed closed this Aug 30, 2024
@cymed cymed reopened this Aug 30, 2024
@cymed
Copy link
Contributor Author

cymed commented Sep 3, 2024

@cymed dependecies on merging #381

@cymed cymed closed this Sep 30, 2024
@cymed cymed reopened this Sep 30, 2024
Copy link
Contributor

@sjib sjib left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be wise to add some tests for that also?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request INTERLIS About INTERLIS exchange format (import / export) plugin Concerns the wastewater plugin review Waiting for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants