use Types::SQL qw/ Varchar /; use Types::Standard -types; use Types::SQL::Util; my $type = Maybe [ Varchar [$size] ]; my %info = column_info_from_type($type); # Info contains: # # ( data_type => 'varchar', # is_numeric => 0, # size => $size, # is_nullable => 1, # )
I've been thinking that it would be nice when using DBIx::Class to be able to define columns using Type::Tiny-style types, e.g.
column foo => ( isa => Maybe[Varchar] );
and have something that extracts the column info from the type.
Whether this should be a change to DBIC or a plugin/extension, I'm not yet sure. But the first thing is to create a type library and a utility function to extract the column_info from the type.
Part of the idea is that you can declare your own types that inherit from these types, and it should still work.