[Dbix-class] better HTML-Widget integration

Carl Franks fireartist at gmail.com
Fri Mar 24 15:11:47 CET 2006


I've started work on extra HTML-Widget constraints at
http://dev.catalyst.perl.org/repos/Catalyst/trunk/HTML-Widget-Constraint-MySQL/

At the moment, the intended use is something like:
    $w->constraint( 'MySQL::VARCHAR', 'name' )->length( 30 );

What I'd like is a better front-end, so that the user's code isn't
mysql specific, and can use other database's constraints, if they're
available.

I'm imagining something like this:
    $w->constraint( 'DBColumn', 'name' )->class( 'UserClass' );
and if the field-name isn't the same as the column name:
    $w->constraint( 'DBColumn', 'name' )->class( 'UserClass'
)->column( 'username' );

What this would require though, is an API in DBIx-Class to retrieve
the database type:
'mysql', 'Pg', etc
and the column datatype:
'INT', 'VARCHAR(10)', 'ENUM('a', 'b')
from the *database*

I don't want the DBIx-Class user to have to put these values into their classes.
Each database backend should be able to get this info from the database.
Yes, it'll be very database-specific, but that's the job of each
constraint's database-backend to know what to do with it.

It needs to be very database specific. For example,
HTML-Widget-Constraint-MySQL can currently validate string length
based on byte length or character length, by knowing the mysql-server
version. This is the sort of specificity I'd need for the constraints
to be really useful.

Does anyone have any opinions on this suggestion?
Does anyone have any ideas for how the API might look?
Is anyone willing to work on this?

I'd be happy to try and get the mysql support working if an API were agreed.

Carl



More information about the Dbix-class mailing list