Problem
Urls.doctype is declared as db.Column(db.String(1000)). There is no DB-level constraint enforcing this, so any writer could insert an arbitrary string (typo, stale literal, etc.) and the model would silently accept it.
Current definition
app/api/models.py:129 (approx, in the Urls class):
doctype = db.Column(db.String(1000)) # weburl, content or comment
Proposed change
Convert to an Enum so the constraint lives with the data:
doctype = db.Column(
db.Enum('weburl', 'content', 'comment', name='url_doctype'),
nullable=False,
)
Problem
Urls.doctypeis declared asdb.Column(db.String(1000)). There is no DB-level constraint enforcing this, so any writer could insert an arbitrary string (typo, stale literal, etc.) and the model would silently accept it.Current definition
app/api/models.py:129(approx, in theUrlsclass):Proposed change
Convert to an Enum so the constraint lives with the data: