[Dbix-class] convention for naming primary keys to avoid ambiguousselects

Brian Phillips bpphillips+ml at gmail.com
Tue Nov 25 21:56:17 GMT 2008


prefixing the "id" column with the name of the relationship seems much more
obvious than prefixing the base table's column with "me".  This doesn't seem
like it would be too complicated to implement -- if the column given is not
already prefixed by one or more table/relationship aliases, it could be
automatically changed to "me.$col".

On Tue, Nov 25, 2008 at 3:41 PM, Peter Rabbitson
<rabbit+list at rabbit.us<rabbit%2Blist at rabbit.us>
> wrote:

> Noel Burton-Krahn wrote:
> > On Tue, Nov 25, 2008 at 10:22 AM, Peter Rabbitson <rabbit+list at rabbit.u=
s<rabbit%2Blist at rabbit.us>>
> wrote:
> >
> > Consider the following search from a schema where person and address
> > both have a column named 'id':
> >
> > $schema->resultset('Person')->search({ id =3D> $person_id}, { prefetch
> > =3D> [ 'address' ] });
> >
> > This is a reasonable query:  load a person with address by the
> > person's id.  The 'id' column is unambiguous in the search call.
>
> Excellent example. Now tell me how to express the query "Get me all
> Persons which have an Address with (address.)id =3D=3D $address_id, while
> prefetching the Address data as well.
>
> _______________________________________________
> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> Searchable Archive:
> http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20081125/dd8=
7c294/attachment-0001.htm


More information about the DBIx-Class mailing list