X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FSQL%2FTranslator%2FParser%2FSQLite.pm;h=102433042ec8c180689114437890271d1c6e9ecc;hb=c601ca5da1eabe59d4dd09b9265923573fb72ec6;hp=55f6e8d835629753cd80663d33b6434a7cb38f33;hpb=7179cb094a6f8ef0c4471a2c329090a9a53fa3a5;p=dbsrgits%2FSQL-Translator.git diff --git a/lib/SQL/Translator/Parser/SQLite.pm b/lib/SQL/Translator/Parser/SQLite.pm index 55f6e8d..1024330 100644 --- a/lib/SQL/Translator/Parser/SQLite.pm +++ b/lib/SQL/Translator/Parser/SQLite.pm @@ -433,6 +433,17 @@ table_constraint : PRIMARY_KEY parens_field_list conflict_clause(?) on_conflict => $item[5][0], } } + | + FOREIGN_KEY parens_field_list REFERENCES ref_def + { + $return = { + supertype => 'constraint', + type => 'foreign_key', + fields => $item[2], + reference_table => $item[4]{'reference_table'}, + reference_fields => $item[4]{'reference_fields'}, + } + } ref_def : /(\w+)\s*\((\w+)\)/ { $return = { reference_table => $1, reference_fields => $2 } } @@ -573,6 +584,8 @@ NOT_NULL : /not null/i PRIMARY_KEY : /primary key/i +FOREIGN_KEY : /foreign key/i + CHECK_C : /check/i DEFAULT : /default/i @@ -674,7 +687,7 @@ sub parse { for my $idata ( @{ $tdata->{'indices'} || [] } ) { my $index = $table->add_index( name => $idata->{'name'}, - type => uc $idata->{'type'}, + type => uc ($idata->{'type'}||''), fields => $idata->{'fields'}, ) or die $table->error; }