Open
Description
Related to #274 - read this first.
In the case of browsing on a multiple-value field (eg. creators_id), perform_distinctby seems to produce some SQL that will always include NULL values:
SELECT
`distinctby_126264504`.`creators_id` AS D0,
`distinctby_126264504`.`eprintid` AS D1
FROM
`eprint`,
`eprint_creators_id` AS `distinctby_126264504`,
`eprint_creators_id` AS `eprint_creators_id`
WHERE
`eprint`.`eprintid`=`distinctby_126264504`.`eprintid`
AND
`eprint`.`eprintid`=`eprint_creators_id`.`eprintid`
AND
(`eprint`.`metadata_visibility` = 'show' AND `eprint`.`eprint_status` = 'archive' AND ( `eprint_creators_id`.`creators_id` != ''))
This is joining eprint to eprint_creators_id (aliased as distinctby_126264504) and then again to eprint_creators_id. If there is a NULL value in eprint_creators_id this will always appear in the resulting join (the query filters on eprint_creators_id
.creators_id
!= '' but not distinctby_126264504
.creators_id
!= '').
Debugging exactly where this seemingly incorrect SQL is produced will be difficult.