Because of the way Postgres handles negation with nulls (e.g. NOT IN), it's not possible to run a query like the following without a seeded entry in the Score table.
SELECT abstracts.*, speakers.full_name AS speaker,
speakers.email, events.name AS event_name
FROM abstracts, speakers, events, scores
WHERE ((abstracts.speaker_id = speakers.id)
AND (abstracts.event_id = events.id)
AND ((scores.abstract_id != abstracts.id)
OR (scores.judge != 'jdixon')))
ORDER BY abstracts.id
Demonstration showing a successful query when at least one Score exists. Note that it works for all users regardless of whether they have a score recorded or not.
I'd prefer to fix this somehow in the SQL, if possible. The alternative would be to handle the exclusion in application code by pulling Score.all separately and coalescing the results.
Because of the way Postgres handles negation with nulls (e.g.
NOT IN
), it's not possible to run a query like the following without a seeded entry in theScore
table.Demonstration showing a successful query when at least one
Score
exists. Note that it works for all users regardless of whether they have a score recorded or not.Demonstration showing failed queries when no scores exist.
One last time, proving that the simple existence of a
Score
is sufficient to workaround this issue.