Pārlūkot izejas kodu

commitNewEntries should ignore conflicting keys on migration from entrytmp to entry

Fixes #1610 by first ignoring all entries from entrytmp which exists
already inside the entry table.
Adrien Dorsaz 8 gadi atpakaļ
vecāks
revīzija
3b8b9eabd0
1 mainītis faili ar 4 papildinājumiem un 1 dzēšanām
  1. 4 1
      app/Models/EntryDAOPGSQL.php

+ 4 - 1
app/Models/EntryDAOPGSQL.php

@@ -30,7 +30,10 @@ maxrank bigint := (SELECT MAX(id) FROM `' . $this->prefix . 'entrytmp`);
 rank bigint := (SELECT maxrank - COUNT(*) FROM `' . $this->prefix . 'entrytmp`);
 BEGIN
 	INSERT INTO `' . $this->prefix . 'entry` (id, guid, title, author, content, link, date, `lastSeen`, hash, is_read, is_favorite, id_feed, tags)
-		(SELECT rank + row_number() OVER(ORDER BY date) AS id, guid, title, author, content, link, date, `lastSeen`, hash, is_read, is_favorite, id_feed, tags FROM `' . $this->prefix . 'entrytmp` ORDER BY date);
+		(SELECT rank + row_number() OVER(ORDER BY date) AS id, guid, title, author, content, link, date, `lastSeen`, hash, is_read, is_favorite, id_feed, tags
+			FROM `' . $this->prefix . 'entrytmp` AS entrytmp
+			WHERE NOT EXISTS (SELECT 1 FROM `' . $this->prefix . 'entry` AS entry WHERE entrytmp.id_feed = entry.id_feed AND entrytmp.guid = entry.guid)
+			ORDER BY date);
 	DELETE FROM `' . $this->prefix . 'entrytmp` WHERE id <= maxrank;
 END $$;';
 		$hadTransaction = $this->bd->inTransaction();