From: Justin Hunter Date: Sun, 26 Jul 2009 16:29:37 +0000 (-0700) Subject: override _column_data_type for SQLite X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=24457cfba1c7065020f15b3d5541ce63502ca071;p=dbsrgits%2FSQL-Translator-2.0-ish.git override _column_data_type for SQLite --- diff --git a/lib/SQL/Translator/Parser/DBI/SQLite.pm b/lib/SQL/Translator/Parser/DBI/SQLite.pm index cb6fb7f..49c4cb1 100644 --- a/lib/SQL/Translator/Parser/DBI/SQLite.pm +++ b/lib/SQL/Translator/Parser/DBI/SQLite.pm @@ -1,3 +1,25 @@ use MooseX::Declare; role SQL::Translator::Parser::DBI::SQLite { + use MooseX::Types::Moose qw(HashRef); + use SQL::Translator::Constants qw(:sqlt_types); + + my %data_type_mapping = ( + 'text' => SQL_LONGVARCHAR(), + 'timestamp' => SQL_TIMESTAMP(), + 'timestamp without time zone' => SQL_TYPE_TIMESTAMP(), + 'timestamp' => SQL_TYPE_TIMESTAMP_WITH_TIMEZONE(), + 'integer' => SQL_INTEGER(), + 'character' => SQL_CHAR(), + 'varchar' => SQL_VARCHAR(), + 'bigint' => SQL_BIGINT(), + ); + + method _column_data_type(HashRef $column_info) { + print $column_info->{TYPE_NAME} . "\n"; + my $data_type = defined $data_type_mapping{$column_info->{TYPE_NAME}} ? + $data_type_mapping{$column_info->{TYPE_NAME}} : + -1; + return $data_type; + } + }