From: Arthur Axel 'fREW' Schmidt Date: Mon, 30 Apr 2012 14:50:02 +0000 (-0500) Subject: fix sizeless types and typemap for SQLite X-Git-Tag: v0.11011~6 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8224e2cf559a6ef91ffeebf9c31208726d6378bb;p=dbsrgits%2FSQL-Translator.git fix sizeless types and typemap for SQLite --- diff --git a/lib/SQL/Translator/Generator/DDL/SQLite.pm b/lib/SQL/Translator/Generator/DDL/SQLite.pm index c195ea2..ec2febe 100644 --- a/lib/SQL/Translator/Generator/DDL/SQLite.pm +++ b/lib/SQL/Translator/Generator/DDL/SQLite.pm @@ -15,12 +15,17 @@ sub name_sep { q(.) } sub _build_type_map { +{ - date => 'datetime', - 'time' => 'datetime', + set => 'varchar', + bytea => 'blob', } } -sub _build_sizeless_types { +{ text => 1 } } +sub _build_sizeless_types { + +{ + text => 1, + blob => 1, + } +} sub _build_numeric_types { +{ int => 1, diff --git a/t/56-sqlite-producer.t b/t/56-sqlite-producer.t index 3151ddb..79e7880 100644 --- a/t/56-sqlite-producer.t +++ b/t/56-sqlite-producer.t @@ -74,4 +74,40 @@ $SQL::Translator::Producer::SQLite::NO_QUOTES = 0; is_deeply($result, $expected, 'correctly unquoted DEFAULT'); } +{ + my $table = SQL::Translator::Schema::Table->new( + name => 'foo', + ); + $table->add_field( + name => 'data', + data_type => 'bytea', + ); + $table->add_field( + name => 'data2', + data_type => 'set', + ); + $table->add_field( + name => 'data2', + data_type => 'set', + ); + $table->add_field( + name => 'data3', + data_type => 'text', + size => 30, + ); + $table->add_field( + name => 'data4', + data_type => 'blob', + size => 30, + ); + my $expected = [ qq]; + my $result = [SQL::Translator::Producer::SQLite::create_table($table, { no_comments => 1 })]; + is_deeply($result, $expected, 'correctly translated bytea to blob'); +} + done_testing;