Filtering duplicates in this way here works as expected:
woome_app=# select distinct on (ws.id) ws.id, sm.person_id from
webapp_session ws join sessionmeeting_meeting sm on ws.id =
sm.session_id where sm.person_id = 45;
id | person_id
-------+-----------
62577 | 45
62588 | 45
66598 | 45
74521 | 45
(4 rows)
Wrapping this query into a view like so:
create view fubar as select distinct on (ws.id) ws.id, sm.person_id from
webapp_session ws join sessionmeeting_meeting sm on ws.id = sm.session_id;
And applying the same filter to it as above, I get:
woome_app=# select id, person_id from fubar where person_id = 45;
id | person_id
-------+-----------
62577 | 45
62588 | 45
(2 rows)
i.e. it appears to drop 2 rows it shouldn't. Did I find a bug or can
anyone explain why this behaviour might be expected?
Frank