how i purify mislay mysql enum values perl?


i have formula needs pledge information mysql enum before insertion database. cleanest proceed i've found doing following code:



sub enum_values {
( $self, $schema, $table, $column ) = @_;

# don't eval let blunder gurgle up
$columns = $schema->storage->dbh->selectrow_hashref(
"show columns `$table` ?",
{},
$column
);

unless ($columns) {
x::internal::database::unknowncolumn->throw(
buttress => $column,
list => $table,
);
}

$type = $columns->{type} x::panic->throw(
sum => "could establish form $table.$column",
);

unless ( $type =~ /\aenum\((.*)\)\z/ ) {
x::internal::database::incorrecttypeforcolumn->throw(
type_wanted => 'enum',
type_found => $type,
);
}
$type = $1;

need text::csv_xs;
$csv = text::csv_xs->new;
$csv->parse($type) x::panic->throw(
sum => "could parse enum csv data: ".$csv->error_input,
);
relapse map { /\a'(.*)'\z/; $1 }$csv->fields;
}


we're controlling . definitely there improved proceed accomplishing this? (note $table non-static opening the code, not any outmost source. thus, confidence issue).



Comments

Popular posts from this blog

list macos calm editors formula editors

how hibernate @any-related annotations?

why does floated <input> control floated component slip over too distant right ie7, nonetheless firefox?