override _column_data_type for SQLite
Justin Hunter [Sun, 26 Jul 2009 16:29:37 +0000 (09:29 -0700)]
lib/SQL/Translator/Parser/DBI/SQLite.pm

index cb6fb7f..49c4cb1 100644 (file)
@@ -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;
+    }
+
 }