Skip to content
Advertisement

SQLAlchemy SQL expression with JSONB query

I have the following property on a flask-sqlalchemy model. I want to make this approved_at property a sortable column in flask-admin, but apparently I need to convert this to a hybrid property using SQL expressions.

JavaScript

I don’t know how to convert this query into a sqlalchemy SQL expression, since it’s pretty complex with the JSONB query in it. I’ve looked at all the other SO answers, haven’t been able to figure it out.

Can I get some help on how to do this? Or alternatively, how to make a sortable column in Flask Admin that doesn’t require me to use hybrid expressions?

Advertisement

Answer

Implementing it as a hybrid is somewhat straightforward:

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement