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


_______________________________________________
List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
Wiki: http://dbix-class.shadowcatsystems.co.uk/
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
Searchable Archive: http://www.mail-archive.com/[email protected]/

Reply via email to