How to make peewee ORM return custom fields conversions from CTE?

  peewee, python

I’m trying to use the recursive CTE from Peewee ORM that returns the same field types as a non-recursive query.

According to the Peewee docs, you use the select_from method, with columns from the previous query, like this:

query = (cte
         .select_from(, cte.c.level, cte.c.path)

My query basically works. However, my table uses a couple of custom field types. When using regular query those fields are converted by the field to objects as defined in the python_value method. But when using the CTE query those values come as the raw database type, not converted by the custom field method.

Is there a way to tell the query to use the field conversion?

I tried .select_from(cte.c.myfield.convert(MyEnum), ...), but that doesn’t work.

Source: Python Questions