fix: rename Note.metadata → entity_meta (reserved by SQLAlchemy Declarative API)

SQLAlchemy reserves 'metadata' as a class attribute on declarative models.
Renamed to 'entity_meta' with explicit column name 'metadata' so the DB
column is unchanged but the Python attribute no longer conflicts.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-31 18:13:47 -04:00
parent 80f30b705d
commit 95056d5be7
4 changed files with 11 additions and 10 deletions
+3 -2
View File
@@ -54,7 +54,8 @@ class Note(Base, TimestampMixin):
# Entity type — 'note' (default), 'person', 'place', 'list'
note_type: Mapped[str] = mapped_column(Text, default="note", server_default="note")
# Structured metadata for entity types (person/place/list)
metadata: Mapped[dict | None] = mapped_column(JSONB, nullable=True)
# Named 'entity_meta' to avoid collision with SQLAlchemy's reserved 'metadata' attribute
entity_meta: Mapped[dict | None] = mapped_column("metadata", JSONB, nullable=True)
__table_args__ = (
Index("ix_notes_tags", "tags", postgresql_using="gin"),
@@ -97,7 +98,7 @@ class Note(Base, TimestampMixin):
),
"is_task": self.is_task,
"note_type": self.entity_type,
"metadata": self.metadata or {},
"metadata": self.entity_meta or {},
"created_at": self.created_at.isoformat(),
"updated_at": self.updated_at.isoformat(),
}