Permalink
Browse files

dump sql type name.

  • Loading branch information...
karupanerura committed Sep 3, 2014
1 parent 456fa7a commit b57ce92df30c3f5f82a5fe334588b6e0816bcd99
Showing with 5 additions and 1 deletion.
  1. +5 −1 lib/Teng/Schema/Dumper.pm
@@ -3,6 +3,9 @@ use strict;
use warnings;
use DBIx::Inspector 0.03;
use Carp ();
use DBI ();
my %SQLTYPE2NAME = map { &{$DBI::{$_}} => $_ } @{$DBI::EXPORT_TAGS{sql_types}};
sub dump {
my $class = shift;
@@ -27,6 +30,7 @@ sub dump {
$ret .= "package ${namespace}::Schema;\n";
$ret .= "use strict;\n";
$ret .= "use warnings;\n";
$ret .= "use DBI qw/:sql_types/;\n";
$ret .= "use Teng::Schema::Declare;\n";
$ret .= "base_row_class '$args{base_row_class}';\n" if $args{base_row_class};
for my $table_info (sort { $a->name cmp $b->name } $inspector->tables) {
@@ -49,7 +53,7 @@ sub _render_table {
$ret .= " columns (\n";
for my $col ($table_info->columns) {
if ($col->data_type) {
$ret .= sprintf(" {name => '%s', type => %s},\n", $col->name, $col->data_type);
$ret .= sprintf(" {name => '%s', type => %s},\n", $col->name, $SQLTYPE2NAME{$col->data_type});
} else {
$ret .= sprintf(" '%s',\n", $col->name);
}

0 comments on commit b57ce92

Please sign in to comment.