clojure - korma 的选择字段功能不拒绝列?

标签 clojure sqlite korma sqlkorma

我在 windows 上使用 sqlite3 数据库玩弄 clojure 及其 korma 库。我以 7web 书为例。它介绍了select*函数及其 friend 。

但是使用 fields函数添加字段而不是限制。

;; models.clj
(defentity issue
  (entity-fields :id :project_id :title :description :status)
  (has-many comment))

;; repl
test=> (-> (select* issue)
  #_=>     (fields :title)
  #_=>     (as-sql))
"SELECT \"issue\".\"id\", \"issue\".\"project_id\", \"issue\".\"title\", \"issue\".\"description\", \"issue\".\"status\", \"issue\".\"title\" FROM \"issue\""

我错过了什么吗?

最佳答案

如问题 #251 中所述原因是 entity-fields表达。它定义了查询的默认字段。 fields函数将更多字段添加到默认值。按设计工作。

因此我删除了 entity-fieldsdefentity 内.

;; models.clj
(defentity issue
  (has-many comment))

;; repl
test=> (-> (select* issue)
  #_=>     (fields :title)
  #_=>     (as-sql))
"SELECT \"issue\".\"title\" FROM \"issue\""
test=> (-> (select* issue)
  #_=>     (as-sql))
"SELECT \"issue\".* FROM \"issue\""

关于clojure - korma 的选择字段功能不拒绝列?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30424533/

相关文章:

clojure - clj-pdf 中的模板

vector - Clojure:将嵌套向量格式应用于展平向量

performance - Clojure: "transpose"有效地是一个中等大小的 map 列表

c# - 如何在 SQLite 中设置自动时间戳?

clojure - 将计算列添加到 Korma 中的查询结果

clojure - 每个环境的Clojure数据库设置

.net - 如何根据客户端架构动态加载x86/x64版本的SQLite3.DLL?

android - 在sqlite中以树结构从数据库中获取数据

postgresql - 尝试为 Clojure/Korma/PostgreSQL 站点创建用户登录

postgresql - 如何通过比较 SqlKorma (clojure) 中的两个字段来创建 where 子句