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