1 package # hide from PAUSE
2 DBIx::Class::CDBICompat::Retrieve;
6 # even though fatalization has been proven over and over to be a universally
7 # bad idea, this line has been part of the code from the beginning
8 # leaving the compat layer as-is, something may in fact depend on that
9 use warnings FATAL => 'all';
11 use base 'DBIx::Class';
15 die "No args to retrieve" unless @_ > 0;
17 my @cols = $self->primary_columns;
20 if (ref $_[0] eq 'HASH') {
21 $query = { %{$_[0]} };
25 @{$query}{@cols} = @_;
31 $query = $self->_build_query($query);
37 my $query = ref $_[0] eq 'HASH' ? shift : {@_};
39 $query = $self->_build_query($query);
40 $self->next::method($query);
45 # Build a query hash. Defaults to a no-op; ColumnCase overrides.
48 my ($self, $query) = @_;
53 sub retrieve_from_sql {
54 my ($class, $cond, @rest) = @_;
56 $cond =~ s/^\s*WHERE//i;
58 # Need to parse the SQL clauses after WHERE in reverse
59 # order of appearance.
63 if( $cond =~ s/\bLIMIT\s+(\d+)\s*$//i ) {
67 if ( $cond =~ s/\bORDER\s+BY\s+(.*)\s*$//i ) {
68 $attrs{order_by} = $1;
71 if( $cond =~ s/\bGROUP\s+BY\s+(.*)\s*$//i ) {
72 $attrs{group_by} = $1;
75 return $class->search_literal($cond, @rest, ( %attrs ? \%attrs : () ) );
80 my $obj = $class->resultset_instance->new_result(@_);
86 sub retrieve_all { shift->search }
87 sub count_all { shift->count }
89 sub maximum_value_of {
90 my($class, $col) = @_;
91 return $class->resultset_instance->get_column($col)->max;
94 sub minimum_value_of {
95 my($class, $col) = @_;
96 return $class->resultset_instance->get_column($col)->min;