diff --git a/sqlalchemy_utils/functions.py b/sqlalchemy_utils/functions.py index e6a5127..bb19f03 100644 --- a/sqlalchemy_utils/functions.py +++ b/sqlalchemy_utils/functions.py @@ -411,6 +411,27 @@ def batch_fetch(entities, *attr_paths): users = session.query(User).limit(20).all() batch_fetch(users, User.phonenumbers) + + + Function also accepts strings as attribute names: :: + + + users = session.query(User).limit(20).all() + + batch_fetch(users, 'phonenumbers') + + + Multiple attributes may be provided: :: + + + clubs = session.query(Club).limit(20).all() + + batch_fetch( + clubs, + 'teams', + 'teams.players', + 'teams.players.friends' + ) """ if entities: