我有一个类似于以下的查询:
User.objects.annotate(
x=Value(False, output_field=BooleanField()),
y=Value(True, output_field=BooleanField())
).annotate(
z=F('x').bitor(F('y')) # HOW TO DO THIS?
).values('z')
这段代码可以运行在SQLite数据库上,但无法在PostgreSQL上运行。出现了以下错误:
LINE 1: SELECT (false | true) AS "z" FROM "auth_user" LIMIT 21
^
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
如何在注释字段上实现逻辑或(OR)运算符以保持一致性?
谢谢。