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

Apparent duplicates in einheitenaenderungnetzbetreiberzuordnungen are dropped #577

Open
nesnoj opened this issue Oct 10, 2024 · 0 comments
Assignees
Labels
🐛 bug Something isn't working

Comments

@nesnoj
Copy link
Collaborator

nesnoj commented Oct 10, 2024

During import into changed_dso_assignment / ChangedDSOAssignment the log says

File 'EinheitenAenderungNetzbetreiberzuordnungen.xml' is parsed.
Data is cleansed.
778 entries already existed in the database.

However - if I understand the table right - the system operator may change multiple times so it's not a good idea to solely use EinheitMastrNummer as primary key:

class ChangedDSOAssignment(ParentAllTables, Base):
__tablename__ = "changed_dso_assignment"
EinheitMastrNummer = Column(String, primary_key=True)
LokationMastrNummer = Column(String)
NetzanschlusspunktMastrNummer = Column(String)
NetzbetreiberMastrNummerNeu = Column(String)
NetzbetreiberMastrNummerAlt = Column(String)
ArtDerAenderung = Column(String)
RegistrierungsdatumNetzbetreiberzuordnungsaenderung = Column(
DateTime(timezone=True)
)
Netzbetreiberzuordnungsaenderungsdatum = Column(DateTime(timezone=True))

To avoid losing this data, we should think of a primary key constraint on multiple columns such as

__table_args__ = (
        PrimaryKeyConstraint('EinheitMastrNummer', 'NetzbetreiberMastrNummerAlt', NetzbetreiberMastrNummerNeu),
)

However, there could be duplicates as well so maybe it's better to include the date like this:

__table_args__ = (
        PrimaryKeyConstraint('EinheitMastrNummer', 'Netzbetreiberzuordnungsaenderungsdatum'),
)

The table was added in #510

@nesnoj nesnoj added the 🐛 bug Something isn't working label Oct 10, 2024
@nesnoj nesnoj self-assigned this Dec 3, 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
Projects
None yet
Development

No branches or pull requests

1 participant