Skip to content

Commit 6023b96

Browse files
committed
fix: [#190] SQL error in SQLite
The SQL query: ``` SELECT COUNT(*) as count FROM ( SELECT tt.torrent_id, tp.username AS uploader, tt.info_hash, ti.title, ti.description, tt.category_id, DATE_FORMAT(tt.date_uploaded, '%Y-%m-%d %H:%i:%s') AS date_uploaded, tt.size AS file_size, CAST(COALESCE(sum(ts.seeders), 0) as signed) as seeders, CAST(COALESCE(sum(ts.leechers), 0) as signed) as leechers FROM torrust_torrents tt INNER JOIN torrust_user_profiles tp ON tt.uploader_id = tp.user_id INNER JOIN torrust_torrent_info ti ON tt.torrent_id = ti.torrent_id LEFT JOIN torrust_torrent_tracker_stats ts ON tt.torrent_id = ts.torrent_id WHERE title LIKE ? GROUP BY tt.torrent_id ) AS count_table ``` should not use the `DATE_FORMAT` function in SQLite.
1 parent 8737e92 commit 6023b96

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/databases/sqlite.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ impl Database for Sqlite {
361361
};
362362

363363
let mut query_string = format!(
364-
"SELECT tt.torrent_id, tp.username AS uploader, tt.info_hash, ti.title, ti.description, tt.category_id, DATE_FORMAT(tt.date_uploaded, '%Y-%m-%d %H:%i:%s') AS date_uploaded, tt.size AS file_size,
364+
"SELECT tt.torrent_id, tp.username AS uploader, tt.info_hash, ti.title, ti.description, tt.category_id, tt.date_uploaded, tt.size AS file_size,
365365
CAST(COALESCE(sum(ts.seeders),0) as signed) as seeders,
366366
CAST(COALESCE(sum(ts.leechers),0) as signed) as leechers
367367
FROM torrust_torrents tt

0 commit comments

Comments
 (0)