Commit | Line | Data |
c0494fe1 |
1 | package DBIx::Class::CDBICompat::Iterator; |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
195dabc7 |
6 | |
d03c0706 |
7 | =head1 NAME |
8 | |
b24d86a1 |
9 | DBIx::Class::CDBICompat::Iterator - Emulates the extra behaviors of the Class::DBI search iterator. |
d03c0706 |
10 | |
11 | =head1 SYNOPSIS |
12 | |
13 | See DBIx::Class::CDBICompat for directions for use. |
14 | |
15 | =head1 DESCRIPTION |
16 | |
17 | Emulates the extra behaviors of the Class::DBI search iterator. |
18 | |
19 | =head2 Differences from DBIx::Class result set |
20 | |
21 | The CDBI iterator returns true if there were any results, false otherwise. The DBIC result set always returns true. |
22 | |
23 | =cut |
24 | |
25 | |
c0494fe1 |
26 | sub _init_result_source_instance { |
27 | my $class = shift; |
d4daee7b |
28 | |
c0494fe1 |
29 | my $table = $class->next::method(@_); |
30 | $table->resultset_class("DBIx::Class::CDBICompat::Iterator::ResultSet"); |
31 | |
32 | return $table; |
33 | } |
34 | |
35 | |
36 | |
37 | package DBIx::Class::CDBICompat::Iterator::ResultSet; |
38 | |
39 | use strict; |
40 | use warnings; |
41 | |
42 | use base qw(DBIx::Class::ResultSet); |
43 | |
44 | sub _bool { |
195dabc7 |
45 | # Performance hack so internal checks whether the result set |
46 | # exists won't do a SQL COUNT. |
47 | return 1 if caller =~ /^DBIx::Class::/; |
48 | |
49 | return $_[0]->count; |
c0494fe1 |
50 | } |
51 | |
52 | 1; |