Fix QA review warnings: model server_default, calendar_id coercion

- EventTemplate model: add server_default=func.now() to created_at
  to match migration 011 and prevent autogenerate drift
- CalendarPage: use nullish coalescing for template calendar_id
  instead of || 0 which produced an invalid falsy ID

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Kyle 2026-02-23 13:50:31 +08:00
parent f64e181fbe
commit 27003374e3
2 changed files with 3 additions and 3 deletions

View File

@ -1,4 +1,4 @@
from sqlalchemy import String, Text, Boolean, ForeignKey, Integer
from sqlalchemy import String, Text, Boolean, ForeignKey, Integer, func
from sqlalchemy.orm import Mapped, mapped_column
from datetime import datetime
from typing import Optional
@ -21,4 +21,4 @@ class EventTemplate(Base):
Integer, ForeignKey("locations.id", ondelete="SET NULL"), nullable=True
)
is_starred: Mapped[bool] = mapped_column(Boolean, default=False)
created_at: Mapped[datetime] = mapped_column(default=datetime.now)
created_at: Mapped[datetime] = mapped_column(default=datetime.now, server_default=func.now())

View File

@ -297,7 +297,7 @@ export default function CalendarPage() {
title: template.title,
description: template.description || '',
all_day: template.all_day,
calendar_id: template.calendar_id || 0,
calendar_id: template.calendar_id ?? undefined,
location_id: template.location_id || undefined,
is_starred: template.is_starred,
recurrence_rule: template.recurrence_rule || undefined,