[Dbix-class] ResultSetManager default "ResultSet" overloading search ?

Jesper Krogh jesper at krogh.cc
Mon Aug 7 15:17:02 CEST 2006


Hi.

I've problably gotten "wrong" into this problem.

I have a table with a text-field, and all I'd like it to have
"length(textfield)" to show up as any other table attribute.. (readonly),
thereby being able to search by it and order by it.

There is apparently no means to put it in the table definitions.. I
thought that was the obvious place to look, but using the
"ResultSetManager" I'm able to do stuff like this:

sub search_default : ResultSet {
    my $self = shift;
    return $self->search(undef,{ '+select' => { "length" =>
'me.textfield'},'+as' => ["textfield_length"]});
}

And dropping in the correct accessor.

This is just not entirely what I want since this only applies to
records found via ->search_default() Better would be that I could overload
the ordinary ->search() with this one.. but that still doesnt make
->textfield_length() work on elements found via ->find().

This could be done using the ResultSetColumn stuff but this gives another
trip back to the database on this one.. and still doesn't work in searches.

Where would the approiate place to put stuff like this be?

Jesper
-- 
Jesper Krogh




More information about the Dbix-class mailing list