Skip to content

Get or create function #50

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

Closed
carbonarok opened this issue May 10, 2021 · 0 comments · Fixed by #70
Closed

Get or create function #50

carbonarok opened this issue May 10, 2021 · 0 comments · Fixed by #70
Assignees
Labels
status: accepted This issue has been accepted by the maintainers team for implementation status: help wanted This issue is tentatively accepted pending a volunteer committed to its implementation

Comments

@carbonarok
Copy link

carbonarok commented May 10, 2021

Environment

  • DiffSync version: 1.1.0

Ability to either get or create an object like the Django ORM

Function that takes the identifiers of an object and either gets or create an object.
Current work around is wrap an object get in an exception of ObjectNotFound.

Use Case

Currently using try and except to catch if an object already exists.

            try:
                self.add(vrf)
            except ObjectAlreadyExists:
                pass

Expected use

self.get_or_create(vrf)
self.update_or_create(vrf)
@dgarros dgarros added status: accepted This issue has been accepted by the maintainers team for implementation status: help wanted This issue is tentatively accepted pending a volunteer committed to its implementation type: minor feature labels Jun 18, 2021
@FragmentedPacket FragmentedPacket self-assigned this Oct 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: accepted This issue has been accepted by the maintainers team for implementation status: help wanted This issue is tentatively accepted pending a volunteer committed to its implementation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants