While implementing the issue, I came to realise that the delete operation on badges does not apply CASCADE delete from the database which would delete associated ASSERTIONS as well
|
def delete_badge(self, badge_id): |
I was testing the different operations on ASSERTION when I faced below error while trying to delete a badge which had an assertion aligned to it
IntegrityError
sqlalchemy.exc.IntegrityError: (psycopg2.errors.NotNullViolation) null value in column "badge_id" of relation "assertions" violates not-null constraint DETAIL: Failing row contains (baccha -> 67405, null, 67405, 7070cf62-1340-4a1a-945f-91b7d186bdce, 2025-09-19 15:41:23.180489, 791cb4baa0d96c00a739f09171dc7d77fb2b07ede370a2a9d58858e71fc5e3c2, Testing assertion creation). [SQL: UPDATE assertions SET badge_id=%(badge_id)s WHERE assertions.id = %(assertions_id)s] [parameters: {'badge_id': None, 'assertions_id': 'baccha -> 67405'}] (Background on this error at: https://sqlalche.me/e/20/gkpj)
It seems no ondelete="CASCADE" is used while setting up the tables.
|
badge_id = Column(Unicode(128), ForeignKey("badges.id"), nullable=False) |
While implementing the issue, I came to realise that the delete operation on badges does not apply
CASCADEdelete from the database which would delete associatedASSERTIONSas welltahrir-api/tahrir_api/dbapi.py
Line 387 in 2c97066
I was testing the different operations on
ASSERTIONwhen I faced below error while trying to delete a badge which had an assertion aligned to itIt seems no
ondelete="CASCADE"is used while setting up the tables.tahrir-api/tahrir_api/model.py
Line 271 in 2c97066