Skip to content

Logical issue with the DELETE operation on BADGES #205

@sdglitched

Description

@sdglitched

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions