默认情况下,peewee为表分配t1
、t2
等名称
我试图在peewee中构建一些复杂的查询,所以我想对表名进行别名。在
让我们假设一个简单的例子:我们有一个表<MyTable>
,我怎么能得到这样的结果
select foo.id from MyTable as foo;
我尝试的是设置alias
,但看起来它是一个类方法,但它不起作用:
我找到了AliasMap
类,它被设置为QueryCompiler
中alias_map_class
类变量的默认值。另外,在QueryCompiler
中有alias
方法,但它是为了other目的而设计的:
The alias() method is used to create self-joins.
好吧,我得再深入研究一下documentation:
相关问题 更多 >
编程相关推荐