[Dbix-class] How do I determine whether a column name is valid?

Josef Karthauser joe at tao.org.uk
Sun Nov 5 23:47:29 GMT 2006


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.
-- 
Josef Karthauser (joe at tao.org.uk)	       http://www.josef-k.net/
Physics Particle Theory (student)   http://www.pact.cpes.sussex.ac.uk/
================ An eclectic mix of fact and theory. =================
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
Url : http://jules.scsys.co.uk/pipermail/dbix-class/attachments/20061105/5b6872ec/attachment.pgp


More information about the Dbix-class mailing list