At the end of this section it is mentioned that:
While the SQL generated in these examples looks the same whether we
invokeselect(user_table)
orselect(User)
, in the more general case
they do not necessarily render the same thing, as an ORM-mapped class
may be mapped to other kinds of “selectables” besides tables. The
select()
that’s against an ORM entity also indicates that ORM-mapped
instances should be returned in a result, which is not the case when
SELECTing from a Table object.
Now I wonder if the following is a bad practice:
stmt = (
select(User, user_tree_table)
.join(
user_tree_table,
User.id == user_tree_table.c.descendant
)
)
I could not find any example that mix them together.
By the way, the user_tree_table
is a closure table and it is really hard or impossible to use the relationship()
here.