[Dbix-class] Should DBIC prefix the table alias on columns in a
WHERE?
Bill Moseley
moseley at hank.org
Wed May 12 19:10:19 GMT 2010
On Wed, May 12, 2010 at 9:48 AM, Peter Rabbitson
<rabbit+dbic at rabbit.us<rabbit%2Bdbic at rabbit.us>
> wrote:
> > So, my question is should (or can??) DBIC add the alias to the "id" in
> > the WHERE? The problem, of course, is if there's a join with another
> > table that also has an "id" column.
>
> No. You qualify yourself as DBIC can not possibly know what you meant.
>
Ok, I was not clear how DBIC manages search conditions.
DBIC does know to prefix the columns, so I was curious if also possible with
the search conditions. I guess not.
$col =3D join( '.', $current_source_alias, $col ) if $col !~ m{\.} &&
$self->has_column( $col )
> > my %criteria =3D ( 'me.' . $primary_keys[0] =3D> $id );
>
> This is totally wrong. This is *exactly* what current_source_alias is
> for. You should use it in place of 'me'
>
Yes, but what I was trying to explain is that at the time the above code is
run the alias does not exist -- that's even before a resultset has been
created so there's no current_source_alias.
But, there's easy work arounds, yes. Thanks for your replies.
-- =
Bill Moseley
moseley at hank.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20100512/463=
4a994/attachment.htm
More information about the DBIx-Class
mailing list