fix: add values_callable to all SQLAlchemy Enum columns
SQLAlchemy 2.0 defaults to mapping Python enum *names* (OPEN, CLOSED) to DB values, but MySQL stores lowercase *values* (open, closed). This mismatch causes LookupError on read. Adding values_callable=lambda x: [e.value for e in x] tells SQLAlchemy to use the enum values for DB mapping. Affected models: milestone, task, meeting, propose, support
This commit is contained in:
@@ -23,8 +23,8 @@ class Task(Base):
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
title = Column(String(255), nullable=False)
|
||||
description = Column(Text, nullable=True)
|
||||
status = Column(Enum(TaskStatus), default=TaskStatus.OPEN)
|
||||
priority = Column(Enum(TaskPriority), default=TaskPriority.MEDIUM)
|
||||
status = Column(Enum(TaskStatus, values_callable=lambda x: [e.value for e in x]), default=TaskStatus.OPEN)
|
||||
priority = Column(Enum(TaskPriority, values_callable=lambda x: [e.value for e in x]), default=TaskPriority.MEDIUM)
|
||||
task_code = Column(String(64), nullable=True, unique=True, index=True)
|
||||
|
||||
# Task type/subtype (replaces old issue_type/issue_subtype)
|
||||
|
||||
Reference in New Issue
Block a user