Refs #4594 - Adds ability to remove DISTINCT modifier from SQL by passing 'distinct' => false in $options. That does not fix the ticket, but gives ability to optimize queries without breaking compatibility.