Subject: | raw sql ORDER_BY clause ignored |
My code works in 0.08118, but is broken in 0.08119; the changelog leads
me to suspect:
- Add $rs->is_ordered to test for existing order_by on a resultset
I first use raw SQL to define a specific ORDER BY sequence "myseq", in
the following method "bynum":
#----------------------------------------
sub bynum {
my $self = shift;
return $self->search(
{},
{ '+select' => [
\'(CASE WHEN num LIKE "U%" THEN 1 WHEN num LIKE "F%" THEN 2
when num LIKE "W%" THEN 3 ELSE 4 END) AS myseq'
],
'order_by' => ['myseq' ],
'+as' => ['myseq' ],
}
);
}
#----------------------------------------
When I use the above method (as follows), in 0.08119 DBIC throws an
error about "column myseq":
DBIx::Class::ResultSet::next(): DBI Exception: DBD::SQLite::db
prepare_cached failed:
no such column: myseq [for Statement "SELECT num, ... ORDER BY
myseq, ...
Here's the skeleton code, but if this needs more explanation, let me know.
#----------------------------------------
package DB::Schema::ResultSet::Pub;
use parent 'DBIx::Class::ResultSet';
sub foo {
my $self = shift;
return $self->search( ... )->bynum; # returns ordered rs
}
sub bar {
my $self = shift;
return $self
->foo # should be an ordered rs
->search( ... ); # error: "cant find column myseq"
}
#----------------------------------------
Then calling "->bar" gives the error msg. Thanks,