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

Josef Karthauser joe at tao.org.uk
Sun Nov 5 17:06:20 GMT 2006


Hi there,

I'm getting up to speed on DBIx::Class, in the context of Catalyst.
Can someone help me with this query?

I need to validate whether a particular column exists in the schema
before calling a search, as I get an SQL error if it doesn't exist.

I'm doing something like this:

        my $order_by = $c->request->params->{order_by} || $default_order;
        my $rs = $c->model('Domain')->
            search(undef,
                { page => $page, rows => 10,
                  order_by => $order_by,
                  prefetch => ['registrant', 'owner']
                });

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.

Thanks for you help :),
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/eb6df265/attachment.pgp


More information about the Dbix-class mailing list