[Dbix-class] enum column values

Dave Howorth dhoworth at mrc-lmb.cam.ac.uk
Tue Mar 8 11:33:02 GMT 2011


I have to connect to a database that is basically stable but where one
particular ENUM column might have a different set of values when I
connect to it each time. (I know this is not ideal). I'm looking for the
least evil way to do this.

I think I need to interrogate the database to get the set of values.
Since it's mysql, I can do that using the DBI $dbh->column_info and the
'mysql_values' key. But I'm not sure if there is a more generic way.

I then need to install the values in the column's DBIC data structure. I
think I can do that by using remove_column and add_column in the table's
ResultSource class, once I have a ResultSet by which access a
ResultSource object. But I don't know if there's a way to get the dbh
during initialization so I can supply the current enum values to
add_columns during initialization.

Or perhaps there's a simpler way to do the whole thing?

Cheers, Dave



More information about the DBIx-Class mailing list