我正在尝试在函数中使用 where 宏:
(defentity student
(pk :id)
(table :student)
(entity-fields :id :name :age :class)
(database prod))
(defn query-student [cond]
(select student
(where cond)))
我测试它:
(select student
(where {:age [> 13]}))
(query-student '{:age [> 13]})
看起来不错,但这
(select student
(where (or {:age [> 13]} {:class [in ["1" "2" "3"]]})))
(query-student '(or {:age [> 13]} {:class [in ["1" "2" "3"]]}))
不工作!
Failure to execute query with SQL:
SELECT "student".* FROM "student" WHERE (or {:age [> 13]} {:class [in ["1" "2" "3"]]}) :: []
PSQLException:
Message: ERROR: syntax error at or near "or"
Location:42
SQLState: 42601
Error Code: 0
PSQLException ERROR: syntax error at or near "or"
Location:42 org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse (QueryExecutorImpl.java:2101)
我想知道为什么?有问题?