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

Error with deleting fit that was once used as a command fit #1692

Closed
blitzmann opened this issue Aug 4, 2018 · 0 comments
Closed

Error with deleting fit that was once used as a command fit #1692

blitzmann opened this issue Aug 4, 2018 · 0 comments
Labels
bug Confirmed to be a bug fixed This issue has been fixed! Oh joy! logged Logged in changelog for release

Comments

@blitzmann
Copy link
Collaborator

  1. Add fit A to fit B as a command fit.
  2. Remove Fit A from Fit B
  3. Attempt to delete Fit A
  4. Error:
Traceback (most recent call last):
  File "C:\Users\holme\Documents\Sync\Git\blitzmann\Pyfa\gui\builtinShipBrowser\sfBrowserItem.py", line 333, in OnLeftUp
    btn.DoCallback()
  File "C:\Users\holme\Documents\Sync\Git\blitzmann\Pyfa\gui\builtinShipBrowser\sfBrowserItem.py", line 50, in DoCallback
    self.callback()
  File "C:\Users\holme\Documents\Sync\Git\blitzmann\Pyfa\gui\builtinShipBrowser\fitItem.py", line 373, in deleteBtnCB
    self.deleteFit()
  File "C:\Users\holme\Documents\Sync\Git\blitzmann\Pyfa\gui\builtinShipBrowser\fitItem.py", line 391, in deleteFit
    sFit.deleteFit(self.fitID)
  File "C:\Users\holme\Documents\Sync\Git\blitzmann\Pyfa\service\fit.py", line 211, in deleteFit
    if booster.boosted_fit != fit and booster.boosted_fit in eos.db.saveddata_session:  # GH issue #359
  File "C:\Users\holme\Documents\Sync\Git\blitzmann\Pyfa\venv\lib\site-packages\sqlalchemy\orm\session.py", line 2123, in __contains__
    raise exc.UnmappedInstanceError(instance)
sqlalchemy.orm.exc.UnmappedInstanceError: Class 'builtins.NoneType' is not mapped

This has to do with this tacky code:

    @staticmethod
    def deleteFit(fitID):
        fit = eos.db.getFit(fitID)
        pyfalog.debug("Fit::deleteFit - Deleting fit: {}", fit)

        # refresh any fits this fit is projected onto. Otherwise, if we have
        # already loaded those fits, they will not reflect the changes

        # A note on refreshFits: we collect the target fits in a set because
        # if a target fit has the same fit for both projected and command,
        # it will be refreshed first during the projected loop and throw an
        # error during the command loop
        refreshFits = set()
        for projection in list(fit.projectedOnto.values()):
            if projection.victim_fit != fit and projection.victim_fit in eos.db.saveddata_session:  # GH issue #359
                refreshFits.add(projection.victim_fit)

        for booster in list(fit.boostedOnto.values()):
            if booster.boosted_fit != fit and booster.boosted_fit in eos.db.saveddata_session:  # GH issue #359
                refreshFits.add(booster.boosted_fit)

        eos.db.remove(fit)

        pyfalog.debug("    Need to refresh {} fits: {}", len(refreshFits), refreshFits)
        for fit in refreshFits:
            eos.db.saveddata_session.refresh(fit)

        eos.db.saveddata_session.commit()

I am still working on #1524 on/off, which let me to this issue. I hope to delve into it with this work, as I'm reworking a lot of old functionality. Keeping track of it here though for now, but if anyone is interested in taking a look into this, feel free to submit a PR - the deleteFit functionality is probably not going to be changing drastically from my work.

@blitzmann blitzmann added the bug Confirmed to be a bug label Aug 4, 2018
@feyyd feyyd mentioned this issue Aug 21, 2018
@blitzmann blitzmann added fixed This issue has been fixed! Oh joy! logged Logged in changelog for release labels Aug 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Confirmed to be a bug fixed This issue has been fixed! Oh joy! logged Logged in changelog for release
Projects
None yet
Development

No branches or pull requests

1 participant