From 15301cd7dc8f07c19665cabb07eabf99aa06a546 Mon Sep 17 00:00:00 2001 From: "J. King" Date: Wed, 5 Dec 2018 11:05:01 -0500 Subject: [PATCH] Fix cleanup tests in PostgreSQL --- lib/Database.php | 6 +++++- lib/Db/PostgreSQL/PDOStatement.php | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/Database.php b/lib/Database.php index 1373c9a..dc308d1 100644 --- a/lib/Database.php +++ b/lib/Database.php @@ -1219,11 +1219,15 @@ class Database { "SELECT id, (select count(*) from arsse_subscriptions where feed = arsse_feeds.id) as subs from arsse_feeds where id = ?". + "), latest_editions(article,edition) as (". + "SELECT article,max(id) from arsse_editions group by article". "), excepted_articles(id,edition) as (". "SELECT - arsse_articles.id, (select max(id) from arsse_editions where article = arsse_articles.id) as edition + arsse_articles.id as id, + latest_editions.edition as edition from arsse_articles join target_feed on arsse_articles.feed = target_feed.id + join latest_editions on arsse_articles.id = latest_editions.article order by edition desc limit ?". ") ". "DELETE from arsse_articles where diff --git a/lib/Db/PostgreSQL/PDOStatement.php b/lib/Db/PostgreSQL/PDOStatement.php index 450ebab..1658260 100644 --- a/lib/Db/PostgreSQL/PDOStatement.php +++ b/lib/Db/PostgreSQL/PDOStatement.php @@ -12,7 +12,7 @@ class PDOStatement extends \JKingWeb\Arsse\Db\AbstractStatement { const BINDINGS = [ "integer" => "bigint", "float" => "decimal", - "datetime" => "timestamp", + "datetime" => "timestamp(0) without time zone", "binary" => "bytea", "string" => "text", "boolean" => "smallint", // FIXME: using boolean leads to incompatibilities with versions of SQLite bundled prior to PHP 7.3