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

Howe, Tom (IDEAS PRACTICE AREAS) Tom.Howe at MorganStanley.com
Tue Jan 20 16:39:40 GMT 2009


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 => ...
    connect_info => [
        ...,
        {
            quote_char => q{"},
            name_sep   => q{.},
        },
    ],
);

But you will still in trouble when writing

order_by => 'user DESC'
because of bug in SQL Abstarct, you will get  ORDER BY "user DESC"

the workaround is to write
order_by => \' "user" DESC',
or
order_by => \'me.user DESC',



2009/1/20 ivan <ivan at price.ru<mailto:ivan at price.ru>>
my $s =  $c->model('MyDB');
my $result = $s ->resultset('Client') -> search(
{ 'id' => $id },
join =>  [qw/ user /],
);

Result SQL:

SELECT COUNT( * ) FROM client me LEFT OUTER JOIN users user ON (
user.user_id = me.user_id ) WHERE ( id = ? )

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<http://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 does not intend to waive confidentiality or privilege. Use of this email is prohibited when received in error.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20090120/d6ba14ca/attachment.htm


More information about the DBIx-Class mailing list