http://qs321.pair.com?node_id=1053571

gryphon has asked for the wisdom of the Perl Monks concerning the following question:

Greetings all,

I have a DBIx::Class schema loader + Moose role + accessor problem/question. I've got DBIx::Class schema loader building a schema, and from this there's a generated class, specifically *::Result::User for the "user" table. In that table, there's a "passwd" column that I'd like to encrypt/decrypt magically in DBIC appropriately on read/write. In the schema loader configuration, I'm asking for a specific Moose role to get added to the *::Result::User class. Ultimately, I'd like to tell DBIC that the "passwd" column should have a "_passwd" accessor, then write a "sub passwd" in the role.

To get to this, I added a "custom_column_info" key to my schema loader configuration. If I want to add any keys to the column definitions, this works perfectly as expected. However, for some reason, any "accessor" keys are silently filtered and never end up in the generated schema classes.

Here's the schema loader code:

#!/usr/bin/env perl use strict; use warnings; use DBIx::Class::Schema::Loader 'make_schema_at'; use App::Conf; my ( $dsn, $dbname, $username, $password ) = @{ App::Conf->new->get('database') }{ qw( dsn dbname username pass +word ) }; make_schema_at( 'App::Db::Schema', { dump_directory => 'lib', naming => 'current', quiet => 0, generate_pod => 1, use_namespaces => 1, use_moose => 1, schema_base_class => 'App::Db', result_roles_map => { User => ['App::Db::Base::Result::User'], }, custom_column_info => sub { my ( $table_name, $column_name, $column_info ) = @_; if ( $table_name eq 'user' and $column_name eq 'passwd' ) +{ $column_info->{accessor} = '_passwd'; } return $column_info; }, }, [ $dsn . $dbname, $username, $password ], );

What am I doing wrong here? Thanks.