1

我正在尝试对NULL特定搜索和返回索引重用查询(基本上实现了这里讨论的想法http://dev.solita.fi/2015/12/29/SQL-in-applications.html)。但是,我ERROR: could not determine data type of parameter $1随时尝试将函数体与[]参数一起使用。

这是clojure

(defn get-ips
  "Get a list of IPs and their User Ids"
  ([] (ip-addresses {:uids nil}))
  ([uids] (ip-addresses {:uids uids})))

这是sql

-- name: ip-addresses
SELECT ipo.ip_address_id::varchar as address, ipo.user_id
FROM ip_ownerships AS ipo
WHERE :uids IS NULL OR ipo.user_id IN (:uids)
4

1 回答 1

1

所以我才找到答案。解决方案是手动转换参数的类型:

-- name: ip-addresses
SELECT ipo.ip_address_id::varchar as address, ipo.user_id
FROM ip_ownerships AS ipo
WHERE :uids::int IS NULL OR ipo.user_id IN (:uids)
于 2018-06-19T20:10:51.790 回答