Fix AsyncSession API: use execute() instead of exec()
All checks were successful
Build And Test / publish (push) Successful in 47s

SQLAlchemy's AsyncSession uses execute() + scalars(), not SQLModel's exec().

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-30 16:14:27 -08:00
parent 73d3ff4319
commit c2a4a1b0d0

View File

@@ -294,10 +294,10 @@ class EmailMonitor:
"""Seed the seen_emails table with existing emails on first run.""" """Seed the seen_emails table with existing emails on first run."""
async with get_session() as session: async with get_session() as session:
# Check if this mailbox has been seeded # Check if this mailbox has been seeded
result = await session.exec( result = await session.execute(
select(CacheMeta).where(CacheMeta.key == f"seeded_{mailbox}") select(CacheMeta).where(CacheMeta.key == f"seeded_{mailbox}")
) )
if result.first(): if result.scalars().first():
logger.debug(f"Mailbox {mailbox} already seeded") logger.debug(f"Mailbox {mailbox} already seeded")
return return
@@ -334,12 +334,12 @@ class EmailMonitor:
async def _is_email_seen(self, email_uid: str, mailbox: str) -> bool: async def _is_email_seen(self, email_uid: str, mailbox: str) -> bool:
"""Check if email has already been processed.""" """Check if email has already been processed."""
async with get_session() as session: async with get_session() as session:
result = await session.exec( result = await session.execute(
select(SeenEmail).where( select(SeenEmail).where(
SeenEmail.email_uid == email_uid, SeenEmail.mailbox == mailbox SeenEmail.email_uid == email_uid, SeenEmail.mailbox == mailbox
) )
) )
return result.first() is not None return result.scalars().first() is not None
async def _mark_as_seen( async def _mark_as_seen(
self, email: EmailSummary, mailbox: str, notification_sent: bool = False self, email: EmailSummary, mailbox: str, notification_sent: bool = False
@@ -367,12 +367,12 @@ class EmailMonitor:
): ):
"""Update the notification status for a seen email.""" """Update the notification status for a seen email."""
async with get_session() as session: async with get_session() as session:
result = await session.exec( result = await session.execute(
select(SeenEmail).where( select(SeenEmail).where(
SeenEmail.email_uid == email_uid, SeenEmail.mailbox == mailbox SeenEmail.email_uid == email_uid, SeenEmail.mailbox == mailbox
) )
) )
seen = result.first() seen = result.scalars().first()
if seen: if seen:
seen.notification_sent = success seen.notification_sent = success
seen.notification_sent_at = datetime.utcnow() if success else None seen.notification_sent_at = datetime.utcnow() if success else None