Can't resolve label reference for ORDER BY / GROUP BY. Textual SQL expression ' xxx desc ' should be explicitly declared as 报错

之前的写法:

1 Table.query.filter().order_by(" xxx desc ").all()

改成如下,加个 text(),问题解决

1 from sqlalchemy.sql import text
2 
3 
4 Table.query.filter().order_by(text(" xxx desc ")).all()
原文地址:https://www.cnblogs.com/whycai/p/12879250.html