mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-10 13:37:01 +03:00
Fix distinct query on postgres
This commit is contained in:
@@ -72,6 +72,15 @@ export class Sqlite implements IDatabase {
|
||||
}
|
||||
|
||||
private static processQuery(query: string): string {
|
||||
if (query.includes("DISTINCT ON")) {
|
||||
const column = query.match(/DISTINCT ON \((.*)\) (.*)/)[1];
|
||||
query = query.replace(/DISTINCT ON \((.*)\)/g, "");
|
||||
|
||||
const parts = query.split("ORDER BY");
|
||||
|
||||
query = `${parts[0]} GROUP BY ${column} ORDER BY ${parts[1]}`;
|
||||
}
|
||||
|
||||
return query.replace(/ ~\* /g, " REGEXP ");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user