Skip to content

Badge model columns missing nullable=False, mismatching schema #578

@mircealungu

Description

@mircealungu

The SQL schema for badge enforces NOT NULL on description and (after PR #573) default_description, but the SQLAlchemy model has them as plain db.Column(db.Text) — which defaults to nullable=True.

# zeeguu/core/model/badge.py
description = db.Column(db.Text)               # schema: NOT NULL
default_description = db.Column(db.Text)       # schema: NOT NULL (after PR #573)

Why it matters

  • ORM-layer code can construct a Badge without these fields and the model layer won't complain. The error only surfaces at flush/commit time as a database-level integrity error, which is harder to trace than a clear ORM validation failure.
  • The Python model becomes misleading documentation of the schema.

Fix

Add nullable=False to columns whose schema enforces it:

description = db.Column(db.Text, nullable=False)
default_description = db.Column(db.Text, nullable=False)

Worth a quick sweep of other models too — this is a pattern that probably exists elsewhere.

Context: came up reviewing PR #573.

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