... | ... |
@@ -1002,6 +1002,20 @@ sub setup_model { |
1002 | 1002 |
return $self; |
1003 | 1003 |
} |
1004 | 1004 |
|
1005 |
+sub available_data_type { |
|
1006 |
+ my $self = shift; |
|
1007 |
+ |
|
1008 |
+ my $data_types = "Data Type (Type name)\n"; |
|
1009 |
+ foreach my $i (-1000 .. 1000) { |
|
1010 |
+ my $type_info = $self->dbh->type_info($i); |
|
1011 |
+ my $data_type = $type_info->{DATA_TYPE}; |
|
1012 |
+ my $type_name = $type_info->{TYPE_NAME}; |
|
1013 |
+ $data_types .= "$data_type ($type_name)\n" |
|
1014 |
+ if defined $data_type; |
|
1015 |
+ } |
|
1016 |
+ return $data_types; |
|
1017 |
+} |
|
1018 |
+ |
|
1005 | 1019 |
sub type_rule { |
1006 | 1020 |
my $self = shift; |
1007 | 1021 |
|
... | ... |
@@ -1009,19 +1023,6 @@ sub type_rule { |
1009 | 1023 |
my $type_rule = _array_to_hash([@_]); |
1010 | 1024 |
$self->{type_rule} = $type_rule; |
1011 | 1025 |
$self->{_into} ||= {}; |
1012 |
- |
|
1013 |
- foreach my $i (-1000 .. 1000) { |
|
1014 |
- my $type_info = $self->dbh->type_info($i); |
|
1015 |
- my $data_type = $type_info->{DATA_TYPE}; |
|
1016 |
- my $type_name = $type_info->{TYPE_NAME}; |
|
1017 |
- foreach my $type (keys %$type_rule) { |
|
1018 |
- use Data::Dumper; |
|
1019 |
- if ($type_name && lc $type eq lc $type_name) { |
|
1020 |
- $type_rule->{$data_type} = $type_rule->{$type}; |
|
1021 |
- } |
|
1022 |
- } |
|
1023 |
- } |
|
1024 |
- |
|
1025 | 1026 |
$self->each_column(sub { |
1026 | 1027 |
my ($dbi, $table, $column, $column_info) = @_; |
1027 | 1028 |
|
... | ... |
@@ -141,13 +141,8 @@ $dbi->type_rule( |
141 | 141 |
$date =~ s/aaaaa//g; |
142 | 142 |
return $date; |
143 | 143 |
}, |
144 |
- from => sub { |
|
145 |
- my $date = shift; |
|
146 |
- $date .= 'bbbbb'; |
|
147 |
- return $date; |
|
148 |
- } |
|
149 | 144 |
}, |
150 |
- 'DATETIME' => { |
|
145 |
+ DATETIME => { |
|
151 | 146 |
into => sub { |
152 | 147 |
my $date = shift; |
153 | 148 |
$date =~ s/ccccc//g; |
... | ... |
@@ -155,7 +150,16 @@ $dbi->type_rule( |
155 | 150 |
|
156 | 151 |
}, |
157 | 152 |
}, |
158 |
- 'TIMESTAMP' => { |
|
153 |
+ # DATE |
|
154 |
+ 9 => { |
|
155 |
+ from => sub { |
|
156 |
+ my $date = shift; |
|
157 |
+ $date .= 'bbbbb'; |
|
158 |
+ return $date; |
|
159 |
+ } |
|
160 |
+ }, |
|
161 |
+ # DATETIME or TIMPESTANM |
|
162 |
+ 11 => { |
|
159 | 163 |
from => sub { |
160 | 164 |
my $date = shift; |
161 | 165 |
$date .= 'ddddd'; |