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

[Fix] network id handling #65

Merged
merged 8 commits into from
Sep 30, 2024
Merged

[Fix] network id handling #65

merged 8 commits into from
Sep 30, 2024

Conversation

jthurner
Copy link
Collaborator

@jthurner jthurner commented Sep 26, 2024

Make net_id the only unique identifier in a project's network collection, ensure consistent handling when specifying networks by their name or net_id, and fix a race condition when automatically assigning an index on network insertion.

Inserting multiple networks with the same name is not considered an error anymore. Only the assigned net_id, which is saved in the network document on the _id field, is considered unique.

Various functions operating on a single network exist which identify the network by it's name. As this can be ambiguous, alternative functions which identify the network by net_id exist. Using the latter is recommended. The former still work but will throw an exception if multiple networks for the given name exist in the database.

The function which stores networks, write_net_to_db, can optionally be passed a custom value for net_id. This does not have to be an integer, but an incrementing integer is assigned as net_id if no value is passed.

All functions affected by this change print out deprecation warnings with recommendations for replacements.

Possible breaking changes

A special handling of net_id in CRUD functions has been removed. Previously, these functions internally interpreted a passed net_id as the name of a network if it was of type string. This prohibits directly using strings as net_ids.

Function arguments specifying the net_id have sometimes been named net, these are now consistently named net_id to avoid confusion.

@jthurner jthurner merged commit b4a2b20 into develop Sep 30, 2024
@jthurner jthurner deleted the fix/network_ids branch October 7, 2024 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants