diff options
author | Sean Molenaar <sean@seanmolenaar.eu> | 2021-02-16 21:17:10 +0100 |
---|---|---|
committer | Sean Molenaar <SMillerDev@users.noreply.github.com> | 2021-02-20 13:57:09 +0100 |
commit | 4a107b3d53c4fe651ac704251b99e04a53cd587f (patch) | |
tree | 9700c89992f1ad739023d73fcd434250c323089e /lib/Db | |
parent | 01e1db329ced43323654990828744d577cac4ba8 (diff) |
General: Fix folder query
Signed-off-by: Sean Molenaar <sean@seanmolenaar.eu>
Diffstat (limited to 'lib/Db')
-rw-r--r-- | lib/Db/ItemMapperV2.php | 15 | ||||
-rw-r--r-- | lib/Db/ListType.php | 16 |
2 files changed, 18 insertions, 13 deletions
diff --git a/lib/Db/ItemMapperV2.php b/lib/Db/ItemMapperV2.php index cfd30b75e..1ef9da244 100644 --- a/lib/Db/ItemMapperV2.php +++ b/lib/Db/ItemMapperV2.php @@ -12,6 +12,7 @@ namespace OCA\News\Db; +use OC\DB\QueryBuilder\Literal; use OCA\News\Service\Exceptions\ServiceValidationException; use Doctrine\DBAL\FetchMode; use OCA\News\Utility\Time; @@ -386,12 +387,14 @@ class ItemMapperV2 extends NewsMapperV2 ->addOrderBy('items.id', 'DESC'); switch ($feedType) { - case FeedType::STARRED: + case ListType::STARRED: $builder->andWhere('items.starred = 1'); break; - case FeedType::UNREAD: + case ListType::UNREAD: $builder->andWhere('items.unread = 1'); break; + case ListType::ALL_ITEMS: + break; default: throw new ServiceValidationException('Unexpected Feed type in call'); } @@ -473,7 +476,7 @@ class ItemMapperV2 extends NewsMapperV2 if ($folderId === null) { $folderWhere = $builder->expr()->isNull('feeds.folder_id'); } else { - $folderWhere = $builder->expr()->eq('feeds.folder_id', $folderId); + $folderWhere = $builder->expr()->eq('feeds.folder_id', new Literal($folderId), IQueryBuilder::PARAM_INT); } $builder->select('items.*') @@ -542,12 +545,14 @@ class ItemMapperV2 extends NewsMapperV2 } switch ($type) { - case FeedType::STARRED: + case ListType::STARRED: $builder->andWhere('items.starred = 1'); break; - case FeedType::UNREAD: + case ListType::UNREAD: $builder->andWhere('items.unread = 1'); break; + case ListType::ALL_ITEMS: + break; default: throw new ServiceValidationException('Unexpected Feed type in call'); } diff --git a/lib/Db/ListType.php b/lib/Db/ListType.php index 1ccd592a8..e96e29ed6 100644 --- a/lib/Db/ListType.php +++ b/lib/Db/ListType.php @@ -18,13 +18,13 @@ namespace OCA\News\Db; * * @package OCA\News\Db */ -class FeedType +class ListType { - const FEED = 0; - const FOLDER = 1; - const STARRED = 2; - const SUBSCRIPTIONS = 3; - const SHARED = 4; - const EXPLORE = 5; - const UNREAD = 6; + const FEED = 0; + const FOLDER = 1; + const STARRED = 2; + const ALL_ITEMS = 3; + const SHARED = 4; + const EXPLORE = 5; + const UNREAD = 6; } |