使用sqlc生成db方法。有以下查询
-- name: RemoveRows:exec
DELETE FROM demotable
WHERE last_updated < (CURRENT_TIMESTAMP - INTERVAL '30' SECOND);
我想传递30
作为参数,但我使用了下面的查询,然后引号不来,数据库给出错误。
-- name: RemoveRows:exec
DELETE FROM demotable
WHERE last_updated < (CURRENT_TIMESTAMP - INTERVAL $1 SECOND);
尝试引用$1
,但sqlc认为它是字符串
-- name: RemoveRows:exec
DELETE FROM demotable
WHERE last_updated < (CURRENT_TIMESTAMP - INTERVAL '$1' SECOND);
1条答案
按热度按时间s4n0splo1#
或者,与其在尝试欺骗类型系统时瞎忙,不如直接做