diff options
| author | 2025-05-13 22:28:34 +0200 | |
|---|---|---|
| committer | 2025-05-13 22:28:34 +0200 | |
| commit | 459ede2b7ebcbbc85135c65991768334b460358e (patch) | |
| tree | 77b482941085623b05408d55b0f06d3b33e53e3f | |
| parent | b401f152ca6256b19995e4e5e0e030961663ecc5 (diff) | |
Fix SQL request for user labels with custom sort (#7588)
The list or articles with a user label with a custom sort was broken when using PostgreSQL
Example: `https://freshrss.example.net/i/?a=normal&get=T&sort=title&order=ASC`
```
SQL error FreshRSS_EntryDAO::listWhereRaw["42P10",7,"ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list\nLINE 3: ...d_entry = e.id WHERE 1=1 AND e.id <= $1 ORDER BY e.title DE...\n ^"]
```
| -rw-r--r-- | app/Models/EntryDAO.php | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php index f9dc9fd82..af859045d 100644 --- a/app/Models/EntryDAO.php +++ b/app/Models/EntryDAO.php @@ -1318,7 +1318,9 @@ SQL; return [array_merge($values, $searchValues), 'SELECT ' . ($type === 'T' ? 'DISTINCT ' : '') - . 'e.id FROM `_entry` e ' + . 'e.id' + . ($type === 'T' && $orderBy !== 'e.id' ? ', ' . $orderBy : '') // SELECT DISTINCT, ORDER BY expressions must appear in SELECT + . ' FROM `_entry` e ' . 'INNER JOIN `_feed` f ON e.id_feed = f.id ' . ($type === 't' || $type === 'T' ? 'INNER JOIN `_entrytag` et ON et.id_entry = e.id ' : '') . 'WHERE ' . $where |
