[rt-devel] SearchBuilder DISTINCTs

Jesse Vincent jesse at bestpractical.com
Thu Feb 20 13:25:28 EST 2003



On Thu, Feb 20, 2003 at 12:17:05PM -0600, Matt Knopp wrote:
> 
> Dude! It's like rocket surgery! No really! Add a LimitDistinctP() method to 
> SearchBuilder which sets an instance variable, say 'UseDistinctP'. Then in 
> _DoSearch change: 
> 
>   $QueryString = 
>     "SELECT DISTINCT main.* FROM " . $self->_TableAliases . " "; 
> 
> To something like: 
> 
>   $QueryString = 
>     "SELECT " . ($this->{'UseDistinctP'} ? "DISTINCT" : "") .
>     " main.* from " . $self->_TableAliases . " "; 


This is a somewhat shortsighted way to do this stuff, since different
databases have different needs, which is why I recommended a proper
refactoring.
> 
> Sure, it requires the SB user to know that they want distinct values, but 
> really that's okay. It's worse to force distinct values on someone who may
> not have expected it. 

It's a core assumption of how the SearchBuilder OO-RDBMS mapper works.
SearchBuilder is not about returning a bunch of possibly redundant
database rows. it's about finding the set of objects that match the
query.


> -Matt
> 
> _______________________________________________
> rt-devel mailing list
> rt-devel at lists.fsck.com
> http://lists.fsck.com/mailman/listinfo/rt-devel

-- 
http://www.bestpractical.com/rt  -- Trouble Ticketing. Free.



More information about the Rt-devel mailing list