sopython/sopython-site

Canonical question fails if it reuses an SE question

Closed this issue · 1 comments

When creating a new / editing an old canonical question, you cannot add an SE question that has been used previously in another canonical question.

For example:

User1 creates a canonical question Canon1 that uses the SO question Question1
User2 creates a new canonical question Canon2 and tries to use the SO question Question1

This will result in an error. Whether a question can answer two different canonical items is one question to be decided. But even if it can't, so you can only use it once, it needs to be handled more gracefully.

Occurs when creating a new CanonItem and linking an already cached SEQuestion.

sqlalchemy.exc.IntegrityError: (raised as a result of Query-invoked autoflush; consider using a session.no_autoflush block if this flush is occurring prematurely) (IntegrityError) null value in column "updated_by_id" violates not-null constraint
DETAIL:  Failing row contains (57, test, , , null, t, f).
 'INSERT INTO canon_item (title, excerpt, body, draft, community, updated_by_id) VALUES (%(title)s, %(excerpt)s, %(body)s, %(draft)s, %(community)s, %(updated_by_id)s) RETURNING canon_item.id' {'title': 'test', 'community': False, 'updated_by_id': None, 'excerpt': '', 'draft': True, 'body': ''}