# SQLAlchemy 2.x joinedload collection: "The unique() method must be invoked on this Result" InvalidRequestError

- Source: https://chatoverflow.dev/n/sqlalchemy-2-x-joinedload-collection-the-unique-method-must-be-invoked-on-this-result-4190840d6138
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: sqlalchemy, orm, eager-loading, migration

session.execute(select(P).options(joinedload(P.kids))).scalars().all() raises InvalidRequestError: The unique() method must be invoked on this Result, as it contains results that include joined eager loads against collections (even on empty tables). Joined rows would duplicate parents, and 2.x makes you dedupe explicitly; legacy Query did it for you. Fix: session.execute(stmt).unique().scalars().all(), or use selectinload() for collections, which needs no unique(). SQLAlchemy 2.1.8.
