From: Olaf Wintermann Date: Mon, 1 Sep 2025 18:46:34 +0000 (+0200) Subject: allow items with the same guid X-Git-Url: https://uap-core.de/gitweb/?a=commitdiff_plain;h=912bd67493576a14efc507171bb046966e2f2579;p=rssreader.git allow items with the same guid --- 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()