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.
The SQL schema for
badgeenforcesNOT NULLondescriptionand (after PR #573)default_description, but the SQLAlchemy model has them as plaindb.Column(db.Text)— which defaults tonullable=True.Why it matters
Badgewithout 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.Fix
Add
nullable=Falseto columns whose schema enforces it:Worth a quick sweep of other models too — this is a pattern that probably exists elsewhere.
Context: came up reviewing PR #573.