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

Fit projection relationship not deleted properly #90

Closed
blitzmann opened this issue May 2, 2014 · 1 comment
Closed

Fit projection relationship not deleted properly #90

blitzmann opened this issue May 2, 2014 · 1 comment

Comments

@blitzmann
Copy link
Collaborator

I already have a fix for this (kinda, see blitzmann@a2727d5), but in the interest of documentation I am creating this issue.

While looking into the various bugs pertaining to projected fits (many of which have been since fixed), I discovered that the relationship in the database is not properly deleted. This causes some issues (including silent crashing requiring restart) as SQL Alchemy can reuse auto-increment IDs. Collisions can occur.

For example, if you have B -> A, and delete A, the relationship is deleted correctly. However, if you delete B, the relationship sticks around. If you delete B and then create a new fit (C, which can take the ID of B and reuse it for itself), and then try to project C -> A, Pyfa crashes because it tries to add the exact same information into the database which is already there (since the old B -> A wasn't deleted).

This happens because when you delete A, sqlalchemy cascades that deletion to the relationship (which only pulls fits projected onto A). However, if you delete B, the Fit object doesn't have any relationship data to delete.

The quick fix is to simply query fits that are projected onto the current fit and fits that the current fit is projected onto. This way, when deleted, we know that all relationships are properly removed.

Now, for the "kinda fixed" part. When you delete a projected fit, that change is not reflected in currently loaded fits. So the UI can still show that there is a fit projected when it has been deleted. This can cause a crash if you try to copy the fit (as it tried to copy the projected fit which no longer exists). Not sure how to fix this just yet.

blitzmann added a commit to blitzmann/Pyfa that referenced this issue May 2, 2014
blitzmann added a commit that referenced this issue May 3, 2014
@blitzmann
Copy link
Collaborator Author

Issue fixed as of 2651a04

The first fix didn't work out. To remove the projected fit from the loaded Fits, the easiest way is to simply fit.projectedFits.remove(). This also remove the relation. However, the first fix removes the relation as well. So now it was trying to remove it twice and choking on it.

I simply reverted the original commit and did it differently. Now when you remove a fit, it queries for fits links to it in the Projected table, then iterates through them removing the projected fit. It finally then removes the fit. I had to tweak a few other things to get the active fit to refresh correctly.

Ebag333 added a commit to Ebag333/Pyfa that referenced this issue May 16, 2017
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

No branches or pull requests

1 participant