From: Ken Youens-Clark Date: Tue, 11 Aug 2009 21:32:31 +0000 (+0000) Subject: Test and data for FK in SQLite. X-Git-Tag: v0.11008~128 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7d8f0a61b9fbd54e85625c0f9857fc000ae11bfd;p=dbsrgits%2FSQL-Translator.git Test and data for FK in SQLite. --- diff --git a/t/27sqlite-parser.t b/t/27sqlite-parser.t index 8f1eac5..0540449 100644 --- a/t/27sqlite-parser.t +++ b/t/27sqlite-parser.t @@ -10,7 +10,7 @@ use SQL::Translator; use SQL::Translator::Schema::Constants; BEGIN { - maybe_plan(5, + maybe_plan(9, 'SQL::Translator::Parser::SQLite'); } SQL::Translator::Parser::SQLite->import('parse'); @@ -35,6 +35,15 @@ my $file = "$Bin/data/sqlite/create.sql"; my $t2 = shift @tables; is( $t2->name, 'pet', "'Pet' table" ); + my @constraints = $t2->get_constraints; + is( scalar @constraints, 3, '3 constraints on pet' ); + + my $c1 = pop @constraints; + is( $c1->type, 'FOREIGN KEY', 'FK constraint' ); + is( $c1->reference_table, 'person', 'References person table' ); + is( join(',', $c1->reference_fields), 'person_id', + 'References person_id field' ); + my @views = $schema->get_views; is( scalar @views, 1, 'Parsed one views' ); diff --git a/t/data/sqlite/create.sql b/t/data/sqlite/create.sql index f5ee2f5..d1a5323 100644 --- a/t/data/sqlite/create.sql +++ b/t/data/sqlite/create.sql @@ -11,7 +11,7 @@ create unique index u_name on person (name); create table pet ( pet_id int, - person_id int, + person_id int references person (person_id), name varchar(30), age int, check ( age < 100 ),