Skip Menu |
 

This queue is for tickets about the DBIx-Class CPAN distribution.

Report information
The Basics
Id: 98133
Status: rejected
Priority: 0/
Queue: DBIx-Class

People
Owner: Nobody in particular
Requestors: TIMB [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: get_inflated_column should not throw an exception on column with no explicit inflation defined
Download (untitled) / with headers
text/plain 1.3k
I have generic code that wants inflated values for individual columns that may or may not have inflation defined. It seems reasonable to me to view all columns has having an implicit 'null' (transparent) inflation by default. I see no value in get_inflated_column throwing an exception. A workaround would be to call get_inflated_columns but that's expensive when I only want one column, for example. I suggest a change from this: sub get_inflated_column { my ($self, $col) = @_; $self->throw_exception("$col is not an inflated column") unless exists $self->column_info($col)->{_inflate_info}; return $self->{_inflated_column}{$col} if exists $self->{_inflated_column}{$col}; my $val = $self->get_column($col); return $val if ref $val eq 'SCALAR'; #that would be a not-yet-reloaded sclarref update return $self->{_inflated_column}{$col} = $self->_inflated_column($col, $val); } To something like this: sub get_inflated_column { my ($self, $col) = @_; return $self->{_inflated_column}{$col} if exists $self->{_inflated_column}{$col}; my $val = $self->get_column($col); return $val if ref $val eq 'SCALAR'; #that would be a not-yet-reloaded sclarref update return $val unless exists $self->column_info($col)->{_inflate_info}; return $self->{_inflated_column}{$col} = $self->_inflated_column($col, $val); }
Download (untitled) / with headers
text/plain 334b
ilmari suggested $self->${\( $self->column_info($col)->{accessor} || $col) } then mattp pointed out that $self->$col would do what I want (unless I've renamed the resultsource column accessor). So this is less of an issue than I thought. It's perhaps now just a matter of pointing out the above in the docs for get_inflated_column.
Download (untitled) / with headers
text/plain 1.1k
On Mon Aug 18 12:43:56 2014, TIMB wrote: Show quoted text
> I have generic code that wants inflated values for individual columns > that may or may not have inflation defined. > > It seems reasonable to me to view all columns has having an implicit > 'null' (transparent) inflation by default. > I see no value in get_inflated_column throwing an exception.
It gets more complicated when you consider that there is also filtering (which is separate from IC) and that there is also the rel/column duality (the artifact from the CDBI days). All in all get_inflated_column(s) is not the proper way to get all the various inflation values from on object - calling the accessor explicitly is the right way to do this. Show quoted text
> A workaround would be to call get_inflated_columns but that's > expensive when I only want one column, for example.
This will not get you filters as noted above. All in all this is a fundamental design issue, and I am very disinclined to try to address it within the current framework of ::Core, given the amount of cross-pollinating misdesigns. I may however be overthinking this - so please feel free to tell me that how/why I may be wrong . I will mark the ticket as rejected for the time being, feel free to reopen it.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.