1 package DBIx::Class::Storage::DBI::MultiDistinctEmulation;
6 use base qw/DBIx::Class::Storage::DBI/;
9 my ($self, $ident, $select, $condition, $attrs) = @_;
11 # hack to make count distincts with multiple columns work in SQLite and Oracle
12 if (ref $select eq 'ARRAY') {
13 @{$select} = map {$self->replace_distincts($_)} @{$select};
15 $select = $self->replace_distincts($select);
18 return $self->next::method($ident, $select, $condition, $attrs);
21 sub replace_distincts {
22 my ($self, $select) = @_;
24 $select->{count}->{distinct} = join("||", @{$select->{count}->{distinct}})
25 if (ref $select eq 'HASH' && $select->{count} && ref $select->{count} eq 'HASH' &&
26 $select->{count}->{distinct} && ref $select->{count}->{distinct} eq 'ARRAY');
35 DBIx::Class::Storage::DBI::MultiDistinctEmulation - Some databases can't handle count distincts with multiple cols. They should use base on this.
41 This class allows count distincts with multiple columns for retarded databases (Oracle and SQLite)
45 Luke Saunders <luke.saunders@gmail.com>
49 You may distribute this code under the same terms as Perl itself.