conn.prepareStatement("""
merge into items i
using (select cast(? as int) as feed_id, cast(? as varchar) as title, cast(? as varchar) as link, cast(? as varchar) as category, cast(? as varchar) as description, cast(? as varchar) as author, cast(? as timestamp) as pub_date, cast(? as timestamp) as updated, cast(? as varchar) as guid, cast(? as clob) as contentText, cast(? as clob) as contentHtml) v
- on (i.feed_id = v.feed_id and i.guid = v.guid and coalesce(i.updated, i.pub_date, '1970-01-01') = coalesce(v.updated, v.pub_date, '1970-01-01'))
+ on (i.feed_id = v.feed_id and coalesce(i.guid, concat(i.link, cast(coalesce(i.pub_date, i.updated) as varchar))) = coalesce(v.guid, concat(v.link, cast(coalesce(v.pub_date, v.updated) as varchar))) and coalesce(i.updated, i.pub_date, '1970-01-01') = coalesce(v.updated, v.pub_date, '1970-01-01'))
when matched then
update set
i.title = v.title,