[Dbix-class] enum column values

Rob Kinyon rob.kinyon at gmail.com
Tue Mar 8 13:59:45 GMT 2011


Have you tried just using the column without declaring the enum
values? The stuff in column_info isn't really used unless you're
creating the schema from DBIC. DBIC doesn't actually do any validation
of enum values (or anything else, for that matter) when you read from
or write to the database.

Rob

On Tue, Mar 8, 2011 at 06:33, Dave Howorth <dhoworth at mrc-lmb.cam.ac.uk> wrote:
> 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
>
> _______________________________________________
> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk
>



-- 
Thanks,
Rob Kinyon



More information about the DBIx-Class mailing list