fix: _default_env_id uses scalars().first() instead of scalar_one_or_none()
scalar_one_or_none() raises MultipleResultsFound when more than one environment exists. Use scalars().first() to pick the lowest-ID environment as the default. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
a9ef13afa8
commit
e0b898df8e
1 changed files with 1 additions and 1 deletions
|
|
@ -125,7 +125,7 @@ async def _get_env_or_404(db: AsyncSession, env_id: int) -> Environment:
|
||||||
|
|
||||||
|
|
||||||
async def _default_env_id(db: AsyncSession) -> int | None:
|
async def _default_env_id(db: AsyncSession) -> int | None:
|
||||||
e = (await db.execute(select(Environment).order_by(Environment.id))).scalar_one_or_none()
|
e = (await db.execute(select(Environment).order_by(Environment.id))).scalars().first()
|
||||||
return e.id if e else None
|
return e.id if e else None
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue