Skip to content

Constrain Urls.doctype at the DB level with an Enum #186

@stultus

Description

@stultus

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,
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions