Avoid alias when matching FTS table

This commit is contained in:
Jordan Wages 2025-09-18 22:31:52 -05:00
commit 6d00906fc9

View file

@ -877,8 +877,8 @@
const searchSql = {
rank: `
SELECT t.id, a.name AS artist, t.title, IFNULL(al.title, '') AS album, t.year, t.genre
FROM fts_tracks f
JOIN tracks t ON t.id = f.rowid
FROM fts_tracks
JOIN tracks t ON t.id = fts_tracks.rowid
JOIN artists a ON a.id = t.artist_id
LEFT JOIN albums al ON al.id = t.album_id
WHERE fts_tracks MATCH ?
@ -887,8 +887,8 @@
`,
alpha: `
SELECT t.id, a.name AS artist, t.title, IFNULL(al.title, '') AS album, t.year, t.genre
FROM fts_tracks f
JOIN tracks t ON t.id = f.rowid
FROM fts_tracks
JOIN tracks t ON t.id = fts_tracks.rowid
JOIN artists a ON a.id = t.artist_id
LEFT JOIN albums al ON al.id = t.album_id
WHERE fts_tracks MATCH ?
@ -898,8 +898,8 @@
};
const countSql = `
SELECT COUNT(*) AS count
FROM fts_tracks f
JOIN tracks t ON t.id = f.rowid
FROM fts_tracks
JOIN tracks t ON t.id = fts_tracks.rowid
JOIN artists a ON a.id = t.artist_id
LEFT JOIN albums al ON al.id = t.album_id
WHERE fts_tracks MATCH ?
@ -1102,8 +1102,8 @@
const ftsCountSql = `
SELECT COUNT(*) AS count FROM (
SELECT a.id
FROM fts_tracks f
JOIN tracks t ON t.id = f.rowid
FROM fts_tracks
JOIN tracks t ON t.id = fts_tracks.rowid
JOIN artists a ON a.id = t.artist_id
WHERE fts_tracks MATCH ?
GROUP BY a.id
@ -1111,8 +1111,8 @@
`;
const ftsRowsSql = `
SELECT a.id, a.name
FROM fts_tracks f
JOIN tracks t ON t.id = f.rowid
FROM fts_tracks
JOIN tracks t ON t.id = fts_tracks.rowid
JOIN artists a ON a.id = t.artist_id
WHERE fts_tracks MATCH ?
GROUP BY a.id