Skip to content

recommended way to eagerly load object relationship retrieved via complex query ? #6126

Discussion options

You must be logged in to vote

Hi -

you can map to that limit query using the "relationship to aliased class" feature, then make a relationship to that. If your database supports window functions (all the major DBs do now), you can use the recipe at https://docs.sqlalchemy.org/en/14/orm/join_conditions.html#row-limited-relationships-with-window-functions directly which will allow all kinds of eager loading such as "selectinload" to work as expected.

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@gerazenobi
Comment options

@zzzeek
Comment options

@gerazenobi
Comment options

@zzzeek
Comment options

@gerazenobi
Comment options

Answer selected by gerazenobi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #6125 on March 24, 2021 15:50.