[Dbix-class] join problem ( change alias for table )

Oleg Pronin syber.rus at gmail.com
Tue Jan 20 20:52:41 GMT 2009


that depends on what u mean

2009/1/20 Howe, Tom (IDEAS PRACTICE AREAS) <Tom.Howe at morganstanley.com>

>  Are there any good examples of modelling inheritance with DBIx::Class?
> Thanks,
>
>
>  ------------------------------
> *From:* Oleg Pronin [mailto:syber.rus at gmail.com]
> *Sent:* 20 January 2009 15:11
> *To:* DBIx::Class user and developer list
> *Subject:* Re: [Dbix-class] join problem ( change alias for table )
>
> The best way is to use quote_char
>
> In your MyDB.pm Model:
>
> __PACKAGE__->config(
>     schema_class =3D> ...
>     connect_info =3D> [
>         ...,
>         {
>             quote_char =3D> q{"},
>             name_sep   =3D> q{.},
>         },
>     ],
> );
>
> But you will still in trouble when writing
>
> order_by =3D> 'user DESC'
> because of bug in SQL Abstarct, you will get  ORDER BY "user DESC"
>
> the workaround is to write
> order_by =3D> \' "user" DESC',
> or
> order_by =3D> \'me.user DESC',
>
>
>
> 2009/1/20 ivan <ivan at price.ru>
>
>> my $s =3D  $c->model('MyDB');
>> my $result =3D $s ->resultset('Client') -> search(
>> { 'id' =3D> $id },
>> join =3D>  [qw/ user /],
>> );
>>
>> Result SQL:
>>
>> SELECT COUNT( * ) FROM client me LEFT OUTER JOIN users user ON (
>> user.user_id =3D me.user_id ) WHERE ( id =3D ? )
>>
>> But 'user' - it is PostgreSQL reserve word.
>>
>>
>> can I change alias for table users ?
>>
>> _______________________________________________
>> 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
>>
>
>  ------------------------------
>
> NOTICE: If received in error, please destroy and notify sender. Sender do=
es
> not intend to waive confidentiality or privilege. Use of this email is
> prohibited when received in error.
>
> _______________________________________________
> 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/20090120/6e2=
d9129/attachment-0001.htm


More information about the DBIx-Class mailing list