[Dbix-class] Get the column names from a resultset
Peter Rabbitson
rabbit+dbic at rabbit.us
Tue Jul 1 13:44:54 GMT 2014
On Tue, Jul 01, 2014 at 12:05:36PM +0000, RAPPAZ Francois wrote:
> I understand that I can retrieve a limited list of columns from a table using
>
> $rs = $self->{schema}->resultset('User')->search_rs(undef, {columns => [qw / id_user nom prenom / ], order_by => 'nom',});
>
> Now, is there a way to retrieve the columns names from a result set, when such a object is received as an argument ?
>
> Is there a way to have
>
> @colnames = $resultset->get_column_names;
Not currently. Work is being planned on this but it is more involved
than it appears on the surface.
As of now it's recommended to just carry around the set of columns with
you. You can also dig in the return of $rs->_resolved_attrs, HOWEVER
THIS IS UNSUPPORTED AND *WILL* CHANGE without a warning. So make sure to
write sufficient tests if yoiu go this route.
Cheers
More information about the DBIx-Class
mailing list