【发布时间】:2018-04-17 11:08:42
【问题描述】:
当我从具有多个关系的表中选择特定字段时,我会收到如下异常:org.postgresql.util.PSQLException: ERROR: missing FROM-clause entry for table \"bar\"
这是我定义的关系:
(declare foo bar)
(korma/defentity foo
(korma/pk :token)
(korma/database db)
(korma/table :foo)
(korma/has-many bar {:fk :token}))
(korma/defentity bar
(korma/pk :token)
(korma/database db)
(korma/table :bar)
(korma/belongs-to foo {:fk :token}))
这是我在 sqlkorma 中生成的查询:
(defn fetch []
(->
(korma/select* foo)
(korma/with bar)
(korma/fields :foo.token :bar.col)
(korma/exec)))
如果我选择使用 * 的所有字段,则查询运行没有问题。但是,我想指定我要选择哪些字段,我做错了什么?
【问题讨论】: