Josef Karthauser wrote:
> On Sun, Nov 05, 2006 at 02:52:24PM -0500, Christopher H. Laco wrote:
>>> So, the value of order_by can be something like 'domainname' or
>>> 'owner.username'.
>>>
>>> How do I check with D::C whether the column exists before feeding it to
>>> search, which expects it to exist?  I've scanned loads of manual pages,
>>> but can't find anything relevant.
>>>
>> http://search.cpan.org/~blblack/DBIx-Class-0.07999_01/lib/DBIx/Class/ResultSource.pm#has_column
>>
>> model('Domain')->result_source->has_column('foo');
>>
> 
> I saw that, but it doesn't work for related columns, like 'owner.username'
> below,
> 
>     package Domain;
>     use base qw/DBIx::Class/;
> 
>     __PACKAGE__->load_components(qw/ PK::Auto Core /);
>     __PACKAGE__->table('domain');
>     __PACKAGE__->add_columns(qw/
>         domainid domainname owner
>     /);
>     __PACKAGE__->set_primary_key('domainid');
>     __PACKAGE__->belongs_to(owner => 'Owner');
> 
> Is there a sensible way I should approach achieving that knowledge?
> 
> Joe.


('Domain')->related_resultset('Owner')->result_source->has_column('foo')...

Of course, if you're working with the schema object itself...

$schema->source('Owner')->has_column

-=Chris

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
Wiki: http://dbix-class.shadowcatsystems.co.uk/
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
Searchable Archive: http://www.mail-archive.com/[email protected]/

Reply via email to