fix(db): fix health_check coroutine and raw SQL string#63
Conversation
- Replace 'async with self.get_session()' with 'async with self.session_factory()' to avoid RuntimeWarning: coroutine was never awaited - Wrap raw SQL with text() for SQLAlchemy 2.0 compatibility Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
|||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||||
User description
Summary
RuntimeWarning: coroutine 'DatabaseManager.get_session' was never awaitedin backend logsasync with self.get_session()was using a coroutine as a context manager — replaced withself.session_factory()directly"SELECT 1"withtext()for SQLAlchemy 2.0 compatibilityResult
Backend startup logs are now clean — no warnings.
🤖 Generated with Claude Code
PR Type
Bug fix
Description
Fixes RuntimeWarning by replacing coroutine with session factory
Wraps raw SQL string with text() for SQLAlchemy 2.0 compatibility
Eliminates backend startup log warnings
Diagram Walkthrough
File Walkthrough
database.py
Fix health_check coroutine and SQL string issuesjournal-platform-backend/app/core/database.py
async with self.get_session()withasync withself.session_factory()to avoid coroutine RuntimeWarning"SELECT 1"withtext()for SQLAlchemy 2.0compatibility
textfrom sqlalchemy module