Spellcheck (jawnsy++)
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Storage / DBI / AmbiguousGlob.pm
CommitLineData
efe2cc83 1package DBIx::Class::Storage::DBI::AmbiguousGlob;
2
3use strict;
4use warnings;
5
6use base 'DBIx::Class::Storage::DBI';
2ad62d97 7use mro 'c3';
efe2cc83 8
9=head1 NAME
10
0ab9c084 11DBIx::Class::Storage::DBI::AmbiguousGlob - Storage component for RDBMS choking on count(*)
efe2cc83 12
13=head1 DESCRIPTION
14
15Some servers choke on things like:
16
17 COUNT(*) FROM (SELECT tab1.col, tab2.col FROM tab1 JOIN tab2 ... )
18
19claiming that col is a duplicate column (it loses the table specifiers by
20the time it gets to the *). Thus for any subquery count we select only the
21primary keys of the main table in the inner query. This hopefully still
22hits the indexes and keeps the server happy.
23
c1300297 24At this point the only overridden method is C<_subq_count_select()>
efe2cc83 25
26=cut
27
618a0fe3 28sub _subq_count_select {
29 my ($self, $source, $rs_attrs) = @_;
0ce4ab92 30
31 return $rs_attrs->{group_by} if $rs_attrs->{group_by};
32
618a0fe3 33 my @pcols = map { join '.', $rs_attrs->{alias}, $_ } ($source->primary_columns);
34 return @pcols ? \@pcols : [ 1 ];
efe2cc83 35}
36
37=head1 AUTHORS
38
39See L<DBIx::Class/CONTRIBUTORS>
40
41=head1 LICENSE
42
43You may distribute this code under the same terms as Perl itself.
44
45=cut
46
471;