additional = None
return u'<Test {0}>'.format(self.id)db.session.query(Test).from_statement("SELECT test.id AS test_id, test.subject AS test_subject, 99 AS additional FROM test")
我使用了与the one recommended in the SqlAlchemy documentation非常相似的自定义类型表单this answer,让我在这里复制它来回答一个自包含的问题:事情按预期运行,方法process_result_value运行,我的datetime对象随UTC tzinfo一起提供。但是,如果我像这样查询: db.query(User).from_statement(text("SELECT * from table where ...")).fi