mirror of
https://github.com/johrpan/musicus_mobile.git
synced 2025-10-26 18:57:25 +01:00
Database: Fix worksByComposer
While the previous code was indeed valid SQL is wasn't the best way to do this. Also, only works with parts where included in the result set. This is fixed now. Some optimization may still be neccessary.
This commit is contained in:
parent
2ee36aacf4
commit
7f783bd016
2 changed files with 7 additions and 13 deletions
|
|
@ -63,10 +63,10 @@ SELECT * FROM works WHERE id = :id LIMIT 1;
|
|||
workParts:
|
||||
SELECT * FROM works WHERE part_of = :id ORDER BY part_index;
|
||||
|
||||
-- TODO: Uncomment this once https://github.com/simolus3/moor/issues/453 is fixed.
|
||||
-- worksByComposer(:id AS INTEGER):
|
||||
-- SELECT DISTINCT A.* FROM works A, works B ON A.id = B.part_of
|
||||
-- WHERE A.composer = :id OR B.composer = :id;
|
||||
-- TODO: Maybe optimize.
|
||||
worksByComposer:
|
||||
SELECT DISTINCT A.* FROM works A LEFT JOIN works B ON A.id = B.part_of
|
||||
WHERE A.part_of IS NULL AND A.composer = :id OR B.composer = :id;
|
||||
|
||||
composersByWork:
|
||||
SELECT DISTINCT persons.* FROM persons
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue