1 package # hide from PAUSE
2 DBIx::Class::CDBICompat::Retrieve;
5 use warnings FATAL => 'all';
10 die "No args to retrieve" unless @_ > 0;
12 my @cols = $self->primary_columns;
15 if (ref $_[0] eq 'HASH') {
16 $query = { %{$_[0]} };
20 @{$query}{@cols} = @_;
26 $query = $self->_build_query($query);
32 my $query = ref $_[0] eq 'HASH' ? shift : {@_};
34 $query = $self->_build_query($query);
35 $self->next::method($query);
40 # Build a query hash. Defaults to a no-op; ColumnCase overrides.
43 my ($self, $query) = @_;
48 sub retrieve_from_sql {
49 my ($class, $cond, @rest) = @_;
51 $cond =~ s/^\s*WHERE//i;
53 # Need to parse the SQL clauses after WHERE in reverse
54 # order of appearance.
58 if( $cond =~ s/\bLIMIT\s+(\d+)\s*$//i ) {
62 if ( $cond =~ s/\bORDER\s+BY\s+(.*)\s*$//i ) {
63 $attrs{order_by} = $1;
66 if( $cond =~ s/\bGROUP\s+BY\s+(.*)\s*$//i ) {
67 $attrs{group_by} = $1;
70 return $class->search_literal($cond, @rest, ( %attrs ? \%attrs : () ) );
75 my $obj = $class->resultset_instance->new_result(@_);
81 sub retrieve_all { shift->search }
82 sub count_all { shift->count }
84 sub maximum_value_of {
85 my($class, $col) = @_;
86 return $class->resultset_instance->get_column($col)->max;
89 sub minimum_value_of {
90 my($class, $col) = @_;
91 return $class->resultset_instance->get_column($col)->min;