Subject: | deep_search_distinct_where() Addition (Supports Distinct Queries) |
I wanted to use deep_search_where() but retrieve only distinct entries. While I noticed the "DISTINCT" directive in deep_search_where() it only does it for all fields. I wanted to do it for a particular field. Please take a look, and hopefully you will agree to add it! (See Patch)
Mark Rorabaugh (2RAD.net)
25a26,45
>
> return $class->sth_to_objects($class->sql_deeply_and_broadly($sql), $bind);
> }
>
> sub deep_search_distinct_where : Plugged
> {
> my $class = shift;
>
> my $distinct_item = shift;
>
> my $joins = {};
> $distinct_item = _transform_field($class, $joins, $distinct_item);
> my ($what, $from, $where, $bind) = $class->get_deep_where(@_);
>
> my $sql = <<"";
> SELECT DISTINCT $distinct_item
> FROM $from
> WHERE $where
>
>
307a328,339
> =head2 deep_search_where
>
> my @cds = Music::CD->deep_search_distinct_where( 'artist.address',
> {
> 'artist.name' => $artist_name
> }
> );
>
> deep_search_distinct_where() takes the field (in Class::DBI method
> format) that you wish to be distinct, and returns an iterator or array
> or Class::DBI objects that match the result.
>
331c363
< =cut
\ No newline at end of file
---
> =cut