summaryrefslogtreecommitdiff
path: root/app/Models/EntryDAOPGSQL.php
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2017-08-16 22:09:28 +0200
committerGravatar GitHub <noreply@github.com> 2017-08-16 22:09:28 +0200
commited4953a1cd8438a3310332f05e335954272a4318 (patch)
tree335f7516a39eb7a5479d75d2da9673c48603b3b4 /app/Models/EntryDAOPGSQL.php
parentda685f9390b8bfa1193c9d335d36f3648c17fe7e (diff)
parentc23fd7782f4ea20bf7693a86c4d859a7520b01bc (diff)
Merge pull request #1613 from Trim/fix-postgresql-commitnewentry-by-ignore
commitNewEntries should ignore conflicting keys on migration from ent…
Diffstat (limited to 'app/Models/EntryDAOPGSQL.php')
-rw-r--r--app/Models/EntryDAOPGSQL.php5
1 files changed, 4 insertions, 1 deletions
diff --git a/app/Models/EntryDAOPGSQL.php b/app/Models/EntryDAOPGSQL.php
index b25993c47..6e6f9e658 100644
--- a/app/Models/EntryDAOPGSQL.php
+++ b/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 etmp
+ WHERE NOT EXISTS (SELECT 1 FROM `' . $this->prefix . 'entry` AS ereal WHERE etmp.id_feed = ereal.id_feed AND etmp.guid = ereal.guid)
+ ORDER BY date);
DELETE FROM `' . $this->prefix . 'entrytmp` WHERE id <= maxrank;
END $$;';
$hadTransaction = $this->bd->inTransaction();