SQLAlchemy patterns — engine setup, session management, declarative models,
98
99%
Does it follow best practices?
Impact
98%
1.96xAverage score across 5 eval scenarios
Passed
No known issues
{
"context": "Tests whether the agent proactively applies SQLAlchemy 2.0 patterns, session best practices, eager loading, and cascade configuration when building a blog platform. The task says nothing about DeclarativeBase, Mapped types, eager loading strategy, or cascade rules.",
"type": "weighted_checklist",
"checklist": [
{
"name": "DeclarativeBase used (not declarative_base)",
"description": "Base class inherits from DeclarativeBase, not the legacy declarative_base() factory. The task did not specify SQLAlchemy version.",
"max_score": 10
},
{
"name": "Mapped types used (not Column)",
"description": "All model columns use Mapped[type] = mapped_column(...), not legacy Column().",
"max_score": 10
},
{
"name": "expire_on_commit=False",
"description": "sessionmaker configured with expire_on_commit=False. The agent was NOT warned about DetachedInstanceError.",
"max_score": 10
},
{
"name": "Pool configuration complete",
"description": "Engine specifies pool_pre_ping=True, pool_size, max_overflow, and pool_recycle. The agent was NOT asked about pool tuning.",
"max_score": 12
},
{
"name": "Eager loading on get_published_posts",
"description": "The get_published_posts query uses selectinload or joinedload to load authors without N+1 queries. The task said 'with their authors loaded' but did not mention eager loading strategy.",
"max_score": 14
},
{
"name": "cascade='all, delete-orphan' on parent relationships",
"description": "Author.posts and Post.comments relationships use cascade='all, delete-orphan'.",
"max_score": 10
},
{
"name": "ondelete='CASCADE' on ForeignKeys",
"description": "Post.author_id and Comment.post_id ForeignKeys include ondelete='CASCADE'.",
"max_score": 8
},
{
"name": "back_populates used (not backref)",
"description": "All relationships use back_populates for explicit bidirectional linking.",
"max_score": 6
},
{
"name": "select() API used",
"description": "Queries use select() with db.execute(), not legacy db.query().",
"max_score": 8
},
{
"name": "Database URL from environment",
"description": "Database URL read from os.getenv or os.environ, not hardcoded.",
"max_score": 6
},
{
"name": "Session yield/finally cleanup",
"description": "Session dependency uses yield with finally for cleanup.",
"max_score": 6
}
]
}