DBIx::Class::CDBICompat::Retrieve;
use strict;
+
+# even though fatalization has been proven over and over to be a universally
+# bad idea, this line has been part of the code from the beginning
+# leaving the compat layer as-is, something may in fact depend on that
use warnings FATAL => 'all';
+use base 'DBIx::Class';
sub retrieve {
my $self = shift;
$cond =~ s/^\s*WHERE//i;
- if( $cond =~ s/\bLIMIT (\d+)\s*$//i ) {
- push @rest, { rows => $1 };
+ # Need to parse the SQL clauses after WHERE in reverse
+ # order of appearance.
+
+ my %attrs;
+
+ if( $cond =~ s/\bLIMIT\s+(\d+)\s*$//i ) {
+ $attrs{rows} = $1;
}
- if ( $cond =~ s/\bORDER\s+BY\s+(.*)$//i ) {
- push @rest, { order_by => $1 };
+ if ( $cond =~ s/\bORDER\s+BY\s+(.*)\s*$//i ) {
+ $attrs{order_by} = $1;
}
- return $class->search_literal($cond, @rest);
+ if( $cond =~ s/\bGROUP\s+BY\s+(.*)\s*$//i ) {
+ $attrs{group_by} = $1;
+ }
+
+ return $class->search_literal($cond, @rest, ( %attrs ? \%attrs : () ) );
}
sub construct {
my $class = shift;
my $obj = $class->resultset_instance->new_result(@_);
$obj->in_storage(1);
-
+
return $obj;
}