From 912bd67493576a14efc507171bb046966e2f2579 Mon Sep 17 00:00:00 2001 From: Olaf Wintermann Date: Mon, 1 Sep 2025 20:46:34 +0200 Subject: [PATCH] allow items with the same guid --- .../src/main/kotlin/de/unixwork/rssreader/Database.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/rss-application/src/main/kotlin/de/unixwork/rssreader/Database.kt b/rss-application/src/main/kotlin/de/unixwork/rssreader/Database.kt index 3bdfd9f..862cf73 100644 --- a/rss-application/src/main/kotlin/de/unixwork/rssreader/Database.kt +++ b/rss-application/src/main/kotlin/de/unixwork/rssreader/Database.kt @@ -278,8 +278,9 @@ object Database { dataSource.connection.use { conn -> conn.prepareStatement(""" insert into items (feed_id, title, link, category, description, author, pub_date, updated, guid, contentText, contentHTML) - select ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? - where ? not in (select guid from items) + select ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? from dual + left join items I on I.guid = ? and I.feed_id = ? and coalesce(I.updated, I.pub_date, ?) = ? + where I.item_id is null """.trimIndent()).use { stmt -> items.forEach { item -> stmt.setInt(1, item.feedId) @@ -294,6 +295,10 @@ object Database { stmt.setString(10, item.contentText) stmt.setString(11, item.contentHtml) stmt.setString(12, item.guid) + stmt.setInt(13, item.feedId) + val itemDate = java.sql.Timestamp.valueOf(item.updated ?: item.pubDate ?: java.time.LocalDateTime.MIN) + stmt.setTimestamp(14, itemDate) + stmt.setTimestamp(15, itemDate) stmt.addBatch() } stmt.executeBatch() -- 2.47.3