DBIx::Class 0.08001 released (and a podcast)
For those of you who're interested in me demonstrating just how badly I interview, you can hear a perlcast podcast interview with me about DBIx::Class which was recorded last month.
Better still, after 7 dev releases, four of them RC grade, a lot of bug fixing, a lot of hating databases, and sterling work from many many people, I'm proud to announce that DBIx::Class 0.08000 is on its way to being available from the CPAN! ... and of course two minutes after I wrote this, somebody found a bug. So please, please make sure you get 0.08001, not 0.08000.
Given it's been not that far short of a year since the last major release, there are quite a lot of new features to show for the time we've spent, so I'm just going to mention a few highlights here.
First, a short list of feature/bug stuff:
- deep prefetch now works for a lot more cases (and is completely rewritten to be clearer and faster)
- inflate_column now obeys 'accessor' column_info key for accessor naming
- multiple ordering columns in DBIx::Class::Ordered
- support for BYTEA and similar columns in Pg (and general support so other drivers can be updated)
- ANSI join syntax now unrolled into WHERE clause to support Oracle 8 and below
- modified reference approaches so $schema objects don't go out of scope anymore
- more efficient database disconnect handling and cleaner error reporting
- significant speed improvements in common row operations
- experimental Replication storage class for "modify master, select from slave" setups
There are also a few bigger things that I'd like to highlight.
DBIx::Class::Schema->load_namespaces
This is an alternative to load_classes which assumes an alternative layout for automatic class loading. It assumes that all result classes are underneath a sub-namespace of the schema called Result, any
corresponding ResultSet classes are underneath a sub-namespace of the schema
called ResultSet.
For example:
# load My::Schema::Result::CD, My::Schema::Result::Artist,
# My::Schema::ResultSet::CD, etc...
My::Schema->load_namespaces;# Override everything to use ugly names.
# In this example, if there is a My::Schema::Res::Foo, but no matching
# My::Schema::RSets::Foo, then Foo will have its
# resultset_class set to My::Schema::RSetBase
My::Schema->load_namespaces(
result_namespace => 'Res',
resultset_namespace => 'RSets',
default_resultset_class => 'RSetBase',
);# Put things in other namespaces
My::Schema->load_namespaces(
result_namespace => '+Some::Place::Results',
resultset_namespace => '+Another::Place::RSets',
);
DBIx::Class::Row->new/insert/update
DBIx::Class will now correctly handle being passed a hashref (for a one-one or many-one relationship) or arrayref of hashrefs (for a one-many relationship) at new() or update() time and the correct data will get created - for example
DBIx::Class::Schema::Versioned
my $artist = $schema->resultset('Artist')
->create({ name => 'Fred 2',
cds => [
{ title => 'Music to code by',
year => 2007,
},
],
});# Add a new CD
$artist->update({cds => [ $artist->cds,
{ title => 'Yet another CD',
year => 2006,
},
],
});
DBIx::Class also now has experimental schema versioning support. Adding
__PACKAGE__->load_components(qw/+DBIx::Class::Schema::Versioned/);
__PACKAGE__->upgrade_directory('/path/to/upgrades/');
__PACKAGE__->backup_directory('/path/to/backups/');
to your schema class, and calling $schema->create_ddl_dir to generate a directory of SQL files for your current schema version (which is best practice since it then allows deploy to work on target systems without SQL::Translator present) will allow you to call $schema->upgrade to do upgrades. See the perldoc for more details.
Have fun!