Open colinallen opened 11 years ago
Problem is with SQLAlchemy configuration of SearchPatterns:
AssertionError: Dependency rule tried to blank-out primary key column 'searchpatterns.target_id' on instance '<Searchpattern at 0x107718150>'
Most likely need to set delete='cascading' on one of the relations.
Fixed this by moving the entity property of the searchpattern to be definied within the Entity class, rather than the Searchpattern class. In doing so, I also enabled passive_deletes and set up the proper cascades. This now allows us to delete ideas newly created.
We will have an issue with thinkers that have influence and teacher relations, but as we are not collecting that feedback, this suits the present purposes and has been pushed. Exploration of that issue was discovered by trying to delete Plato (3724):
sqlalchemy.exc.IntegrityError: (IntegrityError) (1451, 'Cannot delete or update a parent row: a foreign key constraint fails (`inphomirror`.`thinker_has_influenced`, CONSTRAINT `fk_thinker_has_influenced_thinker1` FOREIGN KEY (`thinker1_id`) REFERENCES `thinker` (`ID`) ON DELETE NO ACTION ON UPDATE NO ACTION)') 'DELETE FROM thinker WHERE thinker.`ID` = %s' (3724,)
an application of the same principle of passive_deletes did not fix the issue.
There were further complications caused by an upstream error in MySQL in which we were getting errors like:
sqlalchemy.orm.exc.StaleDataError: DELETE statement on table 'thinker_has_influenced_evaluation' expected to delete 7 row(s); Only 10 were matched.
This is because Plato influenced 7, and was influenced_by 3, so there are 10 rows in the table, all of which must be deleted. I found out about this and a solution to disable the supports_sane_rowcount for the InnoDB tables at the SQLAlchemy Google Group, but it is super hacky. I want to return to this over break, because I suspect the move to the new server will resolve many of these issues, and the immediate problem at hand is fixed.
Trying to test through the web interface reveals this is still broken...
Looks like I'm going to have to examine the constraints on all of the tables tonight.
This bug is still alive -- 6 yrs!
Similar problem with https://www.inphoproject.org/idea/1083
Verifying similar error as before:
IntegrityError: (IntegrityError) (1451, 'Cannot delete or update a parent row: a foreign key constraint fails (`seponto`.`date`, CONSTRAINT `fk_date_entity1` FOREIGN KEY (`entity_id`) REFERENCES `entity` (`ID`) ON DELETE NO ACTION ON UPDATE NO ACTION)') 'DELETE FROM entity WHERE entity.`ID` = %s' (4151,)
I'm trying curl -X DELETE -u name:password https://inpho.cogs.indiana.edu/thinker/4151 (with appropriate name and password) and it returns internal server error