[Dbix-class] Re: How to grep field types?

A. Pagaltzis pagaltzis at gmx.de
Fri May 11 12:31:25 GMT 2007


Hi RA,

* RA Jones <ra.jones at dpw.clara.co.uk> [2007-05-11 12:55]:
> In a Cat controller, the equivalent of $schema->source('Foo')
> is $c->model->('Schema::Foo') ?

that returns a ResultSet, not a ResultSource. You get the source
by asking the set for it using… uh… `result_source`.

> my @date_fields = grep { 
> $c->model('Schema::Foo')->column_info($_)->{data_type} eq 'date' } keys 
> %{ $form->field };

That unnecessarily goes down the chain for every key in the hash. 

    my $src = $c->model('Schema::Foo')->result_source;
    
    my @date_fields = (
        grep { $src->column_info($_)->{data_type} eq 'date' }
        keys %{ $form->field }
    );

Regards,
-- 
Aristotle Pagaltzis // <http://plasmasturm.org/>



More information about the Dbix-class mailing list