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';
13 die "No args to retrieve" unless @_ > 0;
15 my @cols = $self->primary_columns;
18 if (ref $_[0] eq 'HASH') {
19 $query = { %{$_[0]} };
23 @{$query}{@cols} = @_;
29 $query = $self->_build_query($query);
35 my $query = ref $_[0] eq 'HASH' ? shift : {@_};
37 $query = $self->_build_query($query);
38 $self->next::method($query);
43 # Build a query hash. Defaults to a no-op; ColumnCase overrides.
46 my ($self, $query) = @_;
51 sub retrieve_from_sql {
52 my ($class, $cond, @rest) = @_;
54 $cond =~ s/^\s*WHERE//i;
56 # Need to parse the SQL clauses after WHERE in reverse
57 # order of appearance.
61 if( $cond =~ s/\bLIMIT\s+(\d+)\s*$//i ) {
65 if ( $cond =~ s/\bORDER\s+BY\s+(.*)\s*$//i ) {
66 $attrs{order_by} = $1;
69 if( $cond =~ s/\bGROUP\s+BY\s+(.*)\s*$//i ) {
70 $attrs{group_by} = $1;
73 return $class->search_literal($cond, @rest, ( %attrs ? \%attrs : () ) );
78 my $obj = $class->resultset_instance->new_result(@_);
84 sub retrieve_all { shift->search }
85 sub count_all { shift->count }
87 sub maximum_value_of {
88 my($class, $col) = @_;
89 return $class->resultset_instance->get_column($col)->max;
92 sub minimum_value_of {
93 my($class, $col) = @_;
94 return $class->resultset_instance->get_column($col)->min;