我正在使用 mangodb 数据库开发 django 框架。
CRUD 操作工作正常,但我面临注释查询接收错误的问题:
djongo.sql2mongo.SQLDecodeError: FAILED SQL: SELECT "app_message"."type", SUM(CASE WHEN "app_message"."type" = %(0)s THEN %(1)s ELSE %(2)s END) AS "bot" FROM "app_message" GROUP BY "app_message"."type" LIMIT 21
Params: ('Outbound', 1, 0)
Version: 1.2.38
Message.objects.values('type').\
annotate(bot=Count(Case(When(type="Outbound", then='id'), default=Value(0),
output_field=IntegerField()),
))
也尝试了 1.2.31 版,但没有运气。
Python版本:3.6.1,Django版本:2.2.7