我在golang
中的查询中传递字符串时遇到问题,这是我的尝试:
Exec(`UPDATE matches SET expected_completed_at= date + interval ? second WHERE match_id in (?);`,
duration, matchIDs)
持续时间类似于12544
,查询读取为UPDATE matches SET expected_completed_at= date + interval '12544' second WHERE match_id in (?)
,我想不带单引号读取它吗?
答案 0 :(得分:0)
查询中的显式强制转换应该起作用:
Exec(`
UPDATE matches
SET
expected_completed_at = date + (interval $1::integer second)
WHERE
match_id in ($2);
`, duration, matchIDs)