Archive for the ‘perl’ Category

my vote for mst’s forfeit

Wednesday, May 19th, 2010

My bid for mst’s forfeit.

I think he might make a creepy young Doc Brown from back to the future…

Now this is at least a way of making me make time to do an iron man blog post…

Of course, I misread the post, I missed the part about still being in the aggregator, which I am not, due to my utter failure at blogging. :)

A note about fey

Wednesday, June 17th, 2009

I am in the process of transitioning a DBIx::Class application to Fey abd Fey::ORM. I must say Fey::ORM is more comfortable than DBIC.

Fey is a framework for representing database schemas and generating queries from that representation. Fey::ORM is a SQL-lovers object-relational mapping built on top of Fey’s impressive SQL generation capabilities.

I do mean impressive, as Fey is able to infer join conditions entirely on its own:

# A User has many units, and units have many users, via the lnk_unit_users table.

my $unit_users = $schema->table('lnk_unit_users');
my $unit       = $schema->table('lkup_unit');

my $select_units = $factory->new_select
    ->select($unit)
    ->from($unit, $unit_users)
    ->where($unit_users->column('user_id'), '=', Fey::Placeholder->new)
;

has_many 'units' => (
    table       => $unit,
    select      => $select_units,
    bind_params => sub { $_[0]->user_id },
);

So, when I go $user->units, I get an iterator object full of Units, which executes the following sql:

SELECT *
    FROM lkup_unit 
    JOIN lnk_unit_users ON (lnk_unit_users.unit_id = lkup_unit.unit_id) 
    WHERE lnk_unit_users.user_id = ?

Note, in my $select_units query I did not specify the join condition, I merely passed two Fey::Table objects, and using the foreign key constraints Fey figured out what to do.

I think this is pretty cool. :)

Perl Oasis 2009

Tuesday, January 27th, 2009

So, in addition to the new job, another interesting thing that happened: I delivered a talk at Perl Oasis 2009.

I was quite nervous, but it turned out alright. I hope next year I can give a more interesting talk.

Oh, also I met a bunch cool perl people, including Jonathon Rockway, who is coincidently one of my new co-workers.