We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sometimes a DBIC schema uses an alternative accessor instead of the actual column name, especially when working with legacy databases, e.g.
__PACKAGE__->add_columns( "uco" => { accessor => "username", data_type => "text", is_nullable => 0, original => { data_type => "varchar" }, }, ... );
However, search conditions must use the actual column name, not the accessor. So the following will not work:
$rs->search( { username => { '!=', $row->username }, ... );
But HFH::Model::DBIIC uses the accessor instead of the actual name (from line 260):
my $accessor = $field->accessor; my $count = $rs->search( { $accessor => $value, @id_clause } )->count;
You can work around this
use List::Util 1.29 qw/ pairmap /; # These aliases could probably be saved in an attribute my %aliases = pairmap { $b->{accessor} || $a => $a, $a => $a } %{ $self->resultset->result_source->columns_info }; my $accessor = $field->accessor; my $column = $aliases{ $accessor } || $accessor; my $count = $rs->search( { $column => $value, @id_clause } )->count;
The text was updated successfully, but these errors were encountered:
Look up column name from accessor
7b223ca
This fixes gshank#18 by using the column name instead of the accessor in the search condition.
Successfully merging a pull request may close this issue.
Sometimes a DBIC schema uses an alternative accessor instead of the actual column name, especially when working with legacy databases, e.g.
However, search conditions must use the actual column name, not the accessor. So the following will not work:
But HFH::Model::DBIIC uses the accessor instead of the actual name (from line 260):
You can work around this
The text was updated successfully, but these errors were encountered: