我無法從我在Korma中映射的實體中選擇SELECT COUNT(*)
。無法爲默認字段的Korma實體選擇COUNT(*)
這裏是我的實體:
(declare users responses) (korma/defentity users (korma/entity-fields :id :slack_id :active :token :token_created) (korma/many-to-many responses :userresponses))
這裏是我在嘗試SELECT COUNT(*)
:
(korma/select schema/users (korma/fields ["count(*)"]) (korma/where {:slack_id slack-id}))
我得到這個錯誤:
ERROR: column "users.id" must appear in the GROUP BY clause or be used in an aggregate function at character 8 STATEMENT: SELECT "users"."id", "users"."slack_id", "users"."active", "users"."token", "users"."token_created", count(*) FROM "users" WHERE ("users"."slack_id" = $1)
即使我在此查詢中指定要選擇的字段,它看起來像Korma包含我的實體字段。我如何覆蓋它?
http://stackoverflow.com/questions/25825252/restricting-select-fields-with-korma是模糊相似,但涉及「(select)」的默認行爲,沒有指定字段。 – fzzfzzfzz